ajout des champs date de naissance et gender sur l'inscription, modification de la permition de lancer le jeu concour par l'administrateur, envoie des mail a chaque lot remporter
This commit is contained in:
@@ -16,7 +16,7 @@ async function remplirEtSoumettre() {
|
||||
await userEvent.type(screen.getByLabelText(/^nom/i), 'Dupont')
|
||||
await userEvent.type(screen.getByLabelText(/prénom/i), 'Jean')
|
||||
await userEvent.type(screen.getByLabelText(/^mot de passe/i), 'MotDePasse123!')
|
||||
await userEvent.click(screen.getByRole('checkbox'))
|
||||
await userEvent.click(screen.getByRole('checkbox', { name: /conditions d'utilisation/i }))
|
||||
await userEvent.click(screen.getByRole('button', { name: /s'inscrire/i }))
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('Inscription', () => {
|
||||
const bouton = screen.getByRole('button', { name: /s'inscrire/i })
|
||||
expect(bouton).toBeDisabled()
|
||||
|
||||
await userEvent.click(screen.getByRole('checkbox'))
|
||||
await userEvent.click(screen.getByRole('checkbox', { name: /conditions d'utilisation/i }))
|
||||
expect(bouton).toBeEnabled()
|
||||
})
|
||||
|
||||
@@ -64,11 +64,64 @@ describe('Inscription', () => {
|
||||
firstname: 'Jean',
|
||||
lastname: 'Dupont',
|
||||
password: 'MotDePasse123!',
|
||||
birthdate: '',
|
||||
gender: '',
|
||||
marketingOptIn: false,
|
||||
})
|
||||
expect(await screen.findByRole('heading', { name: /vérifiez votre email/i })).toBeInTheDocument()
|
||||
expect(screen.getByText('jean@example.com')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it("transmet la date de naissance et le genre saisis", async () => {
|
||||
registerApi.mockResolvedValue({ message: 'ok' })
|
||||
|
||||
renderWithProviders(<Inscription />, { route: '/inscription' })
|
||||
|
||||
await userEvent.type(screen.getByLabelText(/adresse email/i), 'jean@example.com')
|
||||
await userEvent.type(screen.getByLabelText(/^nom/i), 'Dupont')
|
||||
await userEvent.type(screen.getByLabelText(/prénom/i), 'Jean')
|
||||
await userEvent.type(screen.getByLabelText(/date de naissance/i), '1990-05-14')
|
||||
await userEvent.selectOptions(screen.getByLabelText(/genre/i), 'Femme')
|
||||
await userEvent.type(screen.getByLabelText(/^mot de passe/i), 'MotDePasse123!')
|
||||
await userEvent.click(screen.getByRole('checkbox', { name: /conditions d'utilisation/i }))
|
||||
await userEvent.click(screen.getByRole('button', { name: /s'inscrire/i }))
|
||||
|
||||
expect(registerApi).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ birthdate: '1990-05-14', gender: 'Femme' })
|
||||
)
|
||||
})
|
||||
|
||||
it("transmet le consentement marketing quand il est coché", async () => {
|
||||
registerApi.mockResolvedValue({ message: 'ok' })
|
||||
|
||||
renderWithProviders(<Inscription />, { route: '/inscription' })
|
||||
|
||||
const marketing = screen.getByRole('checkbox', { name: /offres et actualités/i })
|
||||
expect(marketing).not.toBeChecked()
|
||||
|
||||
await userEvent.type(screen.getByLabelText(/adresse email/i), 'jean@example.com')
|
||||
await userEvent.type(screen.getByLabelText(/^nom/i), 'Dupont')
|
||||
await userEvent.type(screen.getByLabelText(/prénom/i), 'Jean')
|
||||
await userEvent.type(screen.getByLabelText(/^mot de passe/i), 'MotDePasse123!')
|
||||
await userEvent.click(marketing)
|
||||
await userEvent.click(screen.getByRole('checkbox', { name: /conditions d'utilisation/i }))
|
||||
await userEvent.click(screen.getByRole('button', { name: /s'inscrire/i }))
|
||||
|
||||
expect(registerApi).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ marketingOptIn: true })
|
||||
)
|
||||
})
|
||||
|
||||
it("n'exige pas le consentement marketing pour s'inscrire", async () => {
|
||||
renderWithProviders(<Inscription />, { route: '/inscription' })
|
||||
|
||||
const bouton = screen.getByRole('button', { name: /s'inscrire/i })
|
||||
await userEvent.click(screen.getByRole('checkbox', { name: /conditions d'utilisation/i }))
|
||||
|
||||
expect(screen.getByRole('checkbox', { name: /offres et actualités/i })).not.toBeChecked()
|
||||
expect(bouton).toBeEnabled()
|
||||
})
|
||||
|
||||
it("affiche l'erreur de l'API si l'inscription échoue", async () => {
|
||||
registerApi.mockRejectedValue(new Error('Cet email est déjà utilisé.'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user