test(e2e): add deep Playwright Electron process-flow coverage#56
Conversation
Reviewer's GuideAdds Playwright-based Electron end-to-end tests for full process-flow coverage, wires them into npm scripts and the QA CI matrix, introduces isolated Electron userData per test via an environment override, and documents the new E2E layer in the test catalog while excluding these specs from Jest. Sequence diagram for Playwright Electron E2E with isolated userDatasequenceDiagram
actor Developer
participant CI as GitHubActions_QA_Matrix
participant NPM as NpmScripts
participant PW as PlaywrightRunner
participant Electron as ElectronApp
participant Main as MainProcess_index_ts
Developer->>NPM: run e2e:playwright
NPM->>PW: playwright test -c playwright.config.ts
PW->>PW: Discover tests in tests/e2e
PW->>PW: For each test set ELECTRON_USER_DATA_PATH
PW->>Electron: Launch app with env ELECTRON_USER_DATA_PATH
Electron->>Main: Execute main index.ts
Main->>Main: Read process.env.ELECTRON_USER_DATA_PATH
Main->>Main: Resolve path and mkdirSync(recursive)
Main->>Electron: app.setPath userData to resolved path
Electron->>PW: Render UI and process markdown/xml
PW->>PW: Perform assertions and save artifacts
CI->>NPM: xvfb-run -a npm run e2e:playwright (Linux)
PW->>CI: Exit code and Playwright artifacts
CI->>CI: Upload dist/qa/playwright-report and dist/qa/playwright-results
Flow diagram for Electron userData override in main processflowchart TD
Start[Electron main process start] --> CheckEnv{Is ELECTRON_USER_DATA_PATH a non-empty string?}
CheckEnv -- No --> DefaultUserData[Use default Electron userData path]
DefaultUserData --> Continue[Continue app startup]
CheckEnv -- Yes --> ResolvePath[Resolve absolute userData path]
ResolvePath --> EnsureDir[fs.mkdirSync path with recursive true]
EnsureDir --> SetUserData[app.setPath userData to resolved path]
SetUserData --> Continue
Continue --> WindowCreate[Create browser window and load renderer]
WindowCreate --> End[App ready for Playwright E2E tests]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello @Mehdi-Bl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the testing infrastructure by introducing robust end-to-end tests for the Electron application using Playwright. The changes aim to provide deterministic, full-process coverage within a self-contained app context, addressing critical gaps in testing the application's core processing behavior and improving the reliability of CI signals beyond basic UI checks. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Review Summary by QodoAdd deep Playwright Electron E2E process-flow coverage
WalkthroughsDescription• Add comprehensive Playwright E2E tests for Electron app process flows - Covers markdown/XML export, file selection, refresh, and save operations - Isolates test state via dedicated user data directories per test • Implement Playwright configuration with HTML reporting and artifact capture • Integrate E2E tests into CI/CD pipeline for Linux with artifact uploads • Exclude E2E specs from Jest discovery and document test coverage mapping Diagramflowchart LR
A["Playwright Config"] -->|defines test setup| B["E2E Test Suite"]
C["Main Process"] -->|accepts ELECTRON_USER_DATA_PATH| D["Isolated User Data"]
B -->|runs full flows| E["Markdown/XML Export"]
B -->|tests interactions| F["File Selection & Refresh"]
B -->|validates save| G["Disk Output"]
H["CI/CD Pipeline"] -->|runs on Linux| B
H -->|uploads artifacts| I["Playwright Reports"]
File Changes1. playwright.config.ts
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds Playwright-based Electron E2E tests with CI steps (Linux/xvfb), Playwright config and npm scripts, a new comprehensive E2E test file, and optional Electron userData redirection via ELECTRON_USER_DATA_PATH. Jest ignores the E2E tests during unit runs. Changes
Sequence Diagram(s)sequenceDiagram
participant CI as CI (qa-matrix)
participant Runner as Linux Runner
participant Xvfb as xvfb-run
participant Playwright as Playwright Test
participant Electron as Electron App
participant FS as Filesystem (dist/qa)
CI->>Runner: schedule job (Linux matrix)
Runner->>Xvfb: run `xvfb-run npm run e2e:playwright`
Xvfb->>Playwright: start tests (playwright.config.ts)
Playwright->>Electron: launch Electron (electronApp)
Playwright->>Electron: interact with UI, stub dialogs
Electron->>FS: write artifacts / saved outputs
Playwright->>FS: emit report to `dist/qa/playwright-report` and results to `dist/qa/playwright-results`
Runner->>CI: upload artifacts (always())
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dee696e7bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (typeof e2eUserDataPath === 'string' && e2eUserDataPath.trim().length > 0) { | ||
| const resolvedUserDataPath = path.resolve(e2eUserDataPath); | ||
| fs.mkdirSync(resolvedUserDataPath, { recursive: true }); | ||
| app.setPath('userData', resolvedUserDataPath); |
There was a problem hiding this comment.
Restrict userData override to test-only execution
This startup block runs in every environment and performs fs.mkdirSync on ELECTRON_USER_DATA_PATH without a safety fallback; if that variable is inherited with an invalid or unwritable path, the call throws before app.whenReady() and the app fails to launch. Because this variable was introduced for Playwright isolation, it should be gated to test runs (or wrapped with fallback handling) so production launches are not broken by ambient shell/CI environment state.
Useful? React with 👍 / 👎.
| ); | ||
| writeFixtureFile(projectDir, 'README.md', '# Fixture Project\n\nUsed for Electron E2E coverage.\n'); | ||
| writeFixtureFile(projectDir, '.gitignore', 'dist/\n*.log\n!important.log\n'); | ||
| writeFixtureFile(projectDir, '.env', 'LOCAL_SECRET_TOKEN=abc123\n'); |
There was a problem hiding this comment.
Remove hardcoded token literal from E2E fixture
The fixture writes a token-shaped credential string into a .env file (LOCAL_SECRET_TOKEN=abc123), which conflicts with the repository’s review policy in /workspace/ai-code-fusion/AGENTS.md to reject hardcoded secret/token exposure in committed code. Even as test data, this pattern can trip secret-scanning workflows and create avoidable security review noise; use a clearly non-credential placeholder instead.
Useful? React with 👍 / 👎.
Code Review by Qodo
1. Hardcoded token-like .env value
|
| writeFixtureFile(projectDir, 'README.md', '# Fixture Project\n\nUsed for Electron E2E coverage.\n'); | ||
| writeFixtureFile(projectDir, '.gitignore', 'dist/\n*.log\n!important.log\n'); | ||
| writeFixtureFile(projectDir, '.env', 'LOCAL_SECRET_TOKEN=abc123\n'); | ||
| writeFixtureFile(projectDir, 'dist/bundle.js', 'console.log("should be excluded");\n'); |
There was a problem hiding this comment.
1. Hardcoded token-like .env value 📘 Rule violation ⛨ Security
The E2E test writes a token-looking value (LOCAL_SECRET_TOKEN=abc123) in tracked test code, which violates the prohibition on committing credentials/tokens in the repository. Even if intended as a fixture, it still constitutes a hardcoded token string in source.
Agent Prompt
## Issue description
A token-like value is hardcoded in a tracked test file (`LOCAL_SECRET_TOKEN=abc123`), which is disallowed by the no-hardcoded-secrets requirement.
## Issue Context
The `.env` file appears to be used only as a fixture file that should be excluded from selection; the content does not need to resemble a real token.
## Fix Focus Areas
- tests/e2e/electron-process-flow.spec.ts[73-76]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive Playwright Electron end-to-end tests, significantly enhancing the test coverage for the application's core process flow. The setup for isolating user data and project directories per test is excellent, ensuring deterministic and reliable test runs. The new npm scripts and Playwright configuration are well-integrated, and the documentation updates in tests/catalog.md are clear and helpful. Overall, this is a robust and well-executed addition to the testing suite.
|
Addressed the actionable review points in latest commit ():
Re-running CI now. |
|
Addressed the actionable review points in latest commit (
Re-running CI now. |
|



Summary
tests/e2eELECTRON_USER_DATA_PATHto prevent cross-test state bleedtests/catalog.mdWhy
This adds deterministic, full-process coverage in a self-contained app context, closes major gaps around true end-to-end processing behavior, and hardens CI signal beyond screenshot-only checks.
Validation
npm run lintnpm test -- --runInBandnpm run qa:screenshotnpm run e2e:playwrightAll commands passed locally.
Summary by Sourcery
Add Playwright-based Electron end-to-end test coverage for the full application process flow and wire it into local tooling and CI.
New Features:
Enhancements:
CI:
Tests:
Summary by CodeRabbit
New Features
Tests
Chores