s2-s7-rebuild-uat.spec.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { test, expect } from './fixtures/auth';
  2. import path from 'node:path';
  3. import { fileURLToPath } from 'node:url';
  4. const __dirname = path.dirname(fileURLToPath(import.meta.url));
  5. const SHOT = path.resolve(
  6. __dirname,
  7. '../../../doc/plan/UAT留证/2026-08-15-S2-S7看板刷新重算统一架构/screenshots',
  8. );
  9. const modules = [
  10. { code: 'S1', path: '/#/aidop/smart-ops/s1', rebuild: true },
  11. { code: 'S2', path: '/#/aidop/smart-ops/s2', rebuild: true },
  12. { code: 'S3', path: '/#/aidop/smart-ops/s3', rebuild: true },
  13. { code: 'S4', path: '/#/aidop/smart-ops/s4', rebuild: true },
  14. { code: 'S5', path: '/#/aidop/smart-ops/s5', rebuild: true },
  15. { code: 'S6', path: '/#/aidop/smart-ops/s6', rebuild: true },
  16. { code: 'S7', path: '/#/aidop/smart-ops/s7', rebuild: true },
  17. { code: 'S9', path: '/#/aidop/smart-ops/s9', rebuild: false },
  18. ];
  19. test('S1-S7 have rebuild; S9 does not; capture dashboards', async ({ authedPage }) => {
  20. test.setTimeout(180_000);
  21. for (const m of modules) {
  22. await authedPage.goto(m.path, { waitUntil: 'domcontentloaded' });
  23. await authedPage.waitForLoadState('networkidle', { timeout: 30_000 }).catch(() => {});
  24. await authedPage.waitForTimeout(1500);
  25. const refresh = authedPage.getByRole('button', { name: '刷新' });
  26. await expect(refresh).toBeVisible({ timeout: 20_000 });
  27. const rebuild = authedPage.getByRole('button', { name: '重算数据' });
  28. if (m.rebuild) await expect(rebuild).toBeVisible();
  29. else await expect(rebuild).toHaveCount(0);
  30. await authedPage.screenshot({
  31. path: path.join(SHOT, `${m.code}-dashboard.png`),
  32. fullPage: true,
  33. });
  34. }
  35. });
  36. test('S2 refresh stays lightweight and S9 refresh creates no rebuild card', async ({ authedPage }) => {
  37. test.setTimeout(90_000);
  38. await authedPage.goto('/#/aidop/smart-ops/s2', { waitUntil: 'domcontentloaded' });
  39. await authedPage.waitForLoadState('networkidle', { timeout: 30_000 }).catch(() => {});
  40. const refreshReq = authedPage.waitForResponse(
  41. (r) => r.url().includes('target-snapshot/refresh') && r.request().method() === 'POST',
  42. { timeout: 20_000 },
  43. );
  44. await authedPage.getByRole('button', { name: '刷新' }).click();
  45. const res = await refreshReq;
  46. expect(res.status()).toBe(200);
  47. await authedPage.screenshot({ path: path.join(SHOT, 'S2-after-quick-refresh.png'), fullPage: true });
  48. await authedPage.goto('/#/aidop/smart-ops/s9', { waitUntil: 'domcontentloaded' });
  49. await authedPage.waitForLoadState('networkidle', { timeout: 30_000 }).catch(() => {});
  50. const s9Req = authedPage.waitForResponse(
  51. (r) => r.url().includes('s9/target-snapshot/refresh') && r.request().method() === 'POST',
  52. { timeout: 20_000 },
  53. );
  54. await authedPage.getByRole('button', { name: '刷新' }).click();
  55. expect((await s9Req).status()).toBe(200);
  56. await expect(authedPage.getByRole('button', { name: '重算数据' })).toHaveCount(0);
  57. await expect(authedPage.locator('.s1-rebuild-card')).toHaveCount(0);
  58. await authedPage.screenshot({ path: path.join(SHOT, 'S9-after-quick-refresh.png'), fullPage: true });
  59. });