Browse Source

playwright: fix stale org-nav selectors against bundled web vault

The product-switch links in the side nav ("Password Manager", "Admin
Console", "Members") are icon-only on the current bundled web vault —
the link element carries the accessible name but no visible text
content. `locator('a').filter({ hasText: '…' })` therefore matches
nothing, and every spec that calls into `setups/orgs.ts` (org create,
member invite, policy edit, …) times out before doing anything.

Switch to `getByRole('link', { name: '…' })` for the three navs.
"Admin Console" appears twice once an org exists (in both
`bit-nav-logo` and `navigation-product-switcher`); `.first()` picks the
visible one. The "Members" entry inside an org also moved from a
`<div>` to a `<link>`, so the `locator('div').filter(...).nth(2)`
selector is replaced with the same role-based selector. The
org-switcher row has a hover tooltip that intercepts the click on the
bundled vault, so the click is forced past the overlay.

Verified empirically: with these changes, `organization.spec.ts` (1/1)
and `sso_organization.spec.ts` (4/5; the remaining failure is an
unrelated server-side master-password-policy enforcement issue) run
green where they previously failed before any helper step.
pull/7248/head
Zaid Marji 3 weeks ago
parent
commit
9186ec245b
  1. 20
      playwright/tests/setups/orgs.ts

20
playwright/tests/setups/orgs.ts

@ -4,7 +4,11 @@ import * as utils from '../../global-utils';
export async function create(test, page: Page, name: string) { export async function create(test, page: Page, name: string) {
await test.step('Create Org', async () => { await test.step('Create Org', async () => {
await page.locator('a').filter({ hasText: 'Password Manager' }).first().click(); // The product-switch nav links are icon-only (accessible name set on
// the link, no text content), so `filter({hasText})` no longer matches
// on the current bundled web vault — use the accessible-name role
// selector instead.
await page.getByRole('link', { name: 'Password Manager' }).click();
await expect(page.getByTitle('All vaults', { exact: true })).toBeVisible(); await expect(page.getByTitle('All vaults', { exact: true })).toBeVisible();
await page.getByRole('link', { name: 'New organisation' }).click(); await page.getByRole('link', { name: 'New organisation' }).click();
await page.getByLabel('Organisation name (required)').fill(name); await page.getByLabel('Organisation name (required)').fill(name);
@ -16,9 +20,11 @@ export async function create(test, page: Page, name: string) {
export async function policies(test, page: Page, name: string) { export async function policies(test, page: Page, name: string) {
await test.step(`Navigate to ${name} policies`, async () => { await test.step(`Navigate to ${name} policies`, async () => {
await page.locator('a').filter({ hasText: 'Admin Console' }).first().click(); await page.getByRole('link', { name: 'Admin Console' }).first().click();
await page.locator('org-switcher').getByLabel(/Toggle collapse/).click(); await page.locator('org-switcher').getByLabel(/Toggle collapse/).click();
await page.locator('org-switcher').getByRole('link', { name: `${name}` }).first().click(); // The org row in the switcher has a hover tooltip that intercepts the
// click on the current bundled web vault; force-click past it.
await page.locator('org-switcher').getByRole('link', { name: `${name}` }).first().click({ force: true });
await expect(page.getByRole('heading', { name: `${name} collections` })).toBeVisible(); await expect(page.getByRole('heading', { name: `${name} collections` })).toBeVisible();
await page.getByRole('button', { name: 'Toggle collapse Settings' }).click(); await page.getByRole('button', { name: 'Toggle collapse Settings' }).click();
await page.getByRole('link', { name: 'Policies' }).click(); await page.getByRole('link', { name: 'Policies' }).click();
@ -28,11 +34,13 @@ export async function policies(test, page: Page, name: string) {
export async function members(test, page: Page, name: string) { export async function members(test, page: Page, name: string) {
await test.step(`Navigate to ${name} members`, async () => { await test.step(`Navigate to ${name} members`, async () => {
await page.locator('a').filter({ hasText: 'Admin Console' }).first().click(); await page.getByRole('link', { name: 'Admin Console' }).first().click();
await page.locator('org-switcher').getByLabel(/Toggle collapse/).click(); await page.locator('org-switcher').getByLabel(/Toggle collapse/).click();
await page.locator('org-switcher').getByRole('link', { name: `${name}` }).first().click(); // The org row in the switcher has a hover tooltip that intercepts the
// click on the current bundled web vault; force-click past it.
await page.locator('org-switcher').getByRole('link', { name: `${name}` }).first().click({ force: true });
await expect(page.getByRole('heading', { name: `${name} collections` })).toBeVisible(); await expect(page.getByRole('heading', { name: `${name} collections` })).toBeVisible();
await page.locator('div').filter({ hasText: 'Members' }).nth(2).click(); await page.getByRole('link', { name: 'Members' }).click();
await expect(page.getByRole('heading', { name: 'Members' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Members' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'All' })).toBeVisible(); await expect(page.getByRole('cell', { name: 'All' })).toBeVisible();
}); });

Loading…
Cancel
Save