History

test(web): stabilize timeline module setup

maria-rcks committed 3 months ago

Commit 39cd15b1 parent 160d97f1 file · +19 −28Browse files

Unified · Split

apps/web/src/components/chat/MessagesTimeline.test.tsx+19−28
@@ -130,7 +130,9 @@ function matchMedia() { · 129 unmodified lines
130130 };
131131 }
132132
133−beforeAll(() => {
133+let MessagesTimeline: typeof import("./MessagesTimeline").MessagesTimeline;
134+
135+beforeAll(async () => {
134136 const classList = {
135137 add: () => {},
136138 remove: () => {},
@@ -161,7 +163,9 @@ beforeAll(() => { · 24 unmodified lines
161163 offsetHeight: 0,
162164 },
163165 });
164−});
166+
167+ ({ MessagesTimeline } = await import("./MessagesTimeline"));
168+}, 30_000);
165169
166170 const ACTIVE_THREAD_ENVIRONMENT_ID = EnvironmentId.make("environment-local");
167171 const MESSAGE_CREATED_AT = "2026-03-17T19:12:28.000Z";
@@ -219,8 +223,7 @@ function buildUserTimelineEntry(text: string) { · 51 unmodified lines
219223 }
220224
221225 describe("MessagesTimeline", () => {
222− it("uses the larger leading inset only when the top fade is enabled", async () => {
223− const { MessagesTimeline } = await import("./MessagesTimeline");
226+ it("uses the larger leading inset only when the top fade is enabled", () => {
224227 const timelineEntries = [buildUserTimelineEntry("Hello")];
225228
226229 const compactMarkup = renderToStaticMarkup(
@@ -236,8 +239,7 @@ describe("MessagesTimeline", () => { · 9 unmodified lines
236239 expect(fadedMarkup).toContain("chat-timeline-scroll-fade");
237240 });
238241
239− it("keeps assistant changed-files headers sticky below the thread header", async () => {
240− const { MessagesTimeline } = await import("./MessagesTimeline");
242+ it("keeps assistant changed-files headers sticky below the thread header", () => {
241243 const assistantMessageId = MessageId.make("message-assistant-with-files");
242244 const turnId = TurnId.make("turn-with-files");
243245 const markup = renderToStaticMarkup(
@@ -349,8 +351,7 @@ describe("MessagesTimeline", () => { · 105 unmodified lines
349351 expect(resolveTimelineMinimapInteractiveWidth(40, true)).toBe("22rem");
350352 });
351353
352− it("anchors a sent attachment message using its measured height", async () => {
353− const { MessagesTimeline } = await import("./MessagesTimeline");
354+ it("anchors a sent attachment message using its measured height", () => {
354355 const onAnchorReady = vi.fn();
355356 const onAnchorSizeChanged = vi.fn();
356357 const firstEntry = buildUserTimelineEntry("First prompt.");
@@ -398,8 +399,7 @@ describe("MessagesTimeline", () => { · 41 unmodified lines
398399 expect(onAnchorSizeChanged).toHaveBeenCalledWith(secondEntry.message.id, 240);
399400 });
400401
401− it("renders collapse controls for long user messages", async () => {
402− const { MessagesTimeline } = await import("./MessagesTimeline");
402+ it("renders collapse controls for long user messages", () => {
403403 const markup = renderToStaticMarkup(
404404 <MessagesTimeline
405405 {...buildProps()}
@@ -418,8 +418,7 @@ describe("MessagesTimeline", () => { · 12 unmodified lines
418418 expect(markup).toContain('data-user-message-footer="true"');
419419 });
420420
421− it("does not render collapse controls for short user messages", async () => {
422− const { MessagesTimeline } = await import("./MessagesTimeline");
421+ it("does not render collapse controls for short user messages", () => {
423422 const markup = renderToStaticMarkup(
424423 <MessagesTimeline
425424 {...buildProps()}
@@ -431,8 +430,7 @@ describe("MessagesTimeline", () => { · 5 unmodified lines
431430 expect(markup).toContain('data-user-message-collapsible="false"');
432431 });
433432
434− it("renders inline terminal labels with the composer chip UI", async () => {
435− const { MessagesTimeline } = await import("./MessagesTimeline");
433+ it("renders inline terminal labels with the composer chip UI", () => {
436434 const markup = renderToStaticMarkup(
437435 <MessagesTimeline
438436 {...buildProps()}
@@ -459,8 +457,7 @@ describe("MessagesTimeline", () => { · 20 unmodified lines
459457 expect(markup).toContain("Show full message");
460458 }, 20_000);
461459
462− it("renders chips for standalone element-pick context messages", async () => {
463− const { MessagesTimeline } = await import("./MessagesTimeline");
460+ it("renders chips for standalone element-pick context messages", () => {
464461 const markup = renderToStaticMarkup(
465462 <MessagesTimeline
466463 {...buildProps()}
@@ -486,8 +483,7 @@ describe("MessagesTimeline", () => { · 19 unmodified lines
486483 expect(markup).not.toContain("<element_context");
487484 });
488485
489− it("keeps the copy button for collapsed long user messages", async () => {
490− const { MessagesTimeline } = await import("./MessagesTimeline");
486+ it("keeps the copy button for collapsed long user messages", () => {
491487 const markup = renderToStaticMarkup(
492488 <MessagesTimeline
493489 {...buildProps()}
@@ -500,8 +496,7 @@ describe("MessagesTimeline", () => { · 6 unmodified lines
500496 expect(markup).toContain('data-user-message-footer="true"');
501497 });
502498
503− it("renders context compaction entries in the normal work log", async () => {
504− const { MessagesTimeline } = await import("./MessagesTimeline");
499+ it("renders context compaction entries in the normal work log", () => {
505500 const markup = renderToStaticMarkup(
506501 <MessagesTimeline
507502 {...buildProps()}
@@ -525,8 +520,7 @@ describe("MessagesTimeline", () => { · 17 unmodified lines
525520 expect(markup).toContain("Work Log");
526521 });
527522
528− it("formats changed file paths from the workspace root", async () => {
529− const { MessagesTimeline } = await import("./MessagesTimeline");
523+ it("formats changed file paths from the workspace root", () => {
530524 const markup = renderToStaticMarkup(
531525 <MessagesTimeline
532526 {...buildProps()}
@@ -552,8 +546,7 @@ describe("MessagesTimeline", () => { · 19 unmodified lines
552546 expect(markup).not.toContain("C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts");
553547 });
554548
555− it("renders review comment contexts as structured cards instead of raw tags", async () => {
556− const { MessagesTimeline } = await import("./MessagesTimeline");
549+ it("renders review comment contexts as structured cards instead of raw tags", () => {
557550 const markup = renderToStaticMarkup(
558551 <MessagesTimeline
559552 {...buildProps()}
@@ -593,8 +586,7 @@ describe("MessagesTimeline", () => { · 33 unmodified lines
593586 expect(markup).not.toContain("&lt;/review_comment&gt;");
594587 });
595588
596− it("renders file review comments as source code instead of diffs", async () => {
597− const { MessagesTimeline } = await import("./MessagesTimeline");
589+ it("renders file review comments as source code instead of diffs", () => {
598590 const markup = renderToStaticMarkup(
599591 <MessagesTimeline
600592 {...buildProps()}
@@ -631,8 +623,7 @@ describe("MessagesTimeline", () => { · 30 unmodified lines
631623 expect(markup).not.toContain('data-testid="file-diff"');
632624 });
633625
634− it("renders a failure marker for failed tool lifecycle entries", async () => {
635− const { MessagesTimeline } = await import("./MessagesTimeline");
626+ it("renders a failure marker for failed tool lifecycle entries", () => {
636627 const markup = renderToStaticMarkup(
637628 <MessagesTimeline
638629 {...buildProps()}