Skip to content

Commit 6d16375

Browse files
test(mobile): run cached pull request link tests on TestClock
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4b086af commit 6d16375

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎apps/mobile/src/connection/environment-cache-store.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import * as Fiber from "effect/Fiber";
2424
import * as Logger from "effect/Logger";
2525
import * as Option from "effect/Option";
2626
import * as Schema from "effect/Schema";
27+
import * as TestClock from "effect/testing/TestClock";
2728

2829
import * as MobileDatabase from "../persistence/mobile-database";
2930
import { make } from "./environment-cache-store";
@@ -567,7 +568,7 @@ describe("mobile SQLite environment cache store", () => {
567568
}),
568569
);
569570

570-
it.live("returns cached threads before their pull request links, which load after", () =>
571+
it.effect("returns cached threads before their pull request links, which load after", () =>
571572
Effect.gen(function* () {
572573
const memory = makeDatabase();
573574
const store = yield* make().pipe(
@@ -592,12 +593,13 @@ describe("mobile SQLite environment cache store", () => {
592593

593594
const shell = Option.getOrThrow(yield* store.loadShell(ENVIRONMENT_ID));
594595
expect(shell.threads.map((thread) => thread.pullRequests)).toEqual([undefined, undefined]);
595-
const links = yield* shell.loadPullRequests!;
596-
expect([...links]).toEqual([[THREAD_ID, [link]]]);
596+
const links = yield* Effect.forkChild(shell.loadPullRequests!);
597+
yield* TestClock.adjust("1 millis");
598+
expect([...(yield* Fiber.join(links))]).toEqual([[THREAD_ID, [link]]]);
597599
}),
598600
);
599601

600-
it.live("keeps cached threads when their pull request links cannot be read", () => {
602+
it.effect("keeps cached threads when their pull request links cannot be read", () => {
601603
const messages: Array<unknown> = [];
602604
const logger = Logger.make(({ message }) => {
603605
messages.push(message);
@@ -633,7 +635,9 @@ describe("mobile SQLite environment cache store", () => {
633635

634636
const shell = Option.getOrThrow(yield* store.loadShell(ENVIRONMENT_ID));
635637
expect(shell.threads.map((thread) => thread.id)).toEqual([THREAD_ID, readable.id]);
636-
expect([...(yield* shell.loadPullRequests!)]).toEqual([[readable.id, [link]]]);
638+
const links = yield* Effect.forkChild(shell.loadPullRequests!);
639+
yield* TestClock.adjust("1 millis");
640+
expect([...(yield* Fiber.join(links))]).toEqual([[readable.id, [link]]]);
637641
expect(messages).toHaveLength(1);
638642
expect(memory.removed).toEqual([]);
639643
}).pipe(Effect.provide(Logger.layer([logger], { mergeWithExisting: false })));

0 commit comments

Comments
 (0)