fix(e2e): scope heading locators to main content area
Fix E2E test failures by scoping heading locators to the main content area instead of searching the entire page. This prevents matching headings in the sidebar or other non-content areas. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
+13
-9
@@ -13,7 +13,9 @@ test.describe('Polaris plugin smoke tests', () => {
|
|||||||
await page.goto('/c/main/polaris');
|
await page.goto('/c/main/polaris');
|
||||||
|
|
||||||
// SectionHeader renders a heading
|
// SectionHeader renders a heading
|
||||||
await expect(page.getByRole('heading', { name: 'Polaris \u2014 Overview' })).toBeVisible();
|
await expect(
|
||||||
|
page.locator('main').getByRole('heading', { name: 'Polaris \u2014 Overview' })
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
// "Cluster Score" section exists with a percentage
|
// "Cluster Score" section exists with a percentage
|
||||||
await expect(page.getByText('Cluster Score')).toBeVisible();
|
await expect(page.getByText('Cluster Score')).toBeVisible();
|
||||||
@@ -23,7 +25,9 @@ test.describe('Polaris plugin smoke tests', () => {
|
|||||||
test('namespaces page renders table with namespace buttons', async ({ page }) => {
|
test('namespaces page renders table with namespace buttons', async ({ page }) => {
|
||||||
await page.goto('/c/main/polaris/namespaces');
|
await page.goto('/c/main/polaris/namespaces');
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Polaris \u2014 Namespaces' })).toBeVisible();
|
await expect(
|
||||||
|
page.locator('main').getByRole('heading', { name: 'Polaris \u2014 Namespaces' })
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
// Table should have at least one row with a namespace button
|
// Table should have at least one row with a namespace button
|
||||||
const table = page.locator('table');
|
const table = page.locator('table');
|
||||||
@@ -48,14 +52,14 @@ test.describe('Polaris plugin smoke tests', () => {
|
|||||||
|
|
||||||
// Drawer should open and show the namespace name in the heading
|
// Drawer should open and show the namespace name in the heading
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
page.locator('main').getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
// "Namespace Score" section should be present in drawer
|
// "Namespace Score" section should be present in drawer
|
||||||
await expect(page.getByText('Namespace Score')).toBeVisible();
|
await expect(page.locator('main').getByText('Namespace Score')).toBeVisible();
|
||||||
|
|
||||||
// Resources table should exist in drawer
|
// Resources table should exist in drawer
|
||||||
await expect(page.getByRole('heading', { name: 'Resources' })).toBeVisible();
|
await expect(page.locator('main').getByRole('heading', { name: 'Resources' })).toBeVisible();
|
||||||
|
|
||||||
// URL hash should be updated with namespace name
|
// URL hash should be updated with namespace name
|
||||||
await expect(page).toHaveURL(/\/polaris\/namespaces#/);
|
await expect(page).toHaveURL(/\/polaris\/namespaces#/);
|
||||||
@@ -73,7 +77,7 @@ test.describe('Polaris plugin smoke tests', () => {
|
|||||||
|
|
||||||
// Verify drawer is open
|
// Verify drawer is open
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
page.locator('main').getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
// Press Escape key
|
// Press Escape key
|
||||||
@@ -81,7 +85,7 @@ test.describe('Polaris plugin smoke tests', () => {
|
|||||||
|
|
||||||
// Drawer should close (heading should not be visible anymore)
|
// Drawer should close (heading should not be visible anymore)
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
page.locator('main').getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
||||||
).not.toBeVisible();
|
).not.toBeVisible();
|
||||||
|
|
||||||
// URL hash should be cleared
|
// URL hash should be cleared
|
||||||
@@ -101,10 +105,10 @@ test.describe('Polaris plugin smoke tests', () => {
|
|||||||
|
|
||||||
// Drawer should automatically open with the namespace details
|
// Drawer should automatically open with the namespace details
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
page.locator('main').getByRole('heading', { name: `Polaris \u2014 ${namespaceName}` })
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
// "Namespace Score" section should be present
|
// "Namespace Score" section should be present
|
||||||
await expect(page.getByText('Namespace Score')).toBeVisible();
|
await expect(page.locator('main').getByText('Namespace Score')).toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user