Skip to content

Commit 878a79b

Browse files
committed
tests: Add comprehensive test suite for JS/TS inline values
- Add JavaScript, TypeScript, and TSX inline values tests to debugger_ui - Add Playwright E2E test suite (20+ test cases) - Add Cucumber BDD scenarios (15 scenarios in French) - Add Jest unit tests with tree-sitter mocks - Add test utilities and configuration Test coverage includes: - Variables (const, let, var) - Function parameters and arrow functions - Rest parameters - Object and array destructuring - Loops (for, for-in, for-of) - Try-catch blocks - Nested scopes - Classes and methods - Async/await
1 parent 3daf28e commit 878a79b

19 files changed

+2708
-1
lines changed

crates/debugger_ui/src/tests/inline_values.rs

Lines changed: 264 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use std::{path::Path, sync::Arc};
33
use dap::{Scope, StackFrame, Variable, requests::Variables};
44
use editor::{Editor, EditorMode, MultiBuffer};
55
use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext};
6-
use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_python, tree_sitter_rust};
6+
use language::{
7+
Language, LanguageConfig, LanguageMatcher, tree_sitter_python, tree_sitter_rust,
8+
tree_sitter_typescript,
9+
};
710
use project::{FakeFs, Project};
811
use serde_json::json;
912
use unindent::Unindent as _;
@@ -2272,3 +2275,263 @@ fn main() {
22722275
)
22732276
.await;
22742277
}
2278+
2279+
fn javascript_lang() -> Language {
2280+
let debug_variables_query = include_str!("../../../languages/src/javascript/debugger.scm");
2281+
Language::new(
2282+
LanguageConfig {
2283+
name: "JavaScript".into(),
2284+
matcher: LanguageMatcher {
2285+
path_suffixes: vec!["js".to_string()],
2286+
..Default::default()
2287+
},
2288+
..Default::default()
2289+
},
2290+
Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()),
2291+
)
2292+
.with_debug_variables_query(debug_variables_query)
2293+
.unwrap()
2294+
}
2295+
2296+
fn typescript_lang() -> Language {
2297+
let debug_variables_query = include_str!("../../../languages/src/typescript/debugger.scm");
2298+
Language::new(
2299+
LanguageConfig {
2300+
name: "TypeScript".into(),
2301+
matcher: LanguageMatcher {
2302+
path_suffixes: vec!["ts".to_string()],
2303+
..Default::default()
2304+
},
2305+
..Default::default()
2306+
},
2307+
Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()),
2308+
)
2309+
.with_debug_variables_query(debug_variables_query)
2310+
.unwrap()
2311+
}
2312+
2313+
fn tsx_lang() -> Language {
2314+
let debug_variables_query = include_str!("../../../languages/src/tsx/debugger.scm");
2315+
Language::new(
2316+
LanguageConfig {
2317+
name: "TSX".into(),
2318+
matcher: LanguageMatcher {
2319+
path_suffixes: vec!["tsx".to_string()],
2320+
..Default::default()
2321+
},
2322+
..Default::default()
2323+
},
2324+
Some(tree_sitter_typescript::LANGUAGE_TSX.into()),
2325+
)
2326+
.with_debug_variables_query(debug_variables_query)
2327+
.unwrap()
2328+
}
2329+
2330+
#[gpui::test]
2331+
async fn test_javascript_inline_values(executor: BackgroundExecutor, cx: &mut TestAppContext) {
2332+
let variables = [
2333+
("x", "10"),
2334+
("y", "20"),
2335+
("sum", "30"),
2336+
("message", "Hello"),
2337+
];
2338+
2339+
let before = r#"
2340+
function calculate() {
2341+
const x = 10;
2342+
const y = 20;
2343+
const sum = x + y;
2344+
const message = "Hello";
2345+
console.log(message, "Sum:", sum);
2346+
}
2347+
"#
2348+
.unindent();
2349+
2350+
let after = r#"
2351+
function calculate() {
2352+
const x: 10 = 10;
2353+
const y: 20 = 20;
2354+
const sum: 30 = x: 10 + y: 20;
2355+
const message = "Hello";
2356+
console.log(message, "Sum:", sum);
2357+
}
2358+
"#
2359+
.unindent();
2360+
2361+
test_inline_values_util(
2362+
&variables,
2363+
&[],
2364+
&before,
2365+
&after,
2366+
None,
2367+
javascript_lang(),
2368+
executor,
2369+
cx,
2370+
)
2371+
.await;
2372+
}
2373+
2374+
#[gpui::test]
2375+
async fn test_typescript_inline_values(
2376+
executor: BackgroundExecutor,
2377+
cx: &mut TestAppContext,
2378+
) {
2379+
let variables = [
2380+
("count", "42"),
2381+
("name", "Alice"),
2382+
("result", "84"),
2383+
("i", "3"),
2384+
];
2385+
2386+
let before = r#"
2387+
function processData(count: number, name: string): number {
2388+
let result = count * 2;
2389+
for (let i = 0; i < 5; i++) {
2390+
console.log(i);
2391+
}
2392+
return result;
2393+
}
2394+
"#
2395+
.unindent();
2396+
2397+
let after = r#"
2398+
function processData(count: 42: number, name: Alice: string): number {
2399+
let result: 84 = count: 42 * 2;
2400+
for (let i: 3 = 0; i: 3 < 5; i: 3++) {
2401+
console.log(i: 3);
2402+
}
2403+
return result: 84;
2404+
}
2405+
"#
2406+
.unindent();
2407+
2408+
test_inline_values_util(
2409+
&variables,
2410+
&[],
2411+
&before,
2412+
&after,
2413+
None,
2414+
typescript_lang(),
2415+
executor,
2416+
cx,
2417+
)
2418+
.await;
2419+
}
2420+
2421+
#[gpui::test]
2422+
async fn test_tsx_inline_values(executor: BackgroundExecutor, cx: &mut TestAppContext) {
2423+
let variables = [("count", "5"), ("message", "Hello React")];
2424+
2425+
let before = r#"
2426+
const Counter = () => {
2427+
const count = 5;
2428+
const message = "Hello React";
2429+
return (
2430+
<div>
2431+
<p>{message}</p>
2432+
<span>{count}</span>
2433+
</div>
2434+
);
2435+
};
2436+
"#
2437+
.unindent();
2438+
2439+
let after = r#"
2440+
const Counter = () => {
2441+
const count: 5 = 5;
2442+
const message = "Hello React";
2443+
return (
2444+
<div>
2445+
<p>{message}</p>
2446+
<span>{count: 5}</span>
2447+
</div>
2448+
);
2449+
};
2450+
"#
2451+
.unindent();
2452+
2453+
test_inline_values_util(
2454+
&variables,
2455+
&[],
2456+
&before,
2457+
&after,
2458+
None,
2459+
tsx_lang(),
2460+
executor,
2461+
cx,
2462+
)
2463+
.await;
2464+
}
2465+
2466+
#[gpui::test]
2467+
async fn test_javascript_arrow_functions(
2468+
executor: BackgroundExecutor,
2469+
cx: &mut TestAppContext,
2470+
) {
2471+
let variables = [("x", "42"), ("result", "84")];
2472+
2473+
let before = r#"
2474+
const double = (x) => {
2475+
const result = x * 2;
2476+
return result;
2477+
};
2478+
"#
2479+
.unindent();
2480+
2481+
let after = r#"
2482+
const double = (x: 42) => {
2483+
const result: 84 = x: 42 * 2;
2484+
return result: 84;
2485+
};
2486+
"#
2487+
.unindent();
2488+
2489+
test_inline_values_util(
2490+
&variables,
2491+
&[],
2492+
&before,
2493+
&after,
2494+
None,
2495+
javascript_lang(),
2496+
executor,
2497+
cx,
2498+
)
2499+
.await;
2500+
}
2501+
2502+
#[gpui::test]
2503+
async fn test_typescript_for_in_loop(executor: BackgroundExecutor, cx: &mut TestAppContext) {
2504+
let variables = [("key", "name"), ("obj", "{name: 'test'}")];
2505+
2506+
let before = r#"
2507+
function iterate() {
2508+
const obj = {name: 'test'};
2509+
for (const key in obj) {
2510+
console.log(key);
2511+
}
2512+
}
2513+
"#
2514+
.unindent();
2515+
2516+
let after = r#"
2517+
function iterate() {
2518+
const obj: {name: 'test'} = {name: 'test'};
2519+
for (const key: name in obj: {name: 'test'}) {
2520+
console.log(key: name);
2521+
}
2522+
}
2523+
"#
2524+
.unindent();
2525+
2526+
test_inline_values_util(
2527+
&variables,
2528+
&[],
2529+
&before,
2530+
&after,
2531+
None,
2532+
typescript_lang(),
2533+
executor,
2534+
cx,
2535+
)
2536+
.await;
2537+
}

