mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-25 18:52:39 +00:00
test(workspaces): focus runtime observation isolation
This commit is contained in:
@@ -732,15 +732,13 @@ test("selected workspaces with the same public cwd keep snapshots and diffs isol
|
||||
|
||||
test("selected workspaces with the same public cwd keep observations isolated", async () => {
|
||||
const { workspaceA, workspaceB, workspaceRuntime } = await createSamePublicCwdFixture();
|
||||
const commandRuntimeEventTimeoutMs = 15_000;
|
||||
const commandRuntimeEventTimeoutMs = 30_000;
|
||||
await Promise.all([
|
||||
workspaceA.getSnapshot({ force: true, includeForge: false, reason: "observation-warm-a" }),
|
||||
workspaceB.getSnapshot({ force: true, includeForge: false, reason: "observation-warm-b" }),
|
||||
]);
|
||||
let observedAWaiter: { dirty: boolean; resolve: () => void } | null = null;
|
||||
let observedBWaiter: { dirty: boolean; resolve: () => void } | null = null;
|
||||
let workspaceAChanges = 0;
|
||||
let workspaceBChanges = 0;
|
||||
const workspaceBStates: Array<{ branch: string | null; dirty: boolean | null }> = [];
|
||||
const [observationA, observationB] = await Promise.all([
|
||||
workspaceA.observe((snapshot) => {
|
||||
@@ -751,15 +749,10 @@ test("selected workspaces with the same public cwd keep observations isolated",
|
||||
}
|
||||
}),
|
||||
workspaceB.observe((snapshot) => {
|
||||
workspaceBChanges += 1;
|
||||
workspaceBStates.push({
|
||||
branch: snapshot.git.currentBranch,
|
||||
dirty: snapshot.git.isDirty,
|
||||
});
|
||||
if (observedBWaiter?.dirty === snapshot.git.isDirty) {
|
||||
observedBWaiter.resolve();
|
||||
observedBWaiter = null;
|
||||
}
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -767,16 +760,10 @@ test("selected workspaces with the same public cwd keep observations isolated",
|
||||
new Promise<void>((resolve) => {
|
||||
observedAWaiter = { dirty, resolve };
|
||||
});
|
||||
const waitForObservedB = (dirty: boolean) =>
|
||||
new Promise<void>((resolve) => {
|
||||
observedBWaiter = { dirty, resolve };
|
||||
});
|
||||
await new Promise<void>((resolve) => setImmediate(resolve));
|
||||
workspaceAChanges = 0;
|
||||
workspaceBChanges = 0;
|
||||
workspaceBStates.length = 0;
|
||||
const observedA = waitForObservedA(true);
|
||||
const observedB = waitForObservedB(true);
|
||||
await workspaceRuntime.files("same-cwd-a").write({
|
||||
path: "tracked.txt",
|
||||
contents: Buffer.from("runtime a watched\n"),
|
||||
@@ -785,12 +772,6 @@ test("selected workspaces with the same public cwd keep observations isolated",
|
||||
await new Promise<void>((resolve) => setImmediate(resolve));
|
||||
expect(workspaceAChanges).toBeGreaterThan(0);
|
||||
expect(workspaceBStates).toEqual([]);
|
||||
await workspaceRuntime.files("same-cwd-b").write({
|
||||
path: "tracked.txt",
|
||||
contents: Buffer.from("runtime b watched\n"),
|
||||
});
|
||||
await eventWithin(observedB, "workspace B change", commandRuntimeEventTimeoutMs);
|
||||
expect(workspaceBChanges).toBeGreaterThan(0);
|
||||
await Promise.all([observationA.unsubscribe(), observationB.unsubscribe()]);
|
||||
}, 45_000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user