| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { test, expect } from './fixtures/auth';
- import path from 'node:path';
- import { fileURLToPath } from 'node:url';
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
- const SHOT = path.resolve(
- __dirname,
- '../../../doc/plan/UAT留证/2026-08-15-S2-S7看板刷新重算统一架构/screenshots',
- );
- const modules = [
- { code: 'S1', path: '/#/aidop/smart-ops/s1', rebuild: true },
- { code: 'S2', path: '/#/aidop/smart-ops/s2', rebuild: true },
- { code: 'S3', path: '/#/aidop/smart-ops/s3', rebuild: true },
- { code: 'S4', path: '/#/aidop/smart-ops/s4', rebuild: true },
- { code: 'S5', path: '/#/aidop/smart-ops/s5', rebuild: true },
- { code: 'S6', path: '/#/aidop/smart-ops/s6', rebuild: true },
- { code: 'S7', path: '/#/aidop/smart-ops/s7', rebuild: true },
- { code: 'S9', path: '/#/aidop/smart-ops/s9', rebuild: false },
- ];
- test('S1-S7 have rebuild; S9 does not; capture dashboards', async ({ authedPage }) => {
- test.setTimeout(180_000);
- for (const m of modules) {
- await authedPage.goto(m.path, { waitUntil: 'domcontentloaded' });
- await authedPage.waitForLoadState('networkidle', { timeout: 30_000 }).catch(() => {});
- await authedPage.waitForTimeout(1500);
- const refresh = authedPage.getByRole('button', { name: '刷新' });
- await expect(refresh).toBeVisible({ timeout: 20_000 });
- const rebuild = authedPage.getByRole('button', { name: '重算数据' });
- if (m.rebuild) await expect(rebuild).toBeVisible();
- else await expect(rebuild).toHaveCount(0);
- await authedPage.screenshot({
- path: path.join(SHOT, `${m.code}-dashboard.png`),
- fullPage: true,
- });
- }
- });
- test('S2 refresh stays lightweight and S9 refresh creates no rebuild card', async ({ authedPage }) => {
- test.setTimeout(90_000);
- await authedPage.goto('/#/aidop/smart-ops/s2', { waitUntil: 'domcontentloaded' });
- await authedPage.waitForLoadState('networkidle', { timeout: 30_000 }).catch(() => {});
- const refreshReq = authedPage.waitForResponse(
- (r) => r.url().includes('target-snapshot/refresh') && r.request().method() === 'POST',
- { timeout: 20_000 },
- );
- await authedPage.getByRole('button', { name: '刷新' }).click();
- const res = await refreshReq;
- expect(res.status()).toBe(200);
- await authedPage.screenshot({ path: path.join(SHOT, 'S2-after-quick-refresh.png'), fullPage: true });
- await authedPage.goto('/#/aidop/smart-ops/s9', { waitUntil: 'domcontentloaded' });
- await authedPage.waitForLoadState('networkidle', { timeout: 30_000 }).catch(() => {});
- const s9Req = authedPage.waitForResponse(
- (r) => r.url().includes('s9/target-snapshot/refresh') && r.request().method() === 'POST',
- { timeout: 20_000 },
- );
- await authedPage.getByRole('button', { name: '刷新' }).click();
- expect((await s9Req).status()).toBe(200);
- await expect(authedPage.getByRole('button', { name: '重算数据' })).toHaveCount(0);
- await expect(authedPage.locator('.s1-rebuild-card')).toHaveCount(0);
- await authedPage.screenshot({ path: path.join(SHOT, 'S9-after-quick-refresh.png'), fullPage: true });
- });
|