tests/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Tests - Zed Project
2+
3+
Ce répertoire contient les suites de tests pour le projet Zed.
4+
5+
## Structure
6+
7+
```
8+
tests/
9+
└── inline-values/ Tests pour les inline values JavaScript/TypeScript
10+
```
11+
12+
## Tests Inline Values
13+
14+
Suite de tests complète pour valider le fonctionnement des inline values dans le débogueur Zed pour JavaScript et TypeScript.
15+
16+
### Accès rapide
17+
18+
```bash
19+
cd tests/inline-values
20+
npm test
21+
```
22+
23+
### Documentation
24+
25+
- [Documentation complète](inline-values/README.md)
26+
- [Guide de démarrage](inline-values/QUICKSTART.md)
27+
- [Structure des tests](inline-values/STRUCTURE.md)
28+
- [Statut de l'installation](inline-values/STATUS.md)
29+
30+
### Frameworks de test
31+
32+
- **Playwright** - Tests end-to-end
33+
- **Cucumber** - Tests BDD avec Gherkin
34+
- **Jest** - Tests unitaires
35+
36+
### Commandes disponibles
37+
38+
```bash
39+
# Dans tests/inline-values/
40+
npm test # Tests unitaires
41+
npm run test:playwright # Tests E2E
42+
npm run test:cucumber # Tests BDD
43+
npm run test:all # Tous les tests
44+
```
45+
46+
## Ajouter de nouveaux tests
47+
48+
Pour ajouter une nouvelle suite de tests:
49+
50+
1. Créer un nouveau répertoire dans `tests/`
51+
2. Initialiser avec `npm init`
52+
3. Configurer vos frameworks de test
53+
4. Mettre à jour ce README
54+
55+
## CI/CD
56+
57+
Les tests peuvent être intégrés dans votre pipeline CI/CD. Voir la documentation de chaque suite de tests pour les détails.
58+
59+
---
60+
61+
**Dernière mise à jour**: 22 octobre 2025

tests/inline-values/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Dependencies
2+
node_modules/
3+
package-lock.json
4+
yarn.lock
5+
6+
# Test results
7+
test-results/
8+
playwright-report/
9+
cucumber-report.html
10+
cucumber-report.json
11+
*.log
12+
13+
# Playwright
14+
.playwright/
15+
playwright/.cache/
16+
17+
# Coverage
18+
coverage/
19+
.nyc_output/
20+
21+
# OS
22+
.DS_Store
23+
Thumbs.db
24+
25+
# IDE
26+
.vscode/
27+
.idea/
28+
*.swp
29+
*.swo
30+
*~
31+
32+
# Temporary files
33+
*.tmp
34+
tmp/
35+
temp/

0 commit comments

Comments
 (0)