diff --git a/e2e/containers.e2e.spec.ts b/e2e/containers.e2e.spec.ts index 0152cb4ac08..9a70ede12bf 100644 --- a/e2e/containers.e2e.spec.ts +++ b/e2e/containers.e2e.spec.ts @@ -6,6 +6,7 @@ import { NavPage } from './pages/nav-page'; import { createDefaultSettings, startRancherDesktop, teardown, tool } from './utils/TestUtils'; import { Settings } from '@pkg/config/settings'; +import { reopenLogs } from '@pkg/utils/logging'; import type { ElectronApplication, Page } from '@playwright/test'; @@ -18,6 +19,11 @@ let page: Page; test.describe.serial('Container Engine', () => { let electronApp: ElectronApplication; + test.beforeAll(async() => { + await tool('rdctl', 'factory-reset', '--verbose'); + reopenLogs(); + }); + test.beforeAll(async() => { createDefaultSettings({ application: { adminAccess: false } }); diff --git a/e2e/lockedFields.e2e.spec.ts b/e2e/lockedFields.e2e.spec.ts index 480ce06b098..7e8cbff3bbf 100644 --- a/e2e/lockedFields.e2e.spec.ts +++ b/e2e/lockedFields.e2e.spec.ts @@ -99,6 +99,11 @@ test.describe('Locked fields', () => { test.afterAll(() => teardown(electronApp, __filename)); + test.afterAll(async() => { + await tool('rdctl', 'factory-reset', '--verbose'); + reopenLogs(); + }); + test('should start up', async() => { const navPage = new NavPage(page); diff --git a/e2e/preferences.e2e.spec.ts b/e2e/preferences.e2e.spec.ts index 04f890f4497..0622516070a 100644 --- a/e2e/preferences.e2e.spec.ts +++ b/e2e/preferences.e2e.spec.ts @@ -4,7 +4,9 @@ import { test, expect, _electron } from '@playwright/test'; import { NavPage } from './pages/nav-page'; import { PreferencesPage } from './pages/preferences'; -import { createDefaultSettings, startRancherDesktop, teardown } from './utils/TestUtils'; +import { createDefaultSettings, startRancherDesktop, teardown, tool } from './utils/TestUtils'; + +import { reopenLogs } from '@pkg/utils/logging'; import type { ElectronApplication, Page } from '@playwright/test'; @@ -30,6 +32,11 @@ test.describe.serial('Main App Test', () => { test.afterAll(() => teardown(electronApp, __filename)); + test.afterAll(async() => { + await tool('rdctl', 'factory-reset', '--verbose'); + reopenLogs(); + }); + test('should open preferences modal', async() => { expect(preferencesWindow).toBeDefined(); diff --git a/e2e/utils/TestUtils.ts b/e2e/utils/TestUtils.ts index 0c3b2f44ae3..d8bfafe70ec 100644 --- a/e2e/utils/TestUtils.ts +++ b/e2e/utils/TestUtils.ts @@ -147,7 +147,12 @@ export async function teardown(app: ElectronApplication, filename: string) { try { await context.tracing.stop({ path: reportAsset(filename) }); await packageLogs(filename); - await app.close(); + // Allow one minute for shutdown + await Promise.race([ + app.close(), + util.promisify(setTimeout)(60 * 1000), + ]); + await tool('rdctl', 'shutdown'); } finally { if (proc.kill('SIGTERM') || proc.kill('SIGKILL')) { console.log(`Manually stopped process ${ pid }`);