e2e: use exact name matching for sidebar link assertions

New plugin nav items like "Catalog Graph" cause Playwright's
substring-based getByRole name matching to find multiple elements
when searching for "Catalog". Switch to exact: true.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-25 22:53:03 +01:00
parent d156cf48bb
commit daaaa72ebb
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -25,7 +25,11 @@ test('App should render the welcome page', async ({ page }) => {
// Verify the sidebar navigation is visible after sign-in
await expect(
page.getByRole('navigation').getByRole('link', { name: 'Catalog' }),
page
.getByRole('navigation')
.getByRole('link', { name: 'Catalog', exact: true }),
).toBeVisible();
await expect(
page.getByRole('link', { name: 'APIs', exact: true }),
).toBeVisible();
await expect(page.getByRole('link', { name: 'APIs' })).toBeVisible();
});
@@ -24,6 +24,10 @@ test('App should render the welcome page', async ({ page }) => {
await enterButton.click();
const nav = page.getByRole('navigation');
await expect(nav.getByRole('link', { name: 'Catalog' })).toBeVisible();
await expect(page.getByRole('link', { name: 'APIs' })).toBeVisible();
await expect(
nav.getByRole('link', { name: 'Catalog', exact: true }),
).toBeVisible();
await expect(
page.getByRole('link', { name: 'APIs', exact: true }),
).toBeVisible();
});