diff --git a/frontend/tests/e2e/sharing/project-sharing.spec.ts b/frontend/tests/e2e/sharing/project-sharing.spec.ts index 19b62e65b..7fc345108 100644 --- a/frontend/tests/e2e/sharing/project-sharing.spec.ts +++ b/frontend/tests/e2e/sharing/project-sharing.spec.ts @@ -18,14 +18,25 @@ for (const kind of ['user', 'team'] as const) { await section.getByRole('combobox', {name: `Search for a ${kind} to share this project with`}).pressSequentially(name, {delay: 10}) await expect(section.locator('.search-results').getByRole('option').first()).toContainText(name) await section.locator('.search-results').getByRole('option').first().click() - await section.getByRole('button', {name: 'Share', exact: true}).click() + const share = section.getByRole('button', {name: 'Share', exact: true}) + await share.focus() + await share.press('Enter') const row = section.getByRole('row').filter({hasText: name}) await expect(row).toBeVisible() + await expect(share).toBeFocused() + if (kind === 'team') { + await expect(row.getByRole('link', {name})).toHaveAttribute('href', `/teams/${team.id}/edit`) + } await row.getByRole('combobox').selectOption('1') await expect(row.locator('td.type')).toHaveText('Read & write') await page.reload() await expect(row.locator('td.type')).toHaveText('Read & write') await row.getByRole('button', {name: `Remove this ${kind}`}).click() + const removeDialog = page.getByRole('dialog', {name: `Remove a ${kind} from the List`}) + await removeDialog.getByRole('button', {name: 'Cancel', exact: true}).click() + await expect(removeDialog).toHaveCount(0) + await expect(row).toBeVisible() + await row.getByRole('button', {name: `Remove this ${kind}`}).click() await page.locator('dialog[open]').getByRole('button', {name: 'Do it!'}).click() await expect(row).toHaveCount(0) await page.reload() @@ -59,7 +70,7 @@ test('read-only members cannot manage shares', async ({page, apiContext}) => { await login(page, apiContext, reader) await page.goto('/projects/1/settings/share') const section = page.getByRole('heading', {name: 'Shared with these users', exact: true}).locator('..') - await expect(section.getByRole('row').filter({hasText: reader.username})).toBeVisible() + await expect(section.getByRole('row').filter({hasText: reader.username}).getByText('You', {exact: true})).toBeVisible() await expect(section.getByRole('combobox', {name: 'Search for a user to share this project with'})).toHaveCount(0) await expect(section.getByRole('button', {name: 'Share', exact: true})).toHaveCount(0) await expect(section.getByRole('button', {name: 'Remove this user'})).toHaveCount(0)