Skip to content

Commit 7098789

Browse files
authored
Fix --no-update command line flag (#2210)
* Fix `--no-update` command line flag Signed-off-by: Michael Telatynski <[email protected]> * Add test Signed-off-by: Michael Telatynski <[email protected]> * fail-fast: false Signed-off-by: Michael Telatynski <[email protected]> * Skip Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 618c04d commit 7098789

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

.github/workflows/build_and_test.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
- linux
5050
- windows
5151
strategy:
52+
fail-fast: false
5253
matrix:
5354
include:
5455
- name: macOS Universal

playwright/e2e/launch/launch.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,16 @@ test.describe("App launch", () => {
5555
}),
5656
).resolves.not.toBeNull();
5757
});
58+
59+
test.describe("--no-update", () => {
60+
test.use({
61+
extraArgs: ["--no-update"],
62+
});
63+
64+
// XXX: this test works fine locally but in CI the app start races with the test plumbing up the stdout/stderr pipes
65+
// which means the logs are missed, disabling for now.
66+
test.skip("should respect option", async ({ page, stdout }) => {
67+
expect(stdout.data.toString()).toContain("Auto update disabled via command line flag");
68+
});
69+
});
5870
});

playwright/element-desktop-test.ts

+38-3
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,62 @@ import fs from "node:fs/promises";
1111
import path, { dirname } from "node:path";
1212
import os from "node:os";
1313
import { fileURLToPath } from "node:url";
14+
import { PassThrough } from "node:stream";
15+
16+
/**
17+
* A PassThrough stream that captures all data written to it.
18+
*/
19+
class CapturedPassThrough extends PassThrough {
20+
private _chunks = [];
21+
22+
public constructor() {
23+
super();
24+
super.on("data", this.onData);
25+
}
26+
27+
private onData = (chunk): void => {
28+
this._chunks.push(chunk);
29+
};
30+
31+
public get data(): Buffer {
32+
return Buffer.concat(this._chunks);
33+
}
34+
}
1435

1536
interface Fixtures {
1637
app: ElectronApplication;
1738
tmpDir: string;
1839
extraEnv: Record<string, string>;
1940
extraArgs: string[];
41+
42+
// Utilities to capture stdout and stderr for tests to make assertions against
43+
stdout: CapturedPassThrough;
44+
stderr: CapturedPassThrough;
2045
}
2146

2247
const __dirname = dirname(fileURLToPath(import.meta.url));
2348

2449
export const test = base.extend<Fixtures>({
2550
extraEnv: {},
2651
extraArgs: [],
52+
53+
// eslint-disable-next-line no-empty-pattern
54+
stdout: async ({}, use) => {
55+
await use(new CapturedPassThrough());
56+
},
57+
// eslint-disable-next-line no-empty-pattern
58+
stderr: async ({}, use) => {
59+
await use(new CapturedPassThrough());
60+
},
61+
2762
// eslint-disable-next-line no-empty-pattern
2863
tmpDir: async ({}, use) => {
2964
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "element-desktop-tests-"));
3065
console.log("Using temp profile directory: ", tmpDir);
3166
await use(tmpDir);
3267
await fs.rm(tmpDir, { recursive: true });
3368
},
34-
app: async ({ tmpDir, extraEnv, extraArgs }, use) => {
69+
app: async ({ tmpDir, extraEnv, extraArgs, stdout, stderr }, use) => {
3570
const args = ["--profile-dir", tmpDir];
3671

3772
const executablePath = process.env["ELEMENT_DESKTOP_EXECUTABLE"];
@@ -49,8 +84,8 @@ export const test = base.extend<Fixtures>({
4984
args: [...args, ...extraArgs],
5085
});
5186

52-
app.process().stdout.pipe(process.stdout);
53-
app.process().stderr.pipe(process.stderr);
87+
app.process().stdout.pipe(stdout).pipe(process.stdout);
88+
app.process().stderr.pipe(stderr).pipe(process.stderr);
5489

5590
await app.firstWindow();
5691

src/electron-main.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,9 @@ app.on("ready", async () => {
436436
});
437437
});
438438

439-
if (argv["no-update"]) {
440-
console.log('Auto update disabled via command line flag "--no-update"');
439+
// Minimist parses `--no-`-prefixed arguments as booleans with value `false` rather than verbatim.
440+
if (argv["update"] === false) {
441+
console.log("Auto update disabled via command line flag");
441442
} else if (global.vectorConfig["update_base_url"]) {
442443
console.log(`Starting auto update with base URL: ${global.vectorConfig["update_base_url"]}`);
443444
void updater.start(global.vectorConfig["update_base_url"]);

0 commit comments

Comments
 (0)