-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[issues-2703] Update swag store link and add a disclaimer (#2709)
* [issues-2703] Update swag store link and add a disclaimer * Update / Create tests * Coverage --------- Co-authored-by: Martijn Verburg <[email protected]>
- Loading branch information
1 parent
477a489
commit 51b978e
Showing
6 changed files
with
282 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"leaving.site.disclaimer.modal.title": "Avis de non-responsabilité - Vous allez quitter notre site Web", | ||
"leaving.site.disclaimer.modal.continue": "Continuer", | ||
"leaving.site.disclaimer.modal.close": "Fermer", | ||
|
||
"swag.store.disclaimer": "En cliquant sur le bouton Continuer, vous quitterez notre site Web. Veuillez noter que de nouvelles conditions d'utilisation s'appliqueront à la boutique Eclipse Foundation, alimentée par Fourthwall : https://eclipse-foundation.store/." | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/components/LeavingSiteDisclaimerModal/__tests__/LeavingSiteDisclaimerModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { describe, expect, it, vi } from 'vitest' | ||
import LeavingSiteDisclaimerModal from '..'; | ||
|
||
describe('LeavingSiteDisclaimerModal component', () => { | ||
it('LeavingSiteDisclaimerModal renders correctly', () => { | ||
const { container } = render( | ||
<LeavingSiteDisclaimerModal /> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('LeavingSiteDisclaimerModal continue correctly', async () => { | ||
const { container } = render( | ||
<LeavingSiteDisclaimerModal /> | ||
); | ||
|
||
const cancelButton = container.querySelector('button[class="btn btn-primary"]'); | ||
|
||
await userEvent.click(cancelButton).then(async() => { | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
121 changes: 121 additions & 0 deletions
121
...avingSiteDisclaimerModal/__tests__/__snapshots__/LeavingSiteDisclaimerModal.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`LeavingSiteDisclaimerModal component > LeavingSiteDisclaimerModal continue correctly 1`] = ` | ||
<div> | ||
<div | ||
aria-hidden="true" | ||
aria-labelledby="leavingSiteDisclaimerLabel" | ||
class="modal fade" | ||
id="leavingSiteDisclaimerModal" | ||
style="z-index: 10000;" | ||
tabindex="-1" | ||
> | ||
<div | ||
class="modal-dialog modal-lg" | ||
> | ||
<div | ||
class="modal-content" | ||
> | ||
<div | ||
class="modal-header" | ||
> | ||
<h5 | ||
class="modal-title" | ||
id="leavingSiteDisclaimerLabel" | ||
> | ||
Text | ||
</h5> | ||
<button | ||
aria-label="Close" | ||
class="btn-close" | ||
data-bs-dismiss="modal" | ||
type="button" | ||
/> | ||
</div> | ||
<div | ||
class="modal-body text-start" | ||
> | ||
<p /> | ||
</div> | ||
<div | ||
class="modal-footer" | ||
> | ||
<button | ||
class="btn btn-primary" | ||
type="button" | ||
> | ||
Text | ||
</button> | ||
<button | ||
class="btn btn-secondary" | ||
data-bs-dismiss="modal" | ||
type="button" | ||
> | ||
Text | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`LeavingSiteDisclaimerModal component > LeavingSiteDisclaimerModal renders correctly 1`] = ` | ||
<div> | ||
<div | ||
aria-hidden="true" | ||
aria-labelledby="leavingSiteDisclaimerLabel" | ||
class="modal fade" | ||
id="leavingSiteDisclaimerModal" | ||
style="z-index: 10000;" | ||
tabindex="-1" | ||
> | ||
<div | ||
class="modal-dialog modal-lg" | ||
> | ||
<div | ||
class="modal-content" | ||
> | ||
<div | ||
class="modal-header" | ||
> | ||
<h5 | ||
class="modal-title" | ||
id="leavingSiteDisclaimerLabel" | ||
> | ||
Text | ||
</h5> | ||
<button | ||
aria-label="Close" | ||
class="btn-close" | ||
data-bs-dismiss="modal" | ||
type="button" | ||
/> | ||
</div> | ||
<div | ||
class="modal-body text-start" | ||
> | ||
<p /> | ||
</div> | ||
<div | ||
class="modal-footer" | ||
> | ||
<button | ||
class="btn btn-primary" | ||
type="button" | ||
> | ||
Text | ||
</button> | ||
<button | ||
class="btn btn-secondary" | ||
data-bs-dismiss="modal" | ||
type="button" | ||
> | ||
Text | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useState } from "react"; | ||
import { Trans } from 'gatsby-plugin-react-i18next'; | ||
|
||
const LeavingSiteDisclaimerModal = () => { | ||
|
||
const [message, setMessage] = useState(''); | ||
const [location, setLocation] = useState(''); | ||
|
||
if (typeof window !== `undefined`) { | ||
window.addEventListener('show.bs.modal', (event: Event) => { | ||
let button = event.relatedTarget; | ||
setMessage(button.getAttribute('data-bs-message')) | ||
setLocation(button.getAttribute('data-bs-location')) | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="modal fade" id="leavingSiteDisclaimerModal" tabIndex={-1} aria-labelledby="leavingSiteDisclaimerLabel" aria-hidden="true" style={{zIndex: '10000'}}> | ||
<div className="modal-dialog modal-lg"> | ||
<div className="modal-content"> | ||
<div className="modal-header"> | ||
<h5 className="modal-title" id="leavingSiteDisclaimerLabel"> | ||
<Trans i18nKey='leaving.site.disclaimer.modal.title' defaults='Disclaimer - You are going to leave our website' /> | ||
</h5> | ||
<button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div className="modal-body text-start"> | ||
<p> | ||
{message} | ||
</p> | ||
</div> | ||
<div className="modal-footer"> | ||
<button | ||
type="button" | ||
className="btn btn-primary" | ||
onClick={(event: React.MouseEvent<HTMLButtonElement>): void => { | ||
event.preventDefault(); | ||
window.location.assign(location); | ||
}} | ||
> | ||
<Trans i18nKey='leaving.site.disclaimer.modal.continue' defaults='Continue' /> | ||
</button> | ||
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal"> | ||
<Trans i18nKey='leaving.site.disclaimer.modal.close' defaults='Close' /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default LeavingSiteDisclaimerModal; |