Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/issue-6567-hoist-internalformroute-import.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
---
---

Test-only: in `apps/console/src/components/FormPage.predicateScope.test.tsx`, hoist
`InternalFormRoute`'s import from a dynamic `await import()` inside the
`hop1SessionPrincipal` case to module scope. That load was costing 10204ms of the
case's 15000ms budget — it is the file's first value request for
`@object-ui/app-shell`, aliased to source — which made the file's one anti-inert
case fail under full-project parallel load. Same module, same binding, loaded
before the timed window instead of inside it. No published behaviour changes.
30 changes: 29 additions & 1 deletion apps/console/src/components/FormPage.predicateScope.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,31 @@ import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { PredicateScopeProvider } from '@object-ui/react';
import { FormPage } from './FormPage';

/**
* `InternalFormRoute` is imported HERE, at module scope, and deliberately NOT
* with a dynamic `await import()` inside `hop1SessionPrincipal` below —
* AGENTS.md §测试纪律, "an unbounded module load counted inside a bounded
* window".
*
* This module's graph is the first VALUE request for `@object-ui/app-shell` in
* the file (`FormPage` only `import type`s it), so it is what runs the
* `vi.mock('@object-ui/app-shell')` factory's `importOriginal()` below — and
* that specifier is aliased to `packages/app-shell/src`
* (`apps/console/vite.config.ts`), a barrel carrying eight side-effect imports,
* transformed on demand. Measured on an IDLE machine it cost **10204ms** of
* `hop1SessionPrincipal`'s 15000ms budget; the render and the assertions cost
* ~12ms, the same as the seven cases above. Nothing was wrong with the test —
* it was racing the module loader, and lost whenever the transform pipeline was
* saturated by a full-project run.
*
* Module scope moves that cost into the IMPORT phase, which no test or hook
* timeout bounds. `beforeAll` would not do: it is bounded by `hookTimeout`
* (10s), narrower than the 15s it replaces. The specifier is unchanged, so this
* is the same module and the same binding as the `await import()` was — only
* loaded before the timed window instead of inside it.
*/
import { InternalFormRoute } from './InternalFormRoute';

vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));

/**
Expand DownExpand Up@@ -312,6 +337,10 @@ describe('#6110 controls — green before AND after the fix, by construction', (
* REAL, because they are the thing under test. `DefaultHomeLayout` is a
* pass-through: the chrome is #4109's subject, not this card's, and stubbing it
* cannot hide the provider, which the route mounts itself.
*
* These still apply to the module-scope `InternalFormRoute` import above:
* `vi.mock` calls are hoisted above every import in the file, so the factories
* are registered before that import executes.
*/
vi.mock('@object-ui/app-shell', async (importOriginal) => {
const actual = await importOriginal<Record<string, unknown>>();
Expand DownExpand Up@@ -341,7 +370,6 @@ describe('#6110 hop 1 — `/forms/:name` publishes the SESSION principal', () =>
// `/apps/:appName/*` subtree) and in app-shell's `RecordFormPage`, and
// NEITHER is above `/forms/:name`. Binding the evaluator call sites without
// this hop would have shipped a fix that reads `{}` forever.
const { InternalFormRoute } = await import('./InternalFormRoute');
vi.stubGlobal(
'fetch',
stubFetch([
Expand Down
Loading