Skip to content

A local-first personal finance app

[AI] Fix Electron e2e test on master (#9139)

Julian Dominguez-Schatze4ee6935dbc7
diff --git a/packages/desktop-electron/e2e/fixtures.ts b/packages/desktop-electron/e2e/fixtures.ts
index e1b2fc31bc..6efc8a043e 100644
--- a/packages/desktop-electron/e2e/fixtures.ts
+++ b/packages/desktop-electron/e2e/fixtures.ts
@@ -16,19 +16,30 @@ type ElectronOptions = {
* exercise the startup error screen.
*/
blockDocumentDir: boolean;
+ corruptGlobalPrefs: boolean;
};
// Create the extended test with fixtures
export const test = base.extend<ElectronFixtures & ElectronOptions>({
blockDocumentDir: [false, { option: true }],
+ corruptGlobalPrefs: [false, { option: true }],
- electronApp: async ({ blockDocumentDir }, use, testInfo: TestInfo) => {
+ electronApp: async (
+ { blockDocumentDir, corruptGlobalPrefs },
+ use,
+ testInfo: TestInfo,
+ ) => {
const uniqueTestId = testInfo.testId.replace(/[^\w-]/g, '-');
const testDataDir = path.join('e2e/data/', uniqueTestId);
await rm(testDataDir, { recursive: true, force: true }); // ensure any leftover test data is removed
await mkdir(testDataDir, { recursive: true });
+ if (corruptGlobalPrefs) {
+ // Trigger a startup diagnostic before the renderer exists.
+ await writeFile(path.join(testDataDir, 'global-store.json'), '{');
+ }
+
let documentDir = testDataDir;
if (blockDocumentDir) {
// A regular file can't contain a folder, so `mkdir <file>/Actual` fails
diff --git a/packages/desktop-electron/e2e/navigation-security.test.ts b/packages/desktop-electron/e2e/navigation-security.test.ts
index 0c7c6ce268..9ba5ee4fea 100644
--- a/packages/desktop-electron/e2e/navigation-security.test.ts
+++ b/packages/desktop-electron/e2e/navigation-security.test.ts
@@ -86,19 +86,22 @@ test('redirects cannot replace the app with an external page', async ({
}
});
-test('forwards queued startup logs to the app DevTools console', async ({
- electronPage,
-}) => {
- await expect(electronPage).toHaveURL('app://actual/config-server');
- const messages: string[] = [];
- const session = await electronPage.context().newCDPSession(electronPage);
- session.on('Runtime.consoleAPICalled', event => {
- messages.push(event.args.map(arg => arg.value).join(' '));
- });
- // Runtime.enable also reports console messages emitted before attachment.
- await session.send('Runtime.enable');
- await expect
- .poll(() => messages.join('\n'))
- .toContain('Could not load global state');
- await session.detach();
-});
+const startupLogTest = test.extend({ corruptGlobalPrefs: true });
+
+startupLogTest(
+ 'forwards queued startup logs to the app DevTools console',
+ async ({ electronPage }) => {
+ await expect(electronPage).toHaveURL('app://actual/config-server');
+ const messages: string[] = [];
+ const session = await electronPage.context().newCDPSession(electronPage);
+ session.on('Runtime.consoleAPICalled', event => {
+ messages.push(event.args.map(arg => arg.value).join(' '));
+ });
+ // Runtime.enable also reports console messages emitted before attachment.
+ await session.send('Runtime.enable');
+ await expect
+ .poll(() => messages.join('\n'))
+ .toContain('Could not parse global state');
+ await session.detach();
+ },
+);
diff --git a/upcoming-release-notes/fix-desktop-startup-log-test.md b/upcoming-release-notes/fix-desktop-startup-log-test.md
new file mode 100644
index 0000000000..22ec112a80
--- /dev/null
+++ b/upcoming-release-notes/fix-desktop-startup-log-test.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [jfdoming]
+---
+
+Fix the desktop startup logging test after changes to preferences loading.