Skip to content

Conversation

@Avni2000
Copy link
Owner

@Avni2000 Avni2000 commented Feb 8, 2026

  • Created registry.ts to manage test definitions and groups for better organization and selection.
  • Extracted repo setup logic into repoSetup.ts for reusable temporary git repository creation.
  • Enhanced runIntegrationTest.ts to support interactive TUI picker and CLI flags for test execution.

Summary by CodeRabbit

  • New Features

    • Interactive test selector (TUI) to pick/all/group/individual integration tests; added --list to view tests
  • Tests

    • Reworked integration test runner and registry for grouped tests, per-test results, summaries, and cleanup
    • Added utilities to create temporary test repos and configs; removed legacy test-case interface
  • Documentation

    • Expanded integration-testing guide with commands, test groups, and available fixtures
  • Chores

    • Updated CI step to run the new integration test command; added npm scripts and dev tooling dependencies

- Created registry.ts to manage test definitions and groups for better organization and selection.
- Extracted repo setup logic into repoSetup.ts for reusable temporary git repository creation.
- Enhanced runIntegrationTest.ts to support interactive TUI picker and CLI flags for test execution.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Replaces the legacy test runner with a CLI/TUI-driven integration test runner, adds a test registry and repo-setup utilities, updates CI and npm scripts to run integration tests, expands AGENTS.md testing docs, and removes the old TestCaseDefinition interface.

Changes

Cohort / File(s) Summary
CI Workflow & Scripts
.github/workflows/vscode-integration-test.yml, package.json
CI step updated to run npm run test:integration:all; removed test:vscode; added integration scripts (pretest:integration*, test:integration*) and devDependencies (@clack/prompts, picocolors).
Documentation
AGENTS.md
Expanded Testing section with integration-test guide, CLI/Node runner examples, key test files list, and notebook fixtures; replaced Git execution_count note with nbdime note.
Test Registry
src/tests/registry.ts
New test registry: TestDef, TestGroup, TEST_GROUPS, and helpers (allTests, findTest, findGroup, resolveTests) to define and resolve groups/tests.
Repo Setup Utilities
src/tests/repoSetup.ts
Added repo utilities: createMergeConflictRepo, writeTestConfig, and cleanup to build temp repos with three-way notebook conflicts.
Integration Test Runner
src/tests/runIntegrationTest.ts
Major rewrite to CLI/TUI runner: arg parsing (--all, --group, --test, --list), interactive picker (lazy-loaded), runTest/runAll, structured RunResult, centralized error handling, and aggregated summary output.
Test Helpers
src/tests/testHelpers.ts
Removed exported TestCaseDefinition interface (legacy test-case shape removed).

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as CLI/TUI
    participant Registry as Test Registry
    participant Runner as Test Runner
    participant RepoSetup as Repo Setup
    participant VSCode as VS Code Tests

    User->>CLI: invoke runner (flags or interactive)
    CLI->>Registry: request available groups/tests
    Registry-->>CLI: return TEST_GROUPS / allTests
    CLI->>User: show picker or accept flags
    User->>CLI: select tests/groups
    CLI->>Runner: runAll(selectedTests)

    loop per test
        Runner->>Registry: findTest(testId)
        Registry-->>Runner: return TestDef
        Runner->>RepoSetup: createMergeConflictRepo(...)
        RepoSetup-->>Runner: repo path
        Runner->>RepoSetup: writeTestConfig(repoPath,...)
        Runner->>VSCode: execute testModule with workspace
        VSCode-->>Runner: result (pass/fail, duration)
        Runner->>RepoSetup: cleanup(repoPath)
    end

    Runner-->>CLI: aggregated summary (durations, failures)
    CLI->>User: display results
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I dug a hole in code today,

registry seeds in tidy rows,
TUI prompts hop, selecting play,
repos sprout where conflicts grow,
tests run, I nibble on my prose.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: refactoring the integration test structure and fixing CLI functionality, which aligns with the PR's core objectives of creating registry.ts, extracting repoSetup.ts, and enhancing runIntegrationTest.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-test-runner

