You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* ai: coding standards for e2e tests
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: CODING_STANDARDS.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,47 @@ Remember, these rules are here to make our codebase harmonious. If something doe
59
59
60
60
- Tests should be fast enough to run continuously. Avoid long-running operations unless absolutely necessary; prefer lightweight fixtures and isolated units.
61
61
62
+
### E2E Tests
63
+
64
+
When reviewing Electron-specific Playwright tests, treat `<project-root>/tests/**` as the canonical location for specs, typically matching `<project-root>/tests/**/*.spec.{ts,js}`. For broader Playwright workflow guidance, also refer to `docs/playwright-testing-guide.md`.
65
+
66
+
Goal: rewrite or critique the tests so they are genuinely behavioural, maintainable, and safely parallelizable.
67
+
68
+
Rules:
69
+
1. Tests must verify user-visible behaviour, not implementation details.
70
+
- Prefer assertions on UI state, persisted data, windows, dialogs, filesystem effects, and app-level outcomes.
71
+
- Avoid hardcoded waits, brittle selectors, fake internal state checks, and “click then expect mock called” tests unless the user behaviour is the point.
72
+
73
+
2. Tests must be Electron-aware.
74
+
- Use Electron app launch patterns correctly.
75
+
- Handle main window, secondary windows, dialogs, menus, native prompts, clipboard, file pickers, and IPC-driven UI behaviour through observable outcomes.
76
+
- Do not reach into app internals unless absolutely necessary for setup or controlled test fixtures.
77
+
78
+
3. Tests must be parallel-safe.
79
+
- No shared user data directories.
80
+
- No shared ports, files, DBs, caches, clipboard assumptions, or global app state.
81
+
- Each test gets isolated temp paths, unique workspace/project names, and deterministic cleanup.
82
+
- Avoid test ordering assumptions.
83
+
84
+
4. No hardcoded mess.
85
+
- Replace magic timeouts with event-driven waits.
86
+
- Replace brittle text/index selectors with role, label, test id, or stable user-facing selectors.
87
+
- Replace duplicated setup with fixtures.
88
+
- Replace hardcoded absolute paths with temp dirs.
89
+
- Replace random sleeps with waiting for actual app signals.
90
+
91
+
5. Every test should follow this shape:
92
+
- Arrange: create isolated fixture state.
93
+
- Act: perform real user actions.
94
+
- Assert: verify observable behavioural outcome.
95
+
- Cleanup: remove isolated resources.
96
+
97
+
For each test file:
98
+
- Identify behavioural vs non-behavioural tests.
99
+
- Flag brittle selectors, hardcoded waits, shared state, serial dependencies, and fake assertions.
100
+
- Rewrite the tests using Playwright best practices for Electron.
0 commit comments