-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivation.test.ts
More file actions
106 lines (99 loc) · 3.87 KB
/
activation.test.ts
File metadata and controls
106 lines (99 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Integration tests booted by @vscode/test-electron. These run inside
// a real extension host, so `vscode` is the genuine namespace — no
// stubs, no vi.mock. The unit-test suite (vitest, src/*.test.ts)
// covers pure logic; this file covers the contracts that only a live
// VS Code can verify: extension activation, command registration,
// view registration, configuration schema correctness.
//
// The workspace under test is `test-fixtures/sample-workflow/` (set
// in .vscode-test.mjs). Opening it triggers our `workspaceContains:`
// activation event because of the `.github/workflows/*.yml` fixture
// inside.
import assert from "node:assert";
import * as vscode from "vscode";
const EXTENSION_ID = "greylag-ci.pipeline-check";
suite("Pipeline-Check — activation", () => {
test("extension is installed and activates", async function () {
// VS Code's first boot in a CI environment can be slow.
this.timeout(15000);
const ext = vscode.extensions.getExtension(EXTENSION_ID);
assert(ext, `extension ${EXTENSION_ID} not found`);
await ext.activate();
assert.strictEqual(ext.isActive, true, "extension failed to activate");
});
test("contributes every command declared in package.json", async () => {
const ext = vscode.extensions.getExtension(EXTENSION_ID);
assert(ext);
await ext.activate();
const registered = await vscode.commands.getCommands(true);
const expected = [
"pipelineCheck.restart",
"pipelineCheck.showLog",
"pipelineCheck.copyInstallCommand",
"pipelineCheck.scanWorkspace",
"pipelineCheck.findings.refresh",
"pipelineCheck.findings.changeGrouping",
"pipelineCheck.findings.copyRuleId",
"pipelineCheck.findings.openRuleDocs",
"pipelineCheck.goToNextFinding",
"pipelineCheck.goToPreviousFinding",
];
for (const cmd of expected) {
assert.ok(
registered.includes(cmd),
`command ${cmd} did not register`,
);
}
});
test("Findings view is registered under the Pipeline-Check container", async () => {
const ext = vscode.extensions.getExtension(EXTENSION_ID);
assert(ext);
await ext.activate();
// VS Code's `<viewId>.focus` command is auto-generated for every
// registered view. The presence of the command is a proxy for
// "the view registered" without needing private API.
const registered = await vscode.commands.getCommands(true);
assert.ok(
registered.includes("pipelineCheck.findings.focus"),
"Findings view did not register (pipelineCheck.findings.focus missing)",
);
});
test("configuration schema exposes every documented setting", async () => {
const ext = vscode.extensions.getExtension(EXTENSION_ID);
assert(ext);
await ext.activate();
const config = vscode.workspace.getConfiguration("pipelineCheck");
// `inspect` returns metadata about a setting; defaults from the
// package.json schema flow through this API. Used here as a
// smoke-test that the manifest contributions deserialised.
for (const key of [
"serverCommand",
"serverArgs",
"severityThreshold",
"disabledProviders",
"trace.server",
]) {
const info = config.inspect(key);
assert.ok(
info !== undefined,
`setting pipelineCheck.${key} is not in the schema`,
);
}
});
test("untrustedWorkspaces capability is declared as 'limited'", () => {
const ext = vscode.extensions.getExtension(EXTENSION_ID);
assert(ext);
const caps = ext.packageJSON.capabilities;
assert.ok(caps, "capabilities block missing from package.json");
assert.strictEqual(
caps.untrustedWorkspaces?.supported,
"limited",
"untrustedWorkspaces.supported is not 'limited'",
);
assert.strictEqual(
caps.virtualWorkspaces,
false,
"virtualWorkspaces should be false (extension spawns a child process)",
);
});
});