No actionable comments were generated in the recent review. 🎉

Tip

We've launched Issue Planner and it is currently in beta. Please try it out and share your feedback on Discord!


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@AGENTS.md`:
- Around line 46-59: The README contains a broken fenced code block: an extra
closing ``` prematurely ends the first bash block after the line containing
"node out/tests/runIntegrationTest.js --list", which leaves the subsequent lines
unformatted; fix by removing that stray closing backtick so the block beginning
with "```bash" includes all listed commands through the final "npm run
test:integration -- --group perCell --group undoRedo" and end the block once
with a single closing ``` (keep the language tag 'bash' and ensure the final
closing fence is present).

In `@src/tests/repoSetup.ts`:
- Around line 16-23: The git() helper currently swallows all errors which masks
real failures; modify git(cwd: string, ...args: string[]) to accept an optional
tolerateFailure boolean (default false) and only return error.stdout when
tolerateFailure is true (used for expected failing commands like 'merge'); for
other failures throw or log the error (e.g., rethrow the error or call
console.warn/processLogger) so callers like createMergeConflictRepo explicitly
call git(..., true) for merges while other git operations fail loudly.
🧹 Nitpick comments (3)
src/tests/repoSetup.ts (2)

73-82: Fixed config path creates a shared-state coupling between test runs.

writeTestConfig always writes to the same mergenb-test-config.json in os.tmpdir(). If two runner processes are invoked concurrently (e.g., local dev + CI, or a future parallel mode), they'll clobber each other's config. Consider using a unique filename per invocation (e.g., include the test id or a random suffix).

Suggested: use a unique temp file
 export function writeTestConfig(
     workspacePath: string,
     testName: string,
     params?: Record<string, unknown>,
 ): string {
-    const configPath = path.join(os.tmpdir(), 'mergenb-test-config.json');
+    const configPath = path.join(os.tmpdir(), `mergenb-test-config-${testName}-${Date.now()}.json`);
     fs.writeFileSync(configPath, JSON.stringify({ workspacePath, testName, params }));
     return configPath;
 }

85-93: cleanup can be simplified — fs.rmSync with recursive + force handles both files and directories.

The statSync → branch is unnecessary since Node.js fs.rmSync({ recursive: true, force: true }) works on files, directories, and non-existent paths alike.

Simplified version
 export function cleanup(dirOrFile: string): void {
     try {
-        const stat = fs.statSync(dirOrFile);
-        if (stat.isDirectory()) {
-            fs.rmSync(dirOrFile, { recursive: true, force: true });
-        } else {
-            fs.unlinkSync(dirOrFile);
-        }
+        fs.rmSync(dirOrFile, { recursive: true, force: true });
     } catch { /* ignore */ }
 }
src/tests/registry.ts (1)

130-154: Silent drop of unrecognized IDs may confuse users.

resolveTests silently ignores IDs that match neither a group nor a test. While the runner catches the empty-result case, a partially-valid input like --group takeAll --group typo would silently drop "typo" and run only takeAll without warning. Consider logging or collecting unmatched IDs so the runner can surface them.

Suggested: return or report unmatched IDs
-export function resolveTests(ids: string[]): TestDef[] {
+export function resolveTests(ids: string[]): { tests: TestDef[]; unmatched: string[] } {
     const result: TestDef[] = [];
     const seen = new Set<string>();
+    const unmatched: string[] = [];

     for (const id of ids) {
         const group = findGroup(id);
         if (group) {
             for (const t of group.tests) {
                 if (!seen.has(t.id)) {
                     result.push(t);
                     seen.add(t.id);
                 }
             }
             continue;
         }
         const test = findTest(id);
         if (test && !seen.has(test.id)) {
             result.push(test);
             seen.add(test.id);
+        } else if (!test) {
+            unmatched.push(id);
         }
     }

-    return result;
+    return { tests: result, unmatched };
 }

@Avni2000 Avni2000 merged commit 6b18545 into main Feb 10, 2026
3 checks passed
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.

1 participant