Files
hertzbeat/web-next/scripts/release-shell-smoke.test.ts
T
Logic 2de48d2caa feat: complete HertzBeat 2.0 novice workflows
Refine entity, monitor, alert, settings, observability, and shared operator workflows; add scale guards, route compatibility, release validation, and Product Design coverage.

AI assistance: used for draft implementation and test iteration.\nHuman validation: Node 22 production build; 426 frontend files and 3,398 tests; 59-route matrix; release budget 7.84 MiB / 8.00 MiB; focused backend tests and Browser QA.\nRisk notes: local scale proof covers 2,005 entities; sustained concurrent-ingestion SLA remains deployment-specific.
2026-07-10 14:54:43 +08:00

64 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import {
buildExpectedQueryEntries,
findMismatchedQueryEntries,
resolveNextRedirectDigestUrl
} from './release-shell-smoke.mjs';
describe('release-shell smoke helpers', () => {
it('normalizes expected query entries into string pairs', () => {
expect(buildExpectedQueryEntries({ redirect: '/monitors?app=website', source: 'guard', empty: null })).toEqual([
['redirect', '/monitors?app=website'],
['source', 'guard']
]);
});
it('finds only query entries that do not match the resolved final URL', () => {
const actualUrl = new URL(
'http://127.0.0.1:1157/passport/login?redirect=%2Fmonitors%3Fapp%3Dwebsite&source=guard'
);
expect(findMismatchedQueryEntries(actualUrl, { redirect: '/monitors?app=website', source: 'guard' })).toEqual([]);
expect(findMismatchedQueryEntries(actualUrl, { redirect: '/overview', source: 'guard' })).toEqual([
['redirect', '/overview']
]);
});
it('extracts next redirect digests into canonical urls for dev-mode smoke checks', () => {
expect(
resolveNextRedirectDigestUrl(
'<script>self.__next_f.push([1,"35:E{\\"digest\\":\\"NEXT_REDIRECT;replace;/log/manage?search=checkout+timeout\\\\u0026view=stream;307;\\"}"])</script>',
'http://127.0.0.1:4200'
)
).toBe('http://127.0.0.1:4200/log/manage?search=checkout+timeout&view=stream');
expect(resolveNextRedirectDigestUrl('<html><body>no redirect digest</body></html>', 'http://127.0.0.1:4200')).toBeNull();
});
it('keeps the release route browser smoke on the required route and console contracts', () => {
const source = readFileSync(resolve(process.cwd(), 'scripts/release-route-browser-smoke.spec.ts'), 'utf8');
[
'/overview',
'/entities',
'/entities/4200',
'/ingestion/otlp/metrics',
'/log/manage',
'/trace/manage',
'/topology',
'/alert',
'/ui-lab'
].forEach(route => {
expect(source).toContain(route);
});
expect(source).toContain('Maximum update depth exceeded');
expect(source).toContain('hydration failed');
expect(source).toContain('data-theme');
expect(source).toContain('dark-ops');
expect(source).toContain('expectReleaseRouteReady');
expect(source).toContain('Load failed');
expect(source).toContain("currentUrl.pathname).not.toBe('/passport/login')");
});
});