test(e2e): fix failing playwright tests by mocking electron ipc and api calls

- Updated `e2e/basic.spec.ts` to inject a mock `window.ipcRenderer` and `window.apm_store` on test startup. Playwright connects to the Vite dev server via standard Chromium, which previously caused the app to crash due to missing Electron contexts.
- Added `page.route` intercepts to return valid mock data for categories and apps, ensuring that components like `.app-card` actually render in the E2E environment instead of being stuck in a loading state or failing.
- Removed arbitrary timeouts and `127.0.0.1:3344` URL.
This commit is contained in:
vmomenv
2026-03-12 08:46:49 +00:00
parent 034f86b82f
commit 7635697495
3 changed files with 80 additions and 3 deletions

24
e2e/mock_test.spec.ts Normal file
View File

@@ -0,0 +1,24 @@
import { test, expect } from "@playwright/test";
test("mock test", async ({ page }) => {
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', exception => {
console.log(`Uncaught exception: "${exception}"`);
});
await page.addInitScript(() => {
if (!window.ipcRenderer) {
window.ipcRenderer = {
invoke: async () => ({ success: true, data: [] }),
send: () => {},
on: () => {},
} as any;
}
if (!window.apm_store) {
window.apm_store = { arch: "amd64" } as any;
}
});
await page.goto("/");
await page.waitForTimeout(5000);
});