test: add deterministic resilience matrix
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user