fix(web): recover pre-render boot failures
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import appV2Source from './AppV2.tsx?raw';
|
||||
import indexSource from '../../index.html?raw';
|
||||
import mainSource from '../main.tsx?raw';
|
||||
|
||||
const v2Styles = readFileSync(resolve(process.cwd(), 'src/v2/styles/v2.css'), 'utf8');
|
||||
@@ -11,6 +13,16 @@ describe('V2 production entry', () => {
|
||||
expect(mainSource).toContain("./v2/styles/v2.css");
|
||||
});
|
||||
|
||||
test('renders a static boot shell and recovers when the React entry never becomes ready', () => {
|
||||
expect(indexSource).toContain('id="platform-boot"');
|
||||
expect(indexSource).toContain("window.addEventListener('error', fail, true)");
|
||||
expect(indexSource).toContain("window.addEventListener('unhandledrejection', fail)");
|
||||
expect(indexSource).toContain('window.setTimeout(fail, 10_000)');
|
||||
expect(indexSource).toContain("target.searchParams.set('__reload', String(Date.now()))");
|
||||
expect(appV2Source).toContain("export const PLATFORM_READY_EVENT = 'vehicle-platform:ready'");
|
||||
expect(appV2Source).toContain('window.dispatchEvent(new Event(PLATFORM_READY_EVENT))');
|
||||
});
|
||||
|
||||
test('applies rendering containment to off-screen vehicle items instead of the visible scroller', () => {
|
||||
const ruleBody = (selector: string) => {
|
||||
const start = v2Styles.indexOf(`${selector} {`);
|
||||
|
||||
Reference in New Issue
Block a user