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:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user