Skip to content

Commit cbb2392

Browse files
committed
test(desktop): cover Linux window class pre-ready
1 parent fdb8c71 commit cbb2392

3 files changed

Lines changed: 23 additions & 33 deletions

File tree

‎apps/desktop/src/app/DesktopAppIdentity.test.ts‎

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ type TestEnvironmentInput = Partial<DesktopEnvironment.MakeDesktopEnvironmentInp
3131
};
3232

3333
interface ElectronAppCalls {
34-
readonly appendCommandLineSwitch: Array<{
35-
readonly name: string;
36-
readonly value: string | undefined;
37-
}>;
3834
readonly setAboutPanelOptions: Array<Electron.AboutPanelOptionsOptions>;
3935
readonly setDockIcon: string[];
4036
readonly setName: string[];
@@ -66,10 +62,7 @@ const makeElectronAppLayer = (calls: ElectronAppCalls) =>
6662
Effect.sync(() => {
6763
calls.setDockIcon.push(iconPath);
6864
}),
69-
appendCommandLineSwitch: (name, value) =>
70-
Effect.sync(() => {
71-
calls.appendCommandLineSwitch.push({ name, value });
72-
}),
65+
appendCommandLineSwitch: () => Effect.void,
7366
onBeforeQuitForUpdate: () => Effect.void,
7467
removeCommandLineSwitch: () => Effect.void,
7568
on: () => Effect.void,
@@ -121,7 +114,6 @@ const withIdentity = <A, E, R>(
121114
} = {},
122115
) => {
123116
const calls: ElectronAppCalls = input.calls ?? {
124-
appendCommandLineSwitch: [],
125117
setAboutPanelOptions: [],
126118
setDockIcon: [],
127119
setName: [],
@@ -192,7 +184,6 @@ describe("DesktopAppIdentity", () => {
192184

193185
it.effect("configures app identity from the environment commit override", () => {
194186
const calls: ElectronAppCalls = {
195-
appendCommandLineSwitch: [],
196187
setAboutPanelOptions: [],
197188
setDockIcon: [],
198189
setName: [],
@@ -220,23 +211,4 @@ describe("DesktopAppIdentity", () => {
220211
},
221212
);
222213
});
223-
224-
it.effect("sets the Linux window class used by the packaged desktop entry", () => {
225-
const calls: ElectronAppCalls = {
226-
appendCommandLineSwitch: [],
227-
setAboutPanelOptions: [],
228-
setDockIcon: [],
229-
setName: [],
230-
};
231-
232-
return withIdentity(
233-
Effect.gen(function* () {
234-
const identity = yield* DesktopAppIdentity.DesktopAppIdentity;
235-
yield* identity.configure;
236-
237-
assert.deepEqual(calls.appendCommandLineSwitch, [{ name: "class", value: "t3code" }]);
238-
}),
239-
{ calls, environment: { platform: "linux" } },
240-
);
241-
});
242214
});

‎apps/desktop/src/app/DesktopAppIdentity.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ export const make = Effect.gen(function* () {
131131
}
132132

133133
if (environment.platform === "linux") {
134-
// Match the packaged desktop entry's StartupWMClass so Linux shells can
135-
// associate the running window with its launcher and icon.
136-
yield* electronApp.appendCommandLineSwitch("class", environment.linuxWmClass);
137134
yield* electronApp.setDesktopName(environment.linuxDesktopEntryName);
138135
}
139136

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
33
import * as Context from "effect/Context";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
6-
import { beforeEach, vi } from "vite-plus/test";
6+
import { afterEach, beforeEach, vi } from "vite-plus/test";
77

88
const { appendSwitchMock, getSwitchValueMock, hasSwitchMock, registerSchemesMock } = vi.hoisted(
99
() => ({
@@ -37,6 +37,10 @@ describe("DesktopPreReadyPlatform", () => {
3737
registerSchemesMock.mockReset();
3838
});
3939

40+
afterEach(() => {
41+
vi.unstubAllEnvs();
42+
});
43+
4044
it("reads an explicit Electron command-line switch value", () => {
4145
const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
4246
{
@@ -78,6 +82,23 @@ describe("DesktopPreReadyPlatform", () => {
7882
assert.isNull(value);
7983
});
8084

85+
it.effect("appends the packaged Linux window class before Electron is ready", () =>
86+
Effect.gen(function* () {
87+
vi.stubEnv("VITE_DEV_SERVER_URL", "");
88+
hasSwitchMock.mockReturnValue(false);
89+
90+
const preReadyLayer = DesktopPreReadyPlatform.layer.pipe(
91+
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
92+
);
93+
const options = yield* Effect.gen(function* () {
94+
return yield* DesktopPreReadyPlatform.DesktopPreReadyElectronOptions;
95+
}).pipe(Effect.provide(preReadyLayer));
96+
97+
assert.equal(options.linux?.linuxWmClass, "t3code");
98+
assert.deepEqual(appendSwitchMock.mock.calls[0], ["class", "t3code"]);
99+
}),
100+
);
101+
81102
it.effect(
82103
"acquires a synchronous pre-ready layer before an asynchronous Clerk-shaped layer",
83104
() =>

0 commit comments

Comments
 (0)