mirror of
https://github.com/actualbudget/actual.git
synced 2026-10-11 22:49:59 +00:00
[AI] Fix Electron e2e test on master (#9139)
* [AI] Make Electron startup log test deterministic Seed corrupt global preferences before launching the startup-log test, so it exercises a real queued diagnostic. Fresh installs no longer log missing preferences after #8968. * [AI] Add release note for desktop startup log test fix
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [jfdoming]
|
||||
---
|
||||
|
||||
Fix the desktop startup logging test after changes to preferences loading.
|
||||
Reference in New Issue
Block a user