Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

VcsStatusBroadcaster.test.ts

603 lines22.4 KB

1import { SourceControlProviderKind } from "@t3tools/contracts";
2import { assert, it, describe } from "@effect/vitest";
3import * as NodeServices from "@effect/platform-node/NodeServices";
4import * as Deferred from "effect/Deferred";
5import * as DateTime from "effect/DateTime";
6import * as Duration from "effect/Duration";
7import * as Effect from "effect/Effect";
8import * as Fiber from "effect/Fiber";
9import * as Exit from "effect/Exit";
10import * as FileSystem from "effect/FileSystem";
11import * as Layer from "effect/Layer";
12import * as Option from "effect/Option";
13import * as Path from "effect/Path";
14import * as Scope from "effect/Scope";
15import * as Stream from "effect/Stream";
16import * as TestClock from "effect/testing/TestClock";
17import type {
18 BackgroundScope,
19 VcsStatusLocalResult,
20 VcsStatusRemoteResult,
21 VcsStatusResult,
22 VcsStatusStreamEvent,
23} from "@t3tools/contracts";
24import { GitManagerError } from "@t3tools/contracts";
25​
26import * as VcsStatusBroadcaster from "./VcsStatusBroadcaster.ts";
27import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
28import * as GitWorkflowService from "../git/GitWorkflowService.ts";
29import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
30​
31const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
32​
33const baseLocalStatus: VcsStatusLocalResult = {
34 isRepo: true,
35 sourceControlProvider: {
36 kind: SourceControlProviderKind.make("github"),
37 name: "GitHub",
38 baseUrl: "https://github.com",
39 },
40 hasPrimaryRemote: true,
41 isDefaultRef: false,
42 refName: "feature/status-broadcast",
43 hasWorkingTreeChanges: false,
44 workingTree: { files: [], insertions: 0, deletions: 0 },
45};
46​
47const baseRemoteStatus: VcsStatusRemoteResult = {
48 hasUpstream: true,
49 aheadCount: 0,
50 behindCount: 0,
51 pr: null,
52};
53​
54const remoteStatusWithPr: VcsStatusRemoteResult = {
55 ...baseRemoteStatus,
56 pr: {
57 number: 2978,
58 title: "[codex] Rewrite client connection architecture",
59 url: "https://github.com/pingdotgg/t3code/pull/2978",
60 baseRef: "main",
61 headRef: "codex/connection-state-audit",
62 state: "open",
63 },
64};
65​
66const baseStatus: VcsStatusResult = {
67 ...baseLocalStatus,
68 ...baseRemoteStatus,
69};
70​
71function layerTestFor(state: {
72 currentLocalStatus: VcsStatusLocalResult;
73 currentRemoteStatus: VcsStatusRemoteResult | null;
74 localStatusCalls: number;
75 remoteStatusCalls: number;
76 localInvalidationCalls: number;
77 remoteInvalidationCalls: number;
78 remoteStatusRefreshUpstreamValues?: Array<boolean | undefined>;
79 backgroundWorkEnabled?: boolean;
80 automaticFetchInterval?: Effect.Effect<Duration.Duration>;
81 beforeRemoteStatus?: Effect.Effect<void>;
82}) {
83 return VcsStatusBroadcaster.layer.pipe(
84 Layer.provideMerge(NodeServices.layer),
85 Layer.provide(layerBackgroundPolicy(() => state.backgroundWorkEnabled !== false)),
86 Layer.provide(
87 Layer.succeed(
88 VcsStatusBroadcaster.VcsAutomaticFetchInterval,
89 state.automaticFetchInterval ?? Effect.succeed(Duration.seconds(30)),
90 ),
91 ),
92 Layer.provide(
93 Layer.mock(GitWorkflowService.GitWorkflowService)({
94 localStatus: () =>
95 Effect.sync(() => {
96 state.localStatusCalls += 1;
97 return state.currentLocalStatus;
98 }),
99 remoteStatus: (_input, options) =>
100 Effect.suspend(() => state.beforeRemoteStatus ?? Effect.void).pipe(
101 Effect.andThen(
102 Effect.sync(() => {
103 state.remoteStatusCalls += 1;
104 state.remoteStatusRefreshUpstreamValues?.push(options?.refreshUpstream);
105 return state.currentRemoteStatus;
106 }),
107 ),
108 ),
109 invalidateLocalStatus: () =>
110 Effect.sync(() => {
111 state.localInvalidationCalls += 1;
112 }),
113 invalidateRemoteStatus: () =>
114 Effect.sync(() => {
115 state.remoteInvalidationCalls += 1;
116 }),
117 invalidateStatus: () =>
118 Effect.sync(() => {
119 state.localInvalidationCalls += 1;
120 state.remoteInvalidationCalls += 1;
121 }),
122 }),
123 ),
124 );
126​
127function layerBackgroundPolicy(shouldRunScopeWork: (scope: BackgroundScope) => boolean) {
128 return Layer.mock(BackgroundPolicy.BackgroundPolicy)({
129 reportClientActivity: () => Effect.void,
130 removeRpcClient: () => Effect.void,
131 reportHostPowerState: () => Effect.void,
132 snapshot: Effect.succeed({
133 hostPower: {
134 source: "unknown",
135 idle: "unknown",
136 idleSeconds: null,
137 locked: "unknown",
138 suspended: false,
139 onBattery: "unknown",
140 lowPowerMode: "unknown",
141 thermalState: "unknown",
142 stale: true,
143 updatedAt: TEST_EPOCH,
144 },
145 leases: [],
146 activeForegroundLeaseCount: 0,
147 activeScopeKeys: [],
148 shouldRunOpportunisticWork: false,
149 updatedAt: TEST_EPOCH,
150 }),
151 streamChanges: Stream.empty,
152 hasDemand: () => Effect.succeed(true),
153 shouldRunScopeWork: (scope) => Effect.sync(() => shouldRunScopeWork(scope)),
154 shouldRunOpportunisticWork: Effect.succeed(true),
155 });
157​
158describe("VcsStatusBroadcaster", () => {
159 it.effect.skipIf(!symlinksSupported)(
160 "automatically pulls an enabled clean default branch when status detects it is behind",
161 () => {
162 let remoteStatus: VcsStatusRemoteResult = { ...baseRemoteStatus, behindCount: 2 };
163 let pullCalls = 0;
164 let configuredWorkspaceRoot = "";
165 const localStatus: VcsStatusLocalResult = {
166 ...baseLocalStatus,
167 isDefaultRef: true,
168 refName: "main",
169 };
170 const layerTest = VcsStatusBroadcaster.layer.pipe(
171 Layer.provideMerge(NodeServices.layer),
172 Layer.provide(layerBackgroundPolicy(() => true)),
173 Layer.provide(
174 Layer.succeed(VcsStatusBroadcaster.VcsAutoPullPolicy, {
175 isEnabled: (cwd) => Effect.succeed(cwd === configuredWorkspaceRoot),
176 }),
177 ),
178 Layer.provide(
179 Layer.mock(GitWorkflowService.GitWorkflowService)({
180 localStatus: () => Effect.succeed(localStatus),
181 remoteStatus: () => Effect.succeed(remoteStatus),
182 invalidateLocalStatus: () => Effect.void,
183 invalidateRemoteStatus: () => Effect.void,
184 invalidateStatus: () => Effect.void,
185 pullCurrentBranch: () =>
186 Effect.sync(() => {
187 pullCalls += 1;
188 remoteStatus = { ...remoteStatus, behindCount: 0 };
189 return {
190 status: "pulled" as const,
191 refName: "main",
192 upstreamRef: "origin/main",
193 };
194 }),
195 }),
196 ),
197 );
198​
199 return Effect.gen(function* () {
200 const fileSystem = yield* FileSystem.FileSystem;
201 const path = yield* Path.Path;
202 const realDir = yield* fileSystem.makeTempDirectoryScoped({
203 prefix: "t3-vcs-auto-pull-real-",
204 });
205 const linkParent = yield* fileSystem.makeTempDirectoryScoped({
206 prefix: "t3-vcs-auto-pull-link-",
207 });
208 configuredWorkspaceRoot = path.join(linkParent, "repo-link");
209 yield* fileSystem.symlink(realDir, configuredWorkspaceRoot);
210​
211 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
212 const status = yield* broadcaster.refreshStatus(configuredWorkspaceRoot);
213​
214 assert.equal(pullCalls, 1);
215 assert.equal(status.behindCount, 0);
216 }).pipe(Effect.provide(layerTest));
217 },
218 );
219​
220 it.effect("refreshes a loaded cwd without reusing a previous branch's PR", () => {
221 const state = {
222 currentLocalStatus: baseLocalStatus,
223 currentRemoteStatus: baseRemoteStatus,
224 localStatusCalls: 0,
225 remoteStatusCalls: 0,
226 localInvalidationCalls: 0,
227 remoteInvalidationCalls: 0,
228 };
229​
230 return Effect.gen(function* () {
231 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
232​
233 assert.isNull(yield* broadcaster.refreshPullRequestStatus("/repo"));
234 assert.equal(state.remoteStatusCalls, 0);
235​
236 yield* broadcaster.getStatus({ cwd: "/repo" });
237 assert.equal(state.remoteStatusCalls, 1);
238​
239 state.currentRemoteStatus = remoteStatusWithPr;
240 const refreshed = yield* broadcaster.refreshPullRequestStatus("/repo");
241 assert.deepStrictEqual(refreshed, remoteStatusWithPr);
242 assert.equal(state.remoteStatusCalls, 2);
243 assert.equal(state.remoteInvalidationCalls, 0);
244​
245 state.currentLocalStatus = { ...baseLocalStatus, refName: "feature/next" };
246 state.currentRemoteStatus = baseRemoteStatus;
247 yield* broadcaster.refreshLocalStatus("/repo");
248 const refreshedBranch = yield* broadcaster.refreshPullRequestStatus("/repo");
249 assert.deepStrictEqual(refreshedBranch, baseRemoteStatus);
250 assert.equal(state.remoteStatusCalls, 3);
251 }).pipe(Effect.provide(layerTestFor(state)));
252 });
253​
254 it.effect("a poll that started before the turn-end refresh cannot overwrite its PR", () => {
255 const releaseFirstPoll = Deferred.makeUnsafe<void>();
256 const firstPollStarted = Deferred.makeUnsafe<void>();
257 let remoteReads = 0;
258 const layer = VcsStatusBroadcaster.layer.pipe(
259 Layer.provideMerge(NodeServices.layer),
260 Layer.provide(layerBackgroundPolicy(() => true)),
261 Layer.provide(
262 Layer.mock(GitWorkflowService.GitWorkflowService)({
263 localStatus: () => Effect.succeed(baseLocalStatus),
264 remoteStatus: () =>
265 Effect.gen(function* () {
266 remoteReads += 1;
267 if (remoteReads === 2) {
268 yield* Deferred.succeed(firstPollStarted, undefined);
269 yield* Deferred.await(releaseFirstPoll);
270 return baseRemoteStatus;
271 }
272 return remoteReads === 1 ? baseRemoteStatus : remoteStatusWithPr;
273 }),
274 invalidateLocalStatus: () => Effect.void,
275 invalidateRemoteStatus: () => Effect.void,
276 invalidateStatus: () => Effect.void,
277 }),
278 ),
279 );
280​
281 return Effect.gen(function* () {
282 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
283 yield* broadcaster.getStatus({ cwd: "/repo" });
284​
285 const poll = yield* broadcaster.refreshStatus("/repo").pipe(Effect.forkScoped);
286 yield* Deferred.await(firstPollStarted);
287 const refresh = yield* broadcaster.refreshPullRequestStatus("/repo").pipe(Effect.forkScoped);
288 yield* Deferred.succeed(releaseFirstPoll, undefined);
289 yield* Fiber.join(poll);
290 const refreshed = yield* Fiber.join(refresh);
291​
292 assert.deepStrictEqual(refreshed, remoteStatusWithPr);
293 const final = yield* broadcaster.getStatus({ cwd: "/repo" });
294 assert.deepStrictEqual(final.pr, remoteStatusWithPr.pr);
295 }).pipe(Effect.provide(layer), Effect.scoped);
296 });
297​
298 it.effect("an initial status read cannot overwrite an explicit refresh", () => {
299 const firstReadStarted = Deferred.makeUnsafe<void>();
300 const releaseFirstRead = Deferred.makeUnsafe<void>();
301 let remoteReads = 0;
302 const layer = VcsStatusBroadcaster.layer.pipe(
303 Layer.provide(FileSystem.layerNoop({ realPath: (path) => Effect.succeed(path) })),
304 Layer.provideMerge(NodeServices.layer),
305 Layer.provide(layerBackgroundPolicy(() => true)),
306 Layer.provide(
307 Layer.mock(GitWorkflowService.GitWorkflowService)({
308 localStatus: () => Effect.succeed(baseLocalStatus),
309 remoteStatus: () =>
310 Effect.gen(function* () {
311 remoteReads += 1;
312 if (remoteReads === 1) {
313 yield* Deferred.succeed(firstReadStarted, undefined);
314 yield* Deferred.await(releaseFirstRead);
315 return baseRemoteStatus;
316 }
317 return remoteStatusWithPr;
318 }),
319 invalidateStatus: () => Effect.void,
320 }),
321 ),
322 );
323 return Effect.gen(function* () {
324 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
325 const initial = yield* broadcaster.getStatus({ cwd: "/repo" }).pipe(Effect.forkScoped);
326 yield* Deferred.await(firstReadStarted);
327 const refresh = yield* broadcaster.refreshStatus("/repo").pipe(Effect.forkScoped);
328 yield* TestClock.adjust(Duration.zero);
329 yield* Deferred.succeed(releaseFirstRead, undefined);
330 yield* Fiber.join(initial);
331 yield* Fiber.join(refresh);
332 assert.deepStrictEqual(
333 (yield* broadcaster.getStatus({ cwd: "/repo" })).pr,
334 remoteStatusWithPr.pr,
335 );
336 }).pipe(Effect.provide(layer), Effect.scoped);
337 });
338​
339 it.effect("keeps the cached snapshot unchanged when a refresh branch fails", () => {
340 const state = {
341 currentLocalStatus: baseLocalStatus,
342 currentRemoteStatus: baseRemoteStatus,
343 localStatusCalls: 0,
344 remoteStatusCalls: 0,
345 localInvalidationCalls: 0,
346 remoteInvalidationCalls: 0,
347 failRemoteStatus: false,
348 };
349 const layerTest = VcsStatusBroadcaster.layer.pipe(
350 Layer.provideMerge(NodeServices.layer),
351 Layer.provide(layerBackgroundPolicy(() => true)),
352 Layer.provide(
353 Layer.mock(GitWorkflowService.GitWorkflowService)({
354 localStatus: () =>
355 Effect.sync(() => {
356 state.localStatusCalls += 1;
357 return state.currentLocalStatus;
358 }),
359 remoteStatus: () =>
360 Effect.suspend(() => {
361 state.remoteStatusCalls += 1;
362 return state.failRemoteStatus
363 ? Effect.fail(
364 new GitManagerError({
365 operation: "VcsStatusBroadcaster.test",
366 cwd: "/repo",
367 detail: "remote status failed",
368 }),
369 )
370 : Effect.succeed(state.currentRemoteStatus);
371 }),
372 invalidateLocalStatus: () =>
373 Effect.sync(() => {
374 state.localInvalidationCalls += 1;
375 }),
376 invalidateRemoteStatus: () =>
377 Effect.sync(() => {
378 state.remoteInvalidationCalls += 1;
379 }),
380 invalidateStatus: () =>
381 Effect.sync(() => {
382 state.localInvalidationCalls += 1;
383 state.remoteInvalidationCalls += 1;
384 }),
385 }),
386 ),
387 );
388​
389 return Effect.gen(function* () {
390 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
391 yield* broadcaster.getStatus({ cwd: "/repo" });
392​
393 state.currentLocalStatus = {
394 ...baseLocalStatus,
395 refName: "feature/partial-refresh",
396 };
397 state.currentRemoteStatus = {
398 ...baseRemoteStatus,
399 aheadCount: 3,
400 };
401 state.failRemoteStatus = true;
402​
403 const refreshExit = yield* broadcaster.refreshStatus("/repo").pipe(Effect.exit);
404 const cached = yield* broadcaster.getStatus({ cwd: "/repo" });
405​
406 assert.isTrue(Exit.isFailure(refreshExit));
407 assert.deepStrictEqual(cached, baseStatus);
408 }).pipe(Effect.provide(layerTest));
409 });
410​
411 it.effect.skipIf(!symlinksSupported)(
412 "normalizes symlinked CWDs before cache lookup and workflow calls",
413 () => {
414 const seenCwds: string[] = [];
415 const state = {
416 currentLocalStatus: baseLocalStatus,
417 currentRemoteStatus: baseRemoteStatus,
418 localStatusCalls: 0,
419 remoteStatusCalls: 0,
420 localInvalidationCalls: 0,
421 remoteInvalidationCalls: 0,
422 };
423 const layerTest = VcsStatusBroadcaster.layer.pipe(
424 Layer.provideMerge(NodeServices.layer),
425 Layer.provide(layerBackgroundPolicy(() => true)),
426 Layer.provide(
427 Layer.mock(GitWorkflowService.GitWorkflowService)({
428 localStatus: (input) =>
429 Effect.sync(() => {
430 seenCwds.push(input.cwd);
431 state.localStatusCalls += 1;
432 return state.currentLocalStatus;
433 }),
434 remoteStatus: (input) =>
435 Effect.sync(() => {
436 seenCwds.push(input.cwd);
437 state.remoteStatusCalls += 1;
438 return state.currentRemoteStatus;
439 }),
440 invalidateLocalStatus: () =>
441 Effect.sync(() => {
442 state.localInvalidationCalls += 1;
443 }),
444 invalidateRemoteStatus: () =>
445 Effect.sync(() => {
446 state.remoteInvalidationCalls += 1;
447 }),
448 } satisfies Partial<GitWorkflowService.GitWorkflowService["Service"]>),
449 ),
450 );
451​
452 return Effect.gen(function* () {
453 const fileSystem = yield* FileSystem.FileSystem;
454 const path = yield* Path.Path;
455 const realDir = yield* fileSystem.makeTempDirectoryScoped({
456 prefix: "t3-vcs-status-real-",
457 });
458 const linkParent = yield* fileSystem.makeTempDirectoryScoped({
459 prefix: "t3-vcs-status-link-",
460 });
461 const linkDir = path.join(linkParent, "repo-link");
462 yield* fileSystem.symlink(realDir, linkDir);
463 const realPath = yield* fileSystem.realPath(realDir);
464​
465 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
466 yield* broadcaster.getStatus({ cwd: linkDir });
467 yield* broadcaster.getStatus({ cwd: realDir });
468​
469 assert.deepStrictEqual(seenCwds, [realPath, realPath]);
470 assert.equal(state.localStatusCalls, 1);
471 assert.equal(state.remoteStatusCalls, 1);
472 }).pipe(Effect.provide(layerTest));
473 },
474 );
475​
476 it.effect("an explicit refresh reads local totals after the fetch", () => {
477 const state: Parameters<typeof layerTestFor>[0] = {
478 currentLocalStatus: baseLocalStatus,
479 currentRemoteStatus: baseRemoteStatus,
480 localStatusCalls: 0,
481 remoteStatusCalls: 0,
482 localInvalidationCalls: 0,
483 remoteInvalidationCalls: 0,
484 };
485​
486 return Effect.gen(function* () {
487 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
488 const fetchStarted = yield* Deferred.make<void>();
489 const finishFetch = yield* Deferred.make<void>();
490 state.beforeRemoteStatus = Deferred.succeed(fetchStarted, undefined).pipe(
491 Effect.andThen(Deferred.await(finishFetch)),
492 );
493 const refresh = yield* broadcaster.refreshStatus("/repo").pipe(Effect.forkScoped);
494 yield* Deferred.await(fetchStarted);
495​
496 const fetchedLocal: VcsStatusLocalResult = {
497 ...baseLocalStatus,
498 branchChanges: { baseRef: "origin/main", insertions: 0, deletions: 0 },
499 };
500 state.currentLocalStatus = fetchedLocal;
501 yield* Deferred.succeed(finishFetch, undefined);
502​
503 const status = yield* Fiber.join(refresh);
504 assert.deepStrictEqual(status.branchChanges, fetchedLocal.branchChanges);
505 }).pipe(Effect.provide(layerTestFor(state)));
506 });
507​
508 it.effect("releases remote demand while passive observers remain", () => {
509 const state = {
510 currentLocalStatus: baseLocalStatus,
511 currentRemoteStatus: baseRemoteStatus,
512 localStatusCalls: 0,
513 remoteStatusCalls: 0,
514 localInvalidationCalls: 0,
515 remoteInvalidationCalls: 0,
516 };
517 let remoteInterruptedDeferred: Deferred.Deferred<void, never> | null = null;
518 let remoteStartedDeferred: Deferred.Deferred<void, never> | null = null;
519 const layerTest = VcsStatusBroadcaster.layer.pipe(
520 Layer.provideMerge(NodeServices.layer),
521 Layer.provide(layerBackgroundPolicy(() => true)),
522 Layer.provide(
523 Layer.mock(GitWorkflowService.GitWorkflowService)({
524 localStatus: () =>
525 Effect.sync(() => {
526 state.localStatusCalls += 1;
527 return state.currentLocalStatus;
528 }),
529 remoteStatus: () =>
530 Effect.sync(() => {
531 state.remoteStatusCalls += 1;
532 }).pipe(
533 Effect.andThen(
534 remoteStartedDeferred
535 ? Deferred.succeed(remoteStartedDeferred, undefined).pipe(Effect.ignore)
536 : Effect.void,
537 ),
538 Effect.andThen(Effect.never as Effect.Effect<VcsStatusRemoteResult | null, never>),
539 Effect.onInterrupt(() =>
540 remoteInterruptedDeferred
541 ? Deferred.succeed(remoteInterruptedDeferred, undefined).pipe(Effect.ignore)
542 : Effect.void,
543 ),
544 ),
545 invalidateLocalStatus: () =>
546 Effect.sync(() => {
547 state.localInvalidationCalls += 1;
548 }),
549 invalidateRemoteStatus: () =>
550 Effect.sync(() => {
551 state.remoteInvalidationCalls += 1;
552 }),
553 } satisfies Partial<GitWorkflowService.GitWorkflowService["Service"]>),
554 ),
555 );
556​
557 return Effect.gen(function* () {
558 const remoteInterrupted = yield* Deferred.make<void>();
559 const remoteStarted = yield* Deferred.make<void>();
560 remoteInterruptedDeferred = remoteInterrupted;
561 remoteStartedDeferred = remoteStarted;
562​
563 const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
564 const firstSnapshot = yield* Deferred.make<VcsStatusStreamEvent>();
565 const secondSnapshot = yield* Deferred.make<VcsStatusStreamEvent>();
566 const firstScope = yield* Scope.make();
567 const secondScope = yield* Scope.make();
568 const passiveSnapshot = yield* Deferred.make<VcsStatusStreamEvent>();
569 yield* Stream.runForEach(
570 broadcaster.streamStatus({ cwd: "/repo", includeRemote: false }),
571 (event) =>
572 event._tag === "snapshot"
573 ? Deferred.succeed(passiveSnapshot, event).pipe(Effect.ignore)
574 : Effect.void,
575 ).pipe(Effect.forkScoped);
576 yield* Deferred.await(passiveSnapshot);
577 assert.equal(state.remoteStatusCalls, 0);
578 yield* Stream.runForEach(broadcaster.streamStatus({ cwd: "/repo" }), (event) =>
579 event._tag === "snapshot"
580 ? Deferred.succeed(firstSnapshot, event).pipe(Effect.ignore)
581 : Effect.void,
582 ).pipe(Effect.forkIn(firstScope));
583 yield* Stream.runForEach(broadcaster.streamStatus({ cwd: "/repo" }), (event) =>
584 event._tag === "snapshot"
585 ? Deferred.succeed(secondSnapshot, event).pipe(Effect.ignore)
586 : Effect.void,
587 ).pipe(Effect.forkIn(secondScope));
588​
589 yield* Deferred.await(firstSnapshot);
590 yield* Deferred.await(secondSnapshot);
591 yield* Deferred.await(remoteStarted);
592​
593 assert.equal(state.remoteStatusCalls, 1);
594​
595 yield* Scope.close(firstScope, Exit.void);
596 assert.isTrue(Option.isNone(yield* Deferred.poll(remoteInterrupted)));
597​
598 yield* Scope.close(secondScope, Exit.void).pipe(Effect.forkScoped);
599 yield* Deferred.await(remoteInterrupted);
600 assert.isTrue(Option.isSome(yield* Deferred.poll(remoteInterrupted)));
601 }).pipe(Effect.provide(layerTest));
602 });
603});