Skip to content

Commit 7348128

Browse files
committed
fixup: wait for set preferences function to be set before setting preferences
1 parent 249437a commit 7348128

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

packages/compass-e2e-tests/helpers/commands/set-feature.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@ export async function setFeature<K extends keyof UserPreferences>(
1111
value: UserPreferences[K]
1212
): Promise<void> {
1313
if (isTestingWeb()) {
14-
// When running in Compass web we cannot use the IPC to update the
15-
// preferences so we use a global function.
16-
await browser.execute(
17-
async (_name, _value) => {
18-
const attributes: Partial<AllPreferences> = {
19-
[_name]: _value === null ? undefined : _value,
20-
};
21-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
22-
await (globalThis as any).__compassWebE2ETestSavePreferences(
23-
attributes
24-
);
25-
},
26-
name,
27-
value
28-
);
14+
await browser.waitUntil(async function () {
15+
// When running in Compass web we cannot use the IPC to update the
16+
// preferences so we use a global function.
17+
const didSavePreference = await browser.execute(
18+
async (_name, _value) => {
19+
if (!(globalThis as any).__compassWebE2ETestSavePreferences) {
20+
return false;
21+
}
22+
23+
const attributes: Partial<AllPreferences> = {
24+
[_name]: _value === null ? undefined : _value,
25+
};
26+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27+
await (globalThis as any).__compassWebE2ETestSavePreferences(
28+
attributes
29+
);
30+
31+
return true;
32+
},
33+
name,
34+
value
35+
);
36+
37+
return didSavePreference;
38+
});
2939
return;
3040
}
3141

packages/compass-e2e-tests/tests/auto-connect.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,7 @@ describe('Automatically connecting from the command line', function () {
308308

309309
await browser.execute(() => {
310310
// eslint-disable-next-line @typescript-eslint/no-var-requires
311-
(require('electron').ipcRenderer as any).call(
312-
'test:show-connect-window'
313-
);
311+
require('electron').ipcRenderer.call('test:show-connect-window');
314312
});
315313

316314
// Switch to the other window

0 commit comments

Comments
 (0)