Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TECH] Migration des test e2e Pix Orga en Playwright #11836

Merged
merged 6 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion high-level-tests/e2e-playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ Vous devez avoir démarré les conteneurs Docker Pix au préalable: `docker comp
npm run test
```

## Exécuter en mode UI\*
## Exécuter en mode UI

```bash
npm run test:ui
```

## Lancer l'enregistreur d'action

Pour faciliter l'écriture des test, playwright propose un utilitaire pour logger les actions utilisateur et générer un scénario.

```bash
npx playwright codegen
```
38 changes: 38 additions & 0 deletions high-level-tests/e2e-playwright/pix-orga/migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- [x] Login

**Onboarding**

- [x] Invitation et Signup (rejoindre une organisation)
- [x] Invitation et Signin (authentifié ou non)
- [ ] Logout

**student-sco**

- [ ] Accès d'un admin vs accès d'une membre
- [ ] Je veux changer le mot de passe d'un élève
- [ ] Je veux créer un identifiant pour un élève ayant la méthode de connexion Mediacentre

**student-sup**

- [ ] Accès d'un admin vs accès d'une membre
- [ ] J'affiche la liste des élèves

**campaign-evaluation**

- [ ] Création d'une campagne d'évaluation
- [ ] Je consulte le détail d'une campagne d'évaluation

**campaign-profile**

- [ ] Création d'une campagne de profil
- [ ] Je consulte le détail d'une campagne de profil

**campaign-management**

- [ ] Duplication
- [ ] Archivage / désarchivage
- [ ] Modification

**member-management**

- [ ] J'envoie une invitation à rejoindre Pix Orga
74 changes: 74 additions & 0 deletions high-level-tests/e2e-playwright/pix-orga/onboarding.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { expect } from '@playwright/test';

import { useLoggedUser } from '../helpers/auth.ts';
import { databaseBuilder } from '../helpers/db.ts';
import { test } from '../helpers/fixtures.ts';

test('A new user joins a new organization from an invitation link', async function ({ page }) {
const invitation = databaseBuilder.factory.buildOrganizationInvitation();
await databaseBuilder.commit();

await page.goto(`/rejoindre?invitationId=${invitation.id}&code=${invitation.code}`);
await expect(page.getByText('Vous êtes invité(e) à')).toBeVisible();

test.step('signup user', async () => {
await page.getByRole('textbox', { name: 'Prénom' }).fill('mini');
await page.getByRole('textbox', { name: 'Nom', exact: true }).fill('pixou');
await page.getByRole('textbox', { name: 'Adresse e-mail' }).fill('minipixou@example.net');
await page.getByRole('textbox', { name: 'Mot de passe' }).fill('Azerty123*');
await page.getByRole('checkbox', { name: "Accepter les conditions d'utilisation de Pix" }).check();
await page.getByRole('button', { name: "Je m'inscris" }).click();
});

await page.getByRole('heading', { name: "Veuillez accepter nos Conditions Générales d'Utilisation" }).waitFor();
await page.getByRole('button', { name: 'Accepter et continuer' }).click();

await expect(page.getByRole('heading', { name: 'Campagnes' })).toBeVisible();
});

test('An existing user joins a new organization from an invitation link', async function ({ page }) {
const invitation = databaseBuilder.factory.buildOrganizationInvitation();
const user = databaseBuilder.factory.buildUser.withRawPassword();
await databaseBuilder.commit();

await page.goto(`/rejoindre?invitationId=${invitation.id}&code=${invitation.code}`);
await expect(page.getByText('Vous êtes invité(e) à')).toBeVisible();

test.step('signin user', async () => {
await page.getByRole('button', { name: 'Se connecter' }).click();
await page.getByRole('textbox', { name: 'Adresse e-mail' }).fill(user.email);
await page.getByRole('textbox', { name: 'Mot de passe' }).fill('pix123');
await page.getByRole('button', { name: 'Je me connecte' }).click();
});

await page.getByRole('heading', { name: "Veuillez accepter nos Conditions Générales d'Utilisation" }).waitFor();
await page.getByRole('button', { name: 'Accepter et continuer' }).click();

await expect(page.getByRole('heading', { name: 'Campagnes' })).toBeVisible();
});

test.describe('When user is already authenticated to Pix Orga', () => {
const userId = useLoggedUser('pix-orga');

test('Joins a new organization from an invitation link', async function ({ page }) {
const invitation = databaseBuilder.factory.buildOrganizationInvitation();
const user = databaseBuilder.factory.buildUser.withMembership({ id: userId });
await databaseBuilder.commit();

await page.goto(`/rejoindre?invitationId=${invitation.id}&code=${invitation.code}`);
await expect(page.getByText('Vous êtes invité(e) à')).toBeVisible();

test.step('signin user', async () => {
await page.getByRole('button', { name: 'Se connecter' }).click();
await page.getByRole('textbox', { name: 'Adresse e-mail' }).fill(user.email);
await page.getByRole('textbox', { name: 'Mot de passe' }).fill('pix123');
await page.getByRole('button', { name: 'Je me connecte' }).click();
});

await page.getByRole('heading', { name: "Veuillez accepter nos Conditions Générales d'Utilisation" }).waitFor();
await page.getByRole('button', { name: 'Accepter et continuer' }).click();

await expect(page.getByRole('heading', { name: 'Campagnes' })).toBeVisible();
await expect(page.getByRole('paragraph').filter({ hasText: 'Observatoire de Pix' })).toBeVisible();
});
});
1 change: 1 addition & 0 deletions high-level-tests/e2e-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default defineConfig({
START_JOB_IN_WEB_PROCESS: 'false',
PIX_AUDIT_LOGGER_ENABLED: 'false',
MAILING_ENABLED: 'false',
FT_PIXAPP_NEW_LAYOUT_ENABLED: 'false',
},
},
{
Expand Down