test: add deterministic resilience matrix

This commit is contained in:
2026-09-02 07:24:48 +03:00
parent 5abd1c19ae
commit 8089d061ec
21 changed files with 809 additions and 22 deletions

View File

@@ -2,6 +2,17 @@ import { createApp } from './app';
import { validateAndFreezeProductionInputSnapshot } from './content/production-input-snapshot';
import type { ProductionInputs } from './content/types';
declare const __PORTFOLIO_TEST_BUILD__: boolean;
const TEST_BUILD = typeof __PORTFOLIO_TEST_BUILD__ !== 'undefined' && __PORTFOLIO_TEST_BUILD__;
const requestsTestFault = TEST_BUILD
&& new URL(location.href).searchParams.has('__portfolio_fault')
&& new URL(location.href).searchParams.has('__portfolio_test_token');
if (requestsTestFault) {
const { installAuthorizedTestHooks } = await import('./testing/fault-hooks');
await installAuthorizedTestHooks();
}
export const readProductionInputsSnapshot = (source: Document): Readonly<ProductionInputs> => {
const snapshot = source.getElementById('portfolio-inputs');
if (
@@ -21,6 +32,8 @@ export const readProductionInputsSnapshot = (source: Document): Readonly<Product
};
const appRoot = document.getElementById('app');
if (appRoot !== null) {
const hydrationFault = TEST_BUILD
&& window.__PORTFOLIO_TEST_HOOKS__?.fault === 'F9-hydration-failure';
if (appRoot !== null && !hydrationFault) {
createApp(readProductionInputsSnapshot(document)).mount(appRoot);
}