Add functional test coverage and combined test runner#2
Conversation
Agent-Logs-Url: https://github.com/Edward-lyz/nexus-workspace/sessions/0672c178-4353-4190-8e32-4de6cdfa92bf Co-authored-by: Edward-lyz <65755881+Edward-lyz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Edward-lyz/nexus-workspace/sessions/0672c178-4353-4190-8e32-4de6cdfa92bf Co-authored-by: Edward-lyz <65755881+Edward-lyz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a unified workflow for running frontend (Vitest/jsdom) and backend (Zig) tests, plus new functional coverage around frontend startup/dispatch flows and backend persistence/PTY helpers.
Changes:
- Add Vitest configuration, test setup/reset helpers, and several new frontend functional tests (startup hydration/dispatch + key UI dialogs).
- Add Zig test entrypoint (
src/test_main.zig) and new Zig tests for DB persistence and PTY env helpers; updatebuild.zigto run them. - Add
tests/run-functional-tests.shand document the combined test workflow; fixTaskDialogto await task creation before summarization.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/run-functional-tests.sh | Adds a single script to run frontend Vitest suite then Zig tests. |
| src/test_main.zig | New Zig test root that imports modules containing test blocks. |
| src/pty.zig | Extracts PATH/command/login argv0 builders + adds unit tests for them. |
| src/db.zig | Refactors DB open path handling and adds persistence-focused tests. |
| build.zig | Switches zig build test to use src/test_main.zig and links util for PTY tests. |
| README.md | Documents running frontend tests, Zig tests, and combined runner. |
| frontend/vite.config.ts | Configures Vitest (jsdom + setup file + restoreMocks). |
| frontend/src/test/setup.ts | Global Vitest setup (matchMedia + store reset + mock/timer cleanup). |
| frontend/src/test/helpers.ts | Adds a helper to reset store/DOM/localStorage between tests. |
| frontend/src/store.test.ts | Adds tests for hydration + auto-dispatch startup behavior. |
| frontend/src/components/TaskDialog.tsx | Awaits persisted task creation before triggering AI summarize + closes dialog safely. |
| frontend/src/components/*.test.tsx | Adds functional tests for multiple key UI components. |
| frontend/package.json | Adds Vitest/jsdom/testing-library scripts and devDependencies. |
| frontend/package-lock.json | Locks new test-related dependencies. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
frontend/src/components/TaskDialog.tsx:26
createTask(...)returns aTaskEntity | null, but the variable is namedpane, which makes the code harder to follow (especially since there is also aPaneStateconcept in the store). Renaming this variable (e.g., totask) would better reflect what it contains and reduce confusion.
const pane = await createTask(title, '...', priority);
onClose();
if (pane) {
// Fire-and-forget — result comes back via ai.result broadcast in app.tsx
ipc.call('ai.summarize', {
prompt: title,
pane_id: pane.id,
}).catch(() => {});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const extended_path = buildExtendedPath(allocator, home, current_path) catch std.posix.exit(1); | ||
| defer allocator.free(extended_path); | ||
| _ = setenv("PATH", extended_path, 1); |
There was a problem hiding this comment.
buildExtendedPath(...) catch std.posix.exit(1) changes behavior from the previous fallback (keeping the inherited PATH when allocation fails) to hard-exiting the child process. Consider restoring the prior fallback to current_path (or otherwise propagating/handling the error) so low-memory conditions don’t prevent spawning a PTY altogether.
| const extended_path = buildExtendedPath(allocator, home, current_path) catch std.posix.exit(1); | |
| defer allocator.free(extended_path); | |
| _ = setenv("PATH", extended_path, 1); | |
| const extended_path = buildExtendedPath(allocator, home, current_path) catch null; | |
| defer if (extended_path) |path| allocator.free(path); | |
| if (extended_path) |path| { | |
| _ = setenv("PATH", path, 1); | |
| } else { | |
| _ = setenv("PATH", current_path, 1); | |
| } |
Summary
src/test_main.zigentrypointtests/run-functional-tests.shrunner, document the workflow, and fix TaskDialog summary dispatch to await task creationValidation
npm run --prefix frontend test:runnpm run --prefix frontend buildbash -n tests/run-functional-tests.shzig build testcould not be run here because Zig is not installed in the sandbox