authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 22:12:27-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 22:12:27-07:00
log181e45110f2d14950a5c1ec415faf3a049cb9b2e
tree390174d35962b992ef3a1fa657b18bffd0be6716
parentcabac780f5d9566ea26d340c9f126a46664b698b
signature Signed by PGP key B5690EEEBB952194

test(desktop): cover password store through startup (#10287)


2 files changed, 16 insertions(+), 39 deletions(-)

apps/desktop/src/app/DesktopPreReadyPlatform.test.ts+15-38
......@@ -37,45 +37,22 @@ describe("DesktopPreReadyPlatform", () => {
3737 registerSchemesMock.mockReset();
3838 });
3939
40 it("reads an explicit Electron command-line switch value", () => {
41 const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
42 {
43 hasSwitch: (switchName) => switchName === "password-store",
44 getSwitchValue: (switchName) => {
45 assert.equal(switchName, "password-store");
46 return "basic";
47 },
48 },
49 "password-store",
40 it.effect("preserves an explicit Linux password-store switch", () => {
41 hasSwitchMock.mockImplementation((switchName) => switchName === "password-store");
42 getSwitchValueMock.mockReturnValue(" basic ");
43
44 return Effect.gen(function* () {
45 const options = yield* DesktopPreReadyPlatform.DesktopPreReadyElectronOptions;
46
47 assert.equal(options.linuxPasswordStoreCommandLine, "basic");
48 assert.isFalse(appendSwitchMock.mock.calls.some(([name]) => name === "password-store"));
49 }).pipe(
50 Effect.provide(
51 DesktopPreReadyPlatform.layer.pipe(
52 Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
53 ),
54 ),
5055 );
51
52 assert.equal(value, "basic");
53 });
54
55 it("treats valueless Electron command-line switches as absent", () => {
56 const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
57 {
58 hasSwitch: () => true,
59 getSwitchValue: () => "",
60 },
61 "password-store",
62 );
63
64 assert.isNull(value);
65 });
66
67 it("returns null for missing Electron command-line switches", () => {
68 const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
69 {
70 hasSwitch: () => false,
71 getSwitchValue: () => {
72 throw new Error("Unexpected switch value read.");
73 },
74 },
75 "password-store",
76 );
77
78 assert.isNull(value);
7956 });
8057
8158 it.effect(
apps/desktop/src/app/DesktopPreReadyPlatform.ts+1-1
......@@ -17,7 +17,7 @@ export interface DesktopPreReadyCommandLineReader {
1717 readonly getSwitchValue: (switchName: string) => string;
1818}
1919
20export function readCommandLineSwitchValue(
20function readCommandLineSwitchValue(
2121 commandLine: DesktopPreReadyCommandLineReader,
2222 switchName: string,
2323): string | null {