Skip to content

Commit 0977c68

Browse files
committed
Refine test ESLint envs, split RCE/tasks, add ts-mockito types
- Scope Mocha to all tests; Node only for desktop; Browser only for web - Simplify ESLint test globs; keep common mocha override for non-env tests - Split tasks_and_rce into tasks.simple and rce.simple; update web/desktop indices - Add minimal ts-mockito ambient types (anyString, spy, capture.) with rationale - Fix utils.test type errors; remove old combined test
1 parent c7d1225 commit 0977c68

8 files changed

Lines changed: 82 additions & 48 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ jobs:
2929
- name: Cache VS Code test downloads
3030
uses: actions/cache@v4
3131
with:
32-
key: neuropilot-tests-vscode-v2-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
32+
key: neuropilot-tests-vscode-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
3333
restore-keys: |
34-
neuropilot-tests-vscode-v2-${{ github.repository }}-${{ runner.os }}-
34+
neuropilot-tests-vscode-${{ github.repository }}-${{ runner.os }}-
3535
path: .vscode-test/
3636
- name: Setup pnpm
3737
uses: pnpm/action-setup@v4
@@ -50,8 +50,6 @@ jobs:
5050
- name: Run desktop tests (macOS/Windows)
5151
run: pnpm run test:desktop
5252
if: runner.os != 'Linux'
53-
# for now we'll stop with this
54-
# VSC-NeuroPilot/actions/send-test-repo-action will be added later
5553

5654
web-tests:
5755
name: Web tests (browser matrix)
@@ -89,16 +87,3 @@ jobs:
8987
run: pnpm run build:web && pnpm run test:web:browser:esbuild
9088
- name: Run web tests (headless)
9189
run: pnpm exec vscode-test-web --headless --browser=${{ matrix.browser }} --extensionDevelopmentPath=. --extensionTestsPath=out/web/test/browser.js test-playground
92-
#test-web:
93-
# name: Web tests
94-
# strategy:
95-
# fail-fast: false
96-
# matrix:
97-
# include:
98-
# - engine: webkit
99-
# browser: Safari
100-
# - engine: firefox
101-
# browser: Firefox
102-
# - engine: chromium
103-
# browser: Chrome
104-
# runs-on: ubuntu-latest

eslint.config.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,30 @@ export default tseslint.config(
9797
},
9898
{
9999
files: ['src/test/**/*.ts'],
100+
languageOptions: {
101+
globals: {
102+
...globals.mocha,
103+
},
104+
},
105+
},
106+
{
107+
files: ['src/test/suite/desktop/**/*.ts', 'src/test/test_utils.ts'],
100108
languageOptions: {
101109
globals: {
102110
...globals.node,
103111
...globals.mocha,
104112
},
105113
},
106114
},
115+
{
116+
files: ['src/test/suite/web/**/*.ts'],
117+
languageOptions: {
118+
globals: {
119+
...globals.browser,
120+
...globals.mocha,
121+
},
122+
},
123+
},
107124
{
108125
files: ['**/*.{js,mjs,cjs}', 'eslint.config.mjs', 'esbuild.mjs', '**/*.esbuild.{m,c,}js'],
109126
plugins: {

src/test/suite/desktop/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import '../../unit-test/place_cursor.simple.test';
2222
import '../../unit-test/replace_text.simple.test';
2323
import '../../unit-test/rewrite_all.simple.test';
2424
import '../../unit-test/rewrite_lines.simple.test';
25-
import '../../unit-test/tasks_and_rce.simple.test';
25+
import '../../unit-test/tasks.simple.test';
26+
import '../../unit-test/rce.simple.test';
2627
import '../../unit-test/terminal.simple.test';
2728
import '../../unit-test/undo_and_save.simple.test';
2829

src/test/suite/web/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import '../../unit-test/place_cursor.simple.test';
3535
import '../../unit-test/replace_text.simple.test';
3636
import '../../unit-test/rewrite_all.simple.test';
3737
import '../../unit-test/rewrite_lines.simple.test';
38-
import '../../unit-test/tasks_and_rce.simple.test';
38+
import '../../unit-test/tasks.simple.test';
39+
import '../../unit-test/rce.simple.test';
3940
import '../../unit-test/undo_and_save.simple.test';
4041

4142
// Testing the meta stuff
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as assert from 'assert';
2+
import { cancelRequestAction } from '@/rce';
3+
4+
// Tests for RCE action prompt generators using real logic
5+
suite('rce Actions', () => {
6+
test('cancel_request has empty prompt', () => {
7+
// === Arrange & Act ===
8+
const prompt = (cancelRequestAction.promptGenerator as () => string)();
9+
10+
// === Assert ===
11+
assert.ok(typeof prompt === 'string');
12+
assert.strictEqual(prompt.length, 0);
13+
});
14+
});
15+
16+
17+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as assert from 'assert';
2+
import { taskHandlers } from '@/tasks';
3+
4+
// Tests for tasks action prompt generators using real logic
5+
suite('tasks Actions', () => {
6+
test('terminate_task fixed prompt', () => {
7+
// === Arrange & Act ===
8+
const prompt = taskHandlers.terminate_task.promptGenerator as string;
9+
10+
// === Assert ===
11+
assert.ok(typeof prompt === 'string' && prompt.length > 0);
12+
});
13+
});
14+
15+
16+

src/test/unit-test/tasks_and_rce.simple.test.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/types/ts-mockito.d.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
// Minimal ambient declarations for ts-mockito to satisfy type-checking in tests
1+
/*
2+
Minimal ambient declarations for ts-mockito to satisfy type-checking in tests
3+
Why this exists:
4+
- ts-mockito ships its own type definitions, but our web test TypeScript config
5+
(see test-tsconfigs/tsconfig.web.json) targets WebWorker libs and intentionally
6+
omits Node types. The official ts-mockito typings may pull in Node types, which
7+
would force us to enable `node` types/globals for web tests.
8+
- Enabling Node types in the web config is undesirable, since it pollutes the
9+
browser-targeted environment with Node globals.
10+
11+
This ambient declaration only exposes the subset of ts-mockito APIs we use with
12+
permissive types. It keeps both desktop and web test builds type-clean without
13+
adding Node typings to the web configuration.
14+
15+
If you remove this file, consider either:
16+
- adding `node` to `types` in test-tsconfigs/tsconfig.web.json; or
17+
- excluding ts-mockito-dependent tests from the web runner.
18+
*/
219
declare module 'ts-mockito' {
320
export function mock<T>(clazz?: new (...args: any[]) => T): T;
421
export function instance<T>(mocked: T): T;
522
export function verify<T>(value: any): any;
6-
export function capture<T>(value: any): { last(): [any, ...any[]] };
23+
export function capture<T>(value: any): {
24+
first(): [any, ...any[]];
25+
second(): [any, ...any[]];
26+
third(): [any, ...any[]];
27+
last(): [any, ...any[]];
28+
};
729
export function anything(): any;
30+
export function anyString(): string;
31+
export function spy<T>(instance: T): T;
832
export function reset<T>(mocked: T): void;
933
}
10-
11-

0 commit comments

Comments
 (0)