Skip to content

feat: improved testing#2377

Merged
RohitKushvaha01 merged 5 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:improve_testing
Jun 24, 2026
Merged

feat: improved testing#2377
RohitKushvaha01 merged 5 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:improve_testing

Conversation

@RohitKushvaha01

Copy link
Copy Markdown
Member

No description provided.

@RohitKushvaha01 RohitKushvaha01 merged commit de5cc70 into Acode-Foundation:main Jun 24, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jun 24, 2026
@RohitKushvaha01 RohitKushvaha01 deleted the improve_testing branch June 24, 2026 12:55
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the old terminal/ANSI-based test runner with a full in-editor dashboard UI (HTML/CSS, collapsible suite cards, live stats bar, progress bar) and adds two new test files — filesystem integration tests (fs.tests.js) and meta-tests for the runner itself (tester.tests.js).

  • tester.js is completely rewritten: test suites are now registered in a fast synchronous pass (isRegistrationPass), then executed via activeRunners, with per-test timing and real-time DOM updates.
  • test-definitions.js centralizes all suite imports into a single exported array, making it easy to add or remove suites.
  • ace.test.js switches session tests to use testFile.session directly with try/finally cleanup, removing reliance on the currently-active editor session.

Confidence Score: 3/5

The core runner rewrite works, but mock runners used in self-tests always inflate the global stats counters shown in the UI, so the displayed numbers are wrong every time the suite runs.

The register = false flag on mock TestRunner instances prevents them from appearing in the suite list, but test() still calls currentRunnerState.stats.total++ and executeSuite() still increments passed/failed/skipped on the global object unconditionally. Every run adds phantom counts to the stats bar that the user will see but cannot explain from the visible suite cards.

src/test/tester.js (global stats mutation in test() and executeSuite()) and src/test/tester.tests.js (mock runners that trigger the contamination).

Important Files Changed

Filename Overview
src/test/tester.js Major overhaul replacing terminal-based output with a full HTML/CSS dashboard UI; introduces module-level global state for the runner, but register = false runners still mutate global stats counters via test() and executeSuite().
src/test/ace.test.js Session tests now use testFile.session with try/finally cleanup (good); but the "editor.session exists" assertion was weakened from a null-check to an in-operator check that passes even when the property is null.
src/test/fs.tests.js New filesystem integration tests with proper try/finally cleanup; GBK encoding round-trip test may give a false positive if the platform silently falls back to UTF-8.
src/test/tester.tests.js New meta-tests for the TestRunner itself; mock runners use register = false to avoid polluting the suite list but inadvertently still pollute global stat counters.
src/test/test-definitions.js New file that centralizes all test suite imports into a single exported array; clean and straightforward.
src/test/sanity.tests.js Trivial whitespace change (blank line removed); no functional change.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant openTestRunnerTab
    participant registerAllSuites
    participant TestRunner
    participant runTestsInternal
    participant executeSuite

    User->>openTestRunnerTab: trigger
    openTestRunnerTab->>openTestRunnerTab: createTestRunnerContent() - build DOM
    openTestRunnerTab->>registerAllSuites: registerAllSuites()
    registerAllSuites->>registerAllSuites: "isRegistrationPass = true"
    loop each testDefinition
        registerAllSuites->>TestRunner: new TestRunner(name) - pushes to activeRunners
        TestRunner->>TestRunner: runner.test() x N - increments stats.total
        TestRunner->>TestRunner: runner.run(null) - returns immediately
    end
    registerAllSuites->>registerAllSuites: "isRegistrationPass = false"
    openTestRunnerTab->>runTestsInternal: runTestsInternal()
    runTestsInternal->>runTestsInternal: reset passed/failed/skipped to 0
    loop each activeRunner
        runTestsInternal->>executeSuite: runner.executeSuite(writeOutput)
        executeSuite->>executeSuite: run tests, update suiteState + global stats
        executeSuite->>executeSuite: updateUI() after each test
    end
    runTestsInternal->>openTestRunnerTab: "status = completed, updateUI()"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant openTestRunnerTab
    participant registerAllSuites
    participant TestRunner
    participant runTestsInternal
    participant executeSuite

    User->>openTestRunnerTab: trigger
    openTestRunnerTab->>openTestRunnerTab: createTestRunnerContent() - build DOM
    openTestRunnerTab->>registerAllSuites: registerAllSuites()
    registerAllSuites->>registerAllSuites: "isRegistrationPass = true"
    loop each testDefinition
        registerAllSuites->>TestRunner: new TestRunner(name) - pushes to activeRunners
        TestRunner->>TestRunner: runner.test() x N - increments stats.total
        TestRunner->>TestRunner: runner.run(null) - returns immediately
    end
    registerAllSuites->>registerAllSuites: "isRegistrationPass = false"
    openTestRunnerTab->>runTestsInternal: runTestsInternal()
    runTestsInternal->>runTestsInternal: reset passed/failed/skipped to 0
    loop each activeRunner
        runTestsInternal->>executeSuite: runner.executeSuite(writeOutput)
        executeSuite->>executeSuite: run tests, update suiteState + global stats
        executeSuite->>executeSuite: updateUI() after each test
    end
    runTestsInternal->>openTestRunnerTab: "status = completed, updateUI()"
Loading

Comments Outside Diff (2)

  1. src/test/tester.js, line 956-976 (link)

    P2 isRegistrationPass relies on all test registrations being synchronous

    registerAllSuites() calls each suite function without await and resets isRegistrationPass = false synchronously after the loop. This works correctly today because every suite creates its TestRunner and calls all runner.test(...) invocations before its first await runner.run(). However, if any future suite adds an await before a runner.test() call (e.g., for async setup), those test registrations will execute after isRegistrationPass is already false, causing them to be silently absent from the suite list and from activeRunners. A short comment documenting this constraint would prevent the footgun.

  2. src/test/fs.tests.js, line 303-312 (link)

    P2 GBK encoding test may silently pass with wrong data on unsupported platforms

    Android's TextDecoder / TextEncoder does not guarantee GBK support. If the underlying filesystem implementation falls back to UTF-8 when GBK is requested, both the write and subsequent read will use UTF-8, so the round-trip comparison "Hello 世界 (GBK)" will still match, giving a false-positive pass. Consider adding an assertion that the raw byte count differs from a UTF-8 encoding to prove the codec was actually used, or document that GBK support is a prerequisite for this test to be meaningful.

Reviews (1): Last reviewed commit: "format" | Re-trigger Greptile

Comment thread src/test/tester.js
Comment thread src/test/ace.test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant