Skip to content

Commit 868ec8d

Browse files
committed
Increase e2e test coverage
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent 2cf4d5d commit 868ec8d

File tree

9 files changed

+468
-275
lines changed

9 files changed

+468
-275
lines changed

test/vscode/extension.test.ts

Lines changed: 411 additions & 270 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{broken json
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "Schema with non-root lint issues",
4+
"description": "Triggers enum_with_type and enum_to_const at non-root positions",
5+
"examples": [
6+
{
7+
"status": "active"
8+
}
9+
],
10+
"type": "object",
11+
"properties": {
12+
"status": {
13+
"type": "string",
14+
"enum": [ "active" ]
15+
}
16+
}
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"title": "Unformatted schema",
5+
"description": "Keywords in wrong order for the formatter",
6+
"examples": [ {} ]
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "A valid test schema",
4+
"description": "This schema passes lint, metaschema, and format checks",
5+
"examples": [
6+
{
7+
"name": "test"
8+
}
9+
],
10+
"type": "object",
11+
"properties": {
12+
"name": {
13+
"title": "Name",
14+
"description": "The name field",
15+
"type": "string"
16+
}
17+
}
18+
}

test/vscode/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
"scripts": {
77
"compile": "tsc -p ./",
88
"pretest": "npm run compile",
9-
"test": "vscode-test",
10-
"test:headed": "vscode-test --headless=false",
11-
"test:watch": "vscode-test --watch"
9+
"test": "vscode-test"
1210
},
1311
"devDependencies": {
1412
"@types/chai": "^5.2.3",

vscode/src/diagnostics/DiagnosticManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class DiagnosticManager {
117117

118118
diagnostic.source = 'Sourcemeta Studio (Metaschema)';
119119

120-
if (error.instanceLocation) {
120+
if (error.instanceLocation !== undefined) {
121121
diagnostic.code = error.instanceLocation;
122122
}
123123

vscode/src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
5454
handleWebviewMessage(message);
5555
});
5656

57+
panelManager.setDisposeHandler(() => {
58+
diagnosticManager.clearAll();
59+
});
60+
5761
const openPanelCommand = vscode.commands.registerCommand('sourcemeta-studio.openPanel', () => {
5862
webviewReady = false;
5963
panelManager.createOrReveal(context);

vscode/src/panel/PanelManager.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class PanelManager {
1111
private readonly iconPath: vscode.Uri;
1212
private readonly extensionPath: string;
1313
private messageHandler?: (message: WebviewToExtensionMessage) => void;
14+
private disposeHandler?: () => void;
1415

1516
constructor(extensionPath: string) {
1617
this.extensionPath = extensionPath;
@@ -24,6 +25,10 @@ export class PanelManager {
2425
this.messageHandler = handler;
2526
}
2627

28+
setDisposeHandler(handler: () => void): void {
29+
this.disposeHandler = handler;
30+
}
31+
2732
/**
2833
* Create or reveal the panel
2934
*/
@@ -70,10 +75,12 @@ export class PanelManager {
7075
context.subscriptions
7176
);
7277

73-
// Handle panel disposal
7478
this.panel.onDidDispose(
7579
() => {
7680
this.panel = undefined;
81+
if (this.disposeHandler) {
82+
this.disposeHandler();
83+
}
7784
},
7885
null,
7986
context.subscriptions

0 commit comments

Comments
 (0)