Skip to content

Commit ec43fb7

Browse files
committed
test(webapp): keep the gallery's fixtures out of the demo barrel
The barrel re-exports React components, and this suite runs without a DOM.
1 parent f820ea1 commit ec43fb7

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

apps/webapp/app/routes/storybook.agent-ui/fixtures.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import {
44
watchExternalNotificationLine,
55
} from "@internal/dashboard-agent-contracts";
66
import { ErrorId } from "@trigger.dev/core/v3/isomorphic";
7+
import { readFileSync } from "node:fs";
78
import { describe, expect, it } from "vitest";
8-
import { DEMO_MARKER } from "~/components/dashboard-agent/demo";
9+
import { DEMO_MARKER } from "~/components/dashboard-agent/demo/ids";
910
import { planDiagnosisActions } from "~/components/dashboard-agent/diagnosis-actions";
1011
import { renderableActions } from "~/components/dashboard-agent/view-actions";
1112
import { reportTrust } from "~/presenters/v3/reports/report-layout";
@@ -152,3 +153,22 @@ describe("gallery report", () => {
152153
expect(trust?.badge).toBe("stale data");
153154
});
154155
});
156+
157+
/**
158+
* `demo/index.ts` re-exports `DemoChartCard` and `DemoIntentBubble`, so importing it here would
159+
* pull React components into a suite that runs without a DOM. `demo.test.ts` reaches past the
160+
* barrel for the same reason; these fixtures and their test do too.
161+
*
162+
* Structural: what a module drags in is not observable from inside it.
163+
*/
164+
describe("the gallery fixtures stay out of the demo barrel", () => {
165+
const BARREL = /from "~\/components\/dashboard-agent\/demo"/;
166+
167+
for (const file of ["fixtures.ts", "fixtures.test.ts"]) {
168+
it(`${file} reaches past it`, () => {
169+
const source = readFileSync(new URL(`./${file}`, import.meta.url), "utf8");
170+
expect(BARREL.test(source), `${file} imports the demo barrel`).toBe(false);
171+
expect(source).toContain('"~/components/dashboard-agent/demo/');
172+
});
173+
}
174+
});

apps/webapp/app/routes/storybook.agent-ui/fixtures.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
type ViewBlock,
99
type WatchResultBlock as WatchResultBlockPayload,
1010
} from "@internal/dashboard-agent-contracts";
11-
import { DEMO_WORLD, demoFixtures, demoId, demoRunsUri } from "~/components/dashboard-agent/demo";
11+
import * as demoFixtures from "~/components/dashboard-agent/demo/fixtures";
12+
import { DEMO_WORLD, demoId, demoRunsUri } from "~/components/dashboard-agent/demo/ids";
1213
import type { TurnActivity } from "~/components/dashboard-agent/DashboardAgentMessages";
1314
import { watchConfirmationBlockBody, watchOneShotBlockBody } from "~/presenters/v3/dashboardAgent";
1415
import {

0 commit comments

Comments
 (0)