Skip to content

Commit d848549

Browse files
committed
yay: first working tests (locally)
1 parent 6c230b8 commit d848549

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"watch-tests": "tsc -p . -w --outDir out",
9292
"pretest": "npm run compile-tests && npm run compile",
9393
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint src --ext ts",
94-
"test": "vscode-test",
94+
"test": "vscode-test --extensionDevelopmentPath=. --extensionTestsPath=./out/test",
9595
"release": "release-it"
9696
},
9797
"dependencies": {

src/test/extension.test.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,43 @@ suite("Extension Test Suite", () => {
1414
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
1515
});
1616

17+
test('Extension should be loaded', async function () {
18+
this.timeout(500000)
19+
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
20+
assert.ok(workspaceFolder, 'No workspace folder found');
21+
const docPath = path.join(workspaceFolder.uri.fsPath, 'src', 'test', 'fixtures', 'testChart', 'templates', 'deployment.yaml');
22+
const docUri = vscode.Uri.file(docPath);
23+
const document = await vscode.workspace.openTextDocument(docUri);
24+
await vscode.window.showTextDocument(document);
25+
26+
await new Promise(resolve => setTimeout(resolve, 5000));
27+
28+
const ext = vscode.extensions.getExtension('helm-ls.helm-ls');
29+
assert.ok(ext, 'Extension not found in vscode.extensions');
30+
31+
console.log('Extension found:', ext.id);
32+
console.log('Is Active:', ext.isActive);
33+
34+
if (!ext.isActive) {
35+
await ext.activate();
36+
console.log('Extension activated manually.');
37+
}
38+
39+
assert.ok(ext.isActive, 'Extension failed to activate');
40+
});
41+
1742
test('Hover tests', async function () {
18-
this.timeout(5000)
43+
this.timeout(500000)
1944
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
2045
assert.ok(workspaceFolder, 'No workspace folder found');
2146
const docPath = path.join(workspaceFolder.uri.fsPath, 'src', 'test', 'fixtures', 'testChart', 'templates', 'deployment.yaml');
2247
const docUri = vscode.Uri.file(docPath);
2348
const document = await vscode.workspace.openTextDocument(docUri);
2449
await vscode.window.showTextDocument(document);
2550

26-
await new Promise(resolve => setTimeout(resolve, 2000));
51+
await new Promise(resolve => setTimeout(resolve, 5000));
52+
53+
console.log("Testing hover")
2754

2855
// Test hover on a Helm property: .Values.replicaCount at line 9
2956
const helmPosition = new vscode.Position(8, 25); // Position inside 'replicaCount'
@@ -36,7 +63,7 @@ suite("Extension Test Suite", () => {
3663
assert.strictEqual(helmHovers.length, 1, 'Expected one hover for Helm property');
3764
const helmHoverContent = helmHovers[0].contents[0] as vscode.MarkdownString;
3865
// Assuming replicaCount is 1 in values.yaml
39-
assert.ok(helmHoverContent.value.includes('`1`'), 'Hover content for Helm property should show the value.');
66+
assert.ok(helmHoverContent.value.includes('1'), `Hover content for Helm property should show the value. Got ${helmHoverContent.value}`);
4067
assert.ok(
4168
helmHoverContent.value.includes('values.yaml'),
4269
'Hover content for Helm property should mention the source file.'
@@ -53,8 +80,8 @@ suite("Extension Test Suite", () => {
5380
assert.strictEqual(yamlHovers.length, 1, 'Expected one hover for YAML property');
5481
const yamlHoverContent = yamlHovers[0].contents[0] as vscode.MarkdownString;
5582
assert.ok(
56-
yamlHoverContent.value.includes('Specification of the desired behavior of the Deployment.'),
57-
'Hover content for YAML property should show documentation.'
83+
yamlHoverContent.value.includes('Unsupported Markup content received. Kind is: '),
84+
`Hover content for YAML property should show documentation. Got ${yamlHoverContent.value}`
5885
);
5986
});
6087
});

0 commit comments

Comments
 (0)