Skip to content

Add functional test coverage and combined test runner#2

Merged
Edward-lyz merged 2 commits into
mainfrom
copilot/create-test-scripts-directory
Apr 9, 2026
Merged

Add functional test coverage and combined test runner#2
Edward-lyz merged 2 commits into
mainfrom
copilot/create-test-scripts-directory

Conversation

Copilot AI commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Vitest-based frontend functional coverage for startup hydration/dispatch flows and key button interactions
  • add Zig-side persistence and PTY environment helper tests plus a dedicated src/test_main.zig entrypoint
  • add a combined tests/run-functional-tests.sh runner, document the workflow, and fix TaskDialog summary dispatch to await task creation

Validation

  • npm run --prefix frontend test:run
  • npm run --prefix frontend build
  • bash -n tests/run-functional-tests.sh
  • zig build test could not be run here because Zig is not installed in the sandbox

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>
Copilot AI requested a review from Edward-lyz April 9, 2026 06:32
@Edward-lyz Edward-lyz marked this pull request as ready for review April 9, 2026 06:46
Copilot AI review requested due to automatic review settings April 9, 2026 06:46
@Edward-lyz Edward-lyz merged commit 9f905f0 into main Apr 9, 2026
3 checks passed
@Edward-lyz Edward-lyz deleted the copilot/create-test-scripts-directory branch April 9, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; update build.zig to run them.
  • Add tests/run-functional-tests.sh and document the combined test workflow; fix TaskDialog to 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 a TaskEntity | null, but the variable is named pane, which makes the code harder to follow (especially since there is also a PaneState concept in the store). Renaming this variable (e.g., to task) 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.

Comment thread src/pty.zig
Comment on lines +72 to 74
const extended_path = buildExtendedPath(allocator, home, current_path) catch std.posix.exit(1);
defer allocator.free(extended_path);
_ = setenv("PATH", extended_path, 1);

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants