Skip to content

Commit de5c453

Browse files
committed
simplify tests
1 parent 38e8538 commit de5c453

1 file changed

Lines changed: 7 additions & 100 deletions

File tree

‎tests/organizations/invitations.spec.ts‎

Lines changed: 7 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,147 +2,54 @@ import { test, expect } from '@playwright/test'
22
import { clickOutside } from '../helpers'
33

44
test.describe('Organization member invitations', () => {
5-
test('can view members page with invite button', async ({ page }) => {
6-
// Navigate to an organization's members page (admin view)
7-
await page.goto('/admin/organizations/6461fa1f4e1de2ee027048b7/members')
8-
9-
// Verify the page loaded correctly
10-
await expect(page.getByRole('heading', { name: 'Membres', level: 1 })).toBeVisible()
11-
12-
// Verify the invite button is visible
13-
await expect(page.getByRole('button', { name: 'Inviter un membre' })).toBeVisible()
14-
15-
await page.screenshot({ path: 'tests/screenshots/members-page.png', fullPage: true })
16-
})
17-
18-
test('can open invite member modal', async ({ page }) => {
19-
await page.goto('/admin/organizations/6461fa1f4e1de2ee027048b7/members')
20-
21-
// Click on the invite button
22-
await page.getByRole('button', { name: 'Inviter un membre' }).click()
23-
24-
// Verify the modal opened
25-
await expect(page.getByRole('heading', { name: 'Inviter un membre' })).toBeVisible()
26-
27-
await page.screenshot({ path: 'tests/screenshots/invite-modal.png', fullPage: true })
28-
29-
// Verify form fields are present
30-
await expect(page.getByText('Utilisateur', { exact: true })).toBeVisible()
31-
await expect(page.getByPlaceholder('Rechercher un utilisateur')).toBeVisible()
32-
await expect(page.getByText('Email', { exact: true })).toBeVisible()
33-
await expect(page.getByText('Rôle', { exact: true })).toBeVisible()
34-
await expect(page.getByText('Message (optionnel)', { exact: true })).toBeVisible()
35-
36-
// Verify buttons
37-
await expect(page.getByRole('button', { name: 'Annuler' })).toBeVisible()
38-
await expect(page.getByRole('button', { name: 'Envoyer l\'invitation' })).toBeVisible()
39-
})
40-
415
test('can invite member by email', async ({ page }) => {
42-
// Use unique email to avoid conflicts
43-
const uniqueEmail = `invite-${Date.now()}@example.com`
44-
456
await page.goto('/admin/organizations/6461fa1f4e1de2ee027048b7/members')
467

47-
// Open the invite modal
488
await page.getByRole('button', { name: 'Inviter un membre' }).click()
499
await expect(page.getByRole('heading', { name: 'Inviter un membre' })).toBeVisible()
5010

51-
// Fill in email
52-
const emailInput = page.locator('input[type="email"]')
53-
await emailInput.fill(uniqueEmail)
54-
55-
// Select role (native <select>)
56-
const roleSelect = page.locator('select')
57-
await roleSelect.selectOption('editor')
58-
59-
// Click outside to ensure Vue updates
11+
await page.locator('input[type="email"]').fill('normal@example.com')
12+
await page.locator('select').selectOption('editor')
6013
await clickOutside(page)
6114

62-
// Add optional message
63-
await page.locator('input').last().fill('Bienvenue dans notre organisation!')
64-
65-
await page.screenshot({ path: 'tests/screenshots/invite-form-filled.png', fullPage: true })
66-
67-
// Submit the invitation
6815
await page.getByRole('button', { name: 'Envoyer l\'invitation' }).click()
69-
70-
// Wait for modal to close
7116
await expect(page.getByRole('heading', { name: 'Inviter un membre' })).not.toBeVisible({ timeout: 10000 })
7217

73-
await page.screenshot({ path: 'tests/screenshots/invite-sent.png', fullPage: true })
74-
75-
// The invitation should now appear in the pending invitations section
76-
await expect(page.getByText(uniqueEmail)).toBeVisible()
18+
await expect(page.getByText('normal@example.com')).toBeVisible()
7719
})
7820

7921
test('can cancel a sent invitation', async ({ page }) => {
80-
// Use unique email to avoid conflicts with previous test runs
8122
const uniqueEmail = `cancel-${Date.now()}@example.com`
8223

8324
await page.goto('/admin/organizations/6461fa1f4e1de2ee027048b7/members')
8425

85-
// First, create an invitation to cancel
8626
await page.getByRole('button', { name: 'Inviter un membre' }).click()
8727
await expect(page.getByRole('heading', { name: 'Inviter un membre' })).toBeVisible()
8828

89-
// Wait for the roles to load and select to be available
90-
const roleSelect = page.locator('select')
91-
await expect(roleSelect).toBeVisible()
92-
93-
// Fill in email
9429
await page.locator('input[type="email"]').fill(uniqueEmail)
95-
96-
// Select role
97-
await roleSelect.selectOption('editor')
98-
99-
// Click outside to trigger blur/change events
30+
await page.locator('select').selectOption('editor')
10031
await clickOutside(page)
101-
await page.waitForTimeout(200)
10232

103-
// Submit
104-
const submitButton = page.getByRole('button', { name: 'Envoyer l\'invitation' })
105-
await expect(submitButton).toBeEnabled({ timeout: 5000 })
106-
await submitButton.click()
107-
108-
// Wait for modal to close
33+
await page.getByRole('button', { name: 'Envoyer l\'invitation' }).click()
10934
await expect(page.getByRole('heading', { name: 'Inviter un membre' })).not.toBeVisible({ timeout: 10000 })
11035

111-
// Wait for the invitation to appear
11236
await expect(page.getByText(uniqueEmail)).toBeVisible({ timeout: 10000 })
11337

114-
await page.screenshot({ path: 'tests/screenshots/invite-created.png', fullPage: true })
115-
116-
// Cancel the invitation - find the card containing this email and click its cancel button
11738
const invitationRow = page.locator('.relative').filter({ hasText: uniqueEmail })
11839
await invitationRow.getByRole('button', { name: 'Annuler l\'invitation' }).click()
11940

120-
// Wait for refresh
121-
await page.waitForTimeout(1000)
122-
await page.screenshot({ path: 'tests/screenshots/invite-cancelled.png', fullPage: true })
123-
124-
// Verify the invitation is gone
125-
await expect(page.getByText(uniqueEmail)).not.toBeVisible()
41+
await expect(page.getByText(uniqueEmail)).not.toBeVisible({ timeout: 10000 })
12642
})
12743

128-
test('user search works in invite modal', async ({ page }) => {
44+
test('can search and select a user in invite modal', async ({ page }) => {
12945
await page.goto('/admin/organizations/6461fa1f4e1de2ee027048b7/members')
13046

131-
// Open the invite modal
13247
await page.getByRole('button', { name: 'Inviter un membre' }).click()
13348
await expect(page.getByRole('heading', { name: 'Inviter un membre' })).toBeVisible()
13449

135-
// Click on the searchable select using its testid (button that wraps the input)
13650
await page.getByTestId('searchable-select-utilisateur').click()
137-
138-
// Fill the search input
13951
await page.getByPlaceholder('Rechercher un utilisateur').fill('Admin')
14052

141-
// Wait for search results to appear
142-
await page.waitForTimeout(1000)
143-
await page.screenshot({ path: 'tests/screenshots/invite-user-search.png', fullPage: true })
144-
145-
// Verify search results appear (option list)
14653
await expect(page.getByRole('option').first()).toBeVisible({ timeout: 5000 })
14754
})
14855
})

0 commit comments

Comments
 (0)