skillhub/web/e2e/dashboard-routes.spec.ts
XiaoSeS 944525aef4 test(review): align real E2E with unified review center
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-11-05 20:08:39 +08:00

52 lines
2.3 KiB
TypeScript

import { expect, test, type Page } from '@playwright/test'
import { setEnglishLocale } from './helpers/auth-fixtures'
import { registerSession } from './helpers/session'
async function expectRouteOpenOrRedirected(page: Page, route: string, heading: string) {
await page.goto(route)
if (page.url().includes(route)) {
await expect(page.getByRole('heading', { name: heading }).first()).toBeVisible()
return
}
await expect.poll(() => page.url()).not.toContain(route)
}
test.describe('Dashboard Routes (Real API)', () => {
test.beforeEach(async ({ page }, testInfo) => {
await setEnglishLocale(page)
await registerSession(page, testInfo)
})
test('opens major dashboard pages', async ({ page }) => {
await page.goto('/dashboard/skills')
await expect(page.getByRole('heading', { name: 'My Skills' })).toBeVisible()
await page.goto('/dashboard/publish')
await expect(page.getByRole('heading', { name: 'Publish Skill' })).toBeVisible()
await page.goto('/dashboard/namespaces')
await expect(page.getByRole('heading', { name: 'My Namespaces' })).toBeVisible()
await page.goto('/dashboard/stars')
await expect(page.getByRole('heading', { name: 'My Stars' })).toBeVisible()
await page.goto('/dashboard/notifications')
await expect(page.getByRole('heading', { name: 'Notifications' })).toBeVisible()
})
test('opens governance and namespace management pages', async ({ page }) => {
await expectRouteOpenOrRedirected(page, '/dashboard/governance', 'Governance Center')
await page.goto('/dashboard/namespaces/e2e-missing-namespace/members')
await expect(page.getByRole('heading', { name: 'Namespace not found' })).toBeVisible()
await page.goto('/dashboard/namespaces/e2e-missing-namespace/reviews')
await expect(page).toHaveURL((url) => url.pathname === '/dashboard/reviews' && url.searchParams.get('namespace') === 'e2e-missing-namespace')
await expect(page.getByRole('heading', { name: 'Review center', exact: true })).toBeVisible()
await expect(page.getByRole('alert')).toContainText(/This account does not have review permission\.|Unable to load the review scope\. Try again\./)
await expect(page.getByRole('table')).toHaveCount(0)
await expect(page.getByRole('button', { name: 'View', exact: true })).toHaveCount(0)
})
})