feat: add Jest unit tests and Playwright e2e test suite#562
Conversation
- Install jest, ts-jest, @types/jest, ts-node, @playwright/test - Add jest.config.ts, playwright.config.ts, tsconfig.test.json - Add manual mocks for electron and electron-store - Add unit tests: SettingsManager (29 tests), InstallIdManager (5 tests), EncryptionManager (11 tests), ConnectionsManager (20 tests), cspUtils (4 tests), toolSourceIcon (6 tests) — 76 total - Add e2e fixtures, app.spec.ts and navigation.spec.ts - Add GitHub Actions test.yml workflow (runs on PRs to dev and main) - Add test/test:unit/test:unit:watch/test:unit:coverage/test:e2e/test:e2e:ui scripts
|
@copilot two tests failed but they shouldnt [electron] › tests/e2e/app.spec.ts:13:9 › App launch › main window is visible after launch ───── Make sure either the tests are written correctly or code needs fixing |
Bundle Size Report 📦
Bundle Analysis ReportsThe detailed bundle analysis reports are available in the workflow artifacts:
Download the artifacts from the workflow run to view interactive visualizations. Bundle size tracking is now active! This helps prevent bundle bloat. |
Bundle Size Report 📦
Bundle Analysis ReportsThe detailed bundle analysis reports are available in the workflow artifacts:
Download the artifacts from the workflow run to view interactive visualizations. Bundle size tracking is now active! This helps prevent bundle bloat. |
The root cause was a timing race in the
Fixes (commit
|
Bundle Size Report 📦
Bundle Analysis ReportsThe detailed bundle analysis reports are available in the workflow artifacts:
Download the artifacts from the workflow run to view interactive visualizations. Bundle size tracking is now active! This helps prevent bundle bloat. |
|
@copilot the test CI process failed |
The CI failure was caused by the Electron binary not being downloaded in the e2e job. Fixed in commit - name: Install Electron binary
run: node ./node_modules/electron/install.jsThis ensures the binary is always present before Playwright attempts to launch the app. |
Bundle Size Report 📦
Bundle Analysis ReportsThe detailed bundle analysis reports are available in the workflow artifacts:
Download the artifacts from the workflow run to view interactive visualizations. Bundle size tracking is now active! This helps prevent bundle bloat. |
Introduces a modular test suite covering main-process managers (unit) and full app launch/navigation (e2e). Runs automatically on PRs targeting
devandmain.Unit Tests (Jest + ts-jest) — 76 tests
electron(safeStorage,app,BrowserWindow,ipcMain, etc.) andelectron-store(in-memoryMap) so tests run in plain Node.jsSettingsManager,InstallIdManager,EncryptionManager,ConnectionsManager,normalizeCspExceptionSource,toolSourceIconutilitiesE2e Tests (Playwright)
tests/e2e/fixtures.tslaunches/tears down a real Electron process per test file; fixture waits forindex.htmlURL and fullloadstate before handing the window to tests, preventing false failures whenfirstWindow()returns while the BrowserWindow is still onabout:blankapp.spec.ts: window title (with 30 s assertion timeout for CI resilience), body visibility, sidebar presence, zero JS errors at startupnavigation.spec.ts: settings and marketplace navigation; usestest.skip(condition, msg)for resilience against selector driftInfrastructure
jest.config.ts+playwright.config.ts+tsconfig.test.jsontests/__mocks__/for electron and electron-store.github/workflows/test.yml: two jobs (unit-tests,e2e-tests), e2e usesxvfb-run; both upload artifacts; e2e job explicitly installs the Electron binary vianode ./node_modules/electron/install.jsafterpnpm installto ensure the binary is present in CINew scripts
test:unittest:unit:watchtest:unit:coveragetest:e2ebuild)test:e2e:uitest