Files
novalon-website/e2e/cases-filter.spec.ts
T
zhangxiang 3e93317988 fix(e2e): resolve admin user journey authentication and stabilize flaky tests
- Fix loginAdminAndSetCookie to set both cookie (middleware) and localStorage (auth-context)
- Add page navigation before localStorage evaluate to avoid SecurityError
- Update Playwright webServer to npm run dev for API route support
- Fix UJ-10 CSS selector parsing error (text= regex mixed with CSS)
- Fix cases-filter flaky test (getByRole('radio') → locator('button[role="radio"]'))
- Update test-strategy-plan.md: mark UJ-03/06/07 as  completed
- Update README.md with admin fix progress record
2026-08-03 08:36:50 +08:00

26 lines
1.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('案例页行业筛选按钮可以正确过滤列表', { tag: '@regression' }, async ({ page }) => {
await page.goto('/cases', { waitUntil: 'domcontentloaded' });
// 默认显示全部 6 个案例
await expect(page.locator('a[href^="/cases/"]')).toHaveCount(6);
// 点击"制造业"筛选
await page.locator('button[role="radio"]:has-text("制造业")').click();
await page.waitForTimeout(500);
await expect(page.locator('a[href^="/cases/"]')).toHaveCount(1);
await expect(page.locator('text=大型制造企业 ERP 升级与数字化转型')).toBeVisible();
// 点击"贸易零售"筛选
await page.locator('button[role="radio"]:has-text("贸易零售")').click();
await page.waitForTimeout(500);
await expect(page.locator('a[href^="/cases/"]')).toHaveCount(1);
await expect(page.locator('text=连锁零售全渠道数字化升级')).toBeVisible();
// 切回全部
await page.locator('button[role="radio"]:has-text("全部行业")').click();
await page.waitForTimeout(500);
await expect(page.locator('a[href^="/cases/"]')).toHaveCount(6);
});