Skip to content

Commit 3b2307c

Browse files
committed
refactor(web): reduce snapshot disable fix to the drain gate
1 parent 0a8b4dd commit 3b2307c

5 files changed

Lines changed: 141 additions & 396 deletions

File tree

‎apps/desktop/src/snapShot/DesktopSnapShot.test.ts‎

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,42 +3815,29 @@ it.effect("probes macOS modifier pairs with the flags poller", () => {
38153815
).pipe(Effect.provide(layerTest("darwin")));
38163816
});
38173817

3818-
it.effect.each([
3819-
{ shortcut: { kind: "modifier-pair", modifier: "meta" }, flags: ["8", "16"] },
3820-
{ shortcut: { kind: "both-shift-keys" }, flags: ["2", "4"] },
3821-
] as const)(
3822-
"registers macOS $shortcut and releases the flags poller when disabled",
3823-
({ shortcut, flags }) => {
3824-
spawnedPollers.length = 0;
3825-
shortcutProcesses.length = 0;
3826-
accessibilityTrustedMock.mockReturnValue(true);
3827-
mediaAccessStatusMock.mockReturnValue("granted");
3828-
const settings = {
3829-
...DEFAULT_CLIENT_SETTINGS,
3830-
snapShotShortcut: shortcut,
3831-
} satisfies ClientSettings;
3818+
it.effect("registers macOS modifier pairs through the flags poller", () => {
3819+
spawnedPollers.length = 0;
3820+
shortcutProcesses.length = 0;
3821+
accessibilityTrustedMock.mockReturnValue(true);
3822+
mediaAccessStatusMock.mockReturnValue("granted");
3823+
const settings = {
3824+
...DEFAULT_CLIENT_SETTINGS,
3825+
snapShotShortcut: { kind: "modifier-pair", modifier: "meta" },
3826+
} satisfies ClientSettings;
38323827

3833-
return Effect.scoped(
3834-
Effect.gen(function* () {
3835-
const service = yield* DesktopSnapShot.make;
3836-
yield* service.configure({ ...settings, snapShotEnabled: true });
3837-
const state = yield* service.state;
3828+
return Effect.scoped(
3829+
Effect.gen(function* () {
3830+
const service = yield* DesktopSnapShot.make;
3831+
yield* service.configure({ ...settings, snapShotEnabled: true });
3832+
const state = yield* service.state;
38383833

3839-
assert.lengthOf(shortcutProcesses, 0);
3840-
assert.lengthOf(spawnedPollers, 1);
3841-
assert.deepEqual(spawnedPollers[0]?.args.slice(-2), [...flags]);
3842-
assert.isTrue(state.shortcutRegistered);
3843-
const poller = spawnedPollers[0]!;
3844-
assert.lengthOf(poller.kill.mock.calls, 0);
3845-
yield* service.configure({ ...settings, snapShotEnabled: false });
3846-
assert.lengthOf(poller.kill.mock.calls, 1);
3847-
assert.isFalse((yield* service.state).shortcutRegistered);
3848-
const failure = yield* Effect.flip(service.capture);
3849-
assert.equal(failure.operation, "disabled");
3850-
}),
3851-
).pipe(Effect.provide(layerTest("darwin")));
3852-
},
3853-
);
3834+
assert.lengthOf(shortcutProcesses, 0);
3835+
assert.lengthOf(spawnedPollers, 1);
3836+
assert.deepEqual(spawnedPollers[0]?.args.slice(-2), ["8", "16"]);
3837+
assert.isTrue(state.shortcutRegistered);
3838+
}),
3839+
).pipe(Effect.provide(layerTest("darwin")));
3840+
});
38543841

38553842
it.effect("waits to apply settings while permissions are pending", () => {
38563843
accessibilityTrustedMock.mockReturnValue(true);

0 commit comments

Comments
 (0)