7d56a903c8
Add waitForSidebar helper function with explicit sidebar visibility wait and networkidle state to ensure page is fully loaded before assertions. This addresses flaky E2E tests where elements were not consistently found due to timing issues during page transitions.
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
async function waitForSidebar(page: import('@playwright/test').Page) {
|
|
const sidebar = page.getByRole('navigation', { name: 'Navigation' });
|
|
await expect(sidebar).toBeVisible({ timeout: 15_000 });
|
|
await page.waitForLoadState('networkidle');
|
|
return sidebar;
|
|
}
|
|
|
|
test.describe('TNS CSI plugin smoke tests', () => {
|
|
test('sidebar contains TNS CSI entry', async ({ page }) => {
|
|
await page.goto('/');
|
|
const sidebar = await waitForSidebar(page);
|
|
await expect(sidebar.getByRole('button', { name: /tns.csi/i })).toBeVisible();
|
|
});
|
|
|
|
test('TNS CSI sidebar entry navigates to TNS CSI view', async ({ page }) => {
|
|
await page.goto('/');
|
|
const sidebar = await waitForSidebar(page);
|
|
|
|
const entry = sidebar.getByRole('button', { name: /tns.csi/i });
|
|
await expect(entry).toBeVisible();
|
|
await entry.click();
|
|
|
|
await page.waitForLoadState('networkidle');
|
|
await expect(page).toHaveURL(/tns-csi/);
|
|
await expect(page.getByRole('heading', { name: /tns.csi.*overview/i })).toBeVisible();
|
|
});
|
|
|
|
test('TNS CSI page renders content', async ({ page }) => {
|
|
await page.goto('/c/main/tns-csi');
|
|
await waitForSidebar(page);
|
|
|
|
await expect(page.getByRole('heading', { name: /tns.csi.*overview/i })).toBeVisible({
|
|
timeout: 15_000,
|
|
});
|
|
|
|
const hasTable = await page.locator('table').first().isVisible().catch(() => false);
|
|
const hasContent = await page.locator('[class*="Mui"]').first().isVisible().catch(() => false);
|
|
expect(hasTable || hasContent).toBe(true);
|
|
});
|
|
|
|
test('plugin settings page shows TNS CSI plugin entry', async ({ page }) => {
|
|
await page.goto('/settings/plugins');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
const pluginEntry = page.locator('text=/tns.csi/i').first();
|
|
await expect(pluginEntry).toBeVisible({ timeout: 30_000 });
|
|
});
|
|
});
|