Skip to content

Commit 8c1b18b

Browse files
committed
fix: cleanup
1 parent 8b89605 commit 8c1b18b

File tree

2 files changed

+62
-35
lines changed

2 files changed

+62
-35
lines changed

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@
8181
"languages": [
8282
{
8383
"id": "helm",
84-
"aliases": ["helm-template", "helm"],
84+
"aliases": [
85+
"helm-template",
86+
"helm"
87+
],
8588
"filenamePatterns": [
8689
"**/templates/*.yaml",
8790
"**/templates/*.yml",
@@ -101,8 +104,8 @@
101104
"compile-tests": "tsc -p . --outDir out",
102105
"watch-tests": "tsc -p . -w --outDir out",
103106
"pretest": "npm run compile-tests && npm run compile",
104-
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint src --ext ts",
105-
"test": "vscode-test --extensionDevelopmentPath=. --extensionTestsPath=./out/test",
107+
"lint": "eslint src --ext ts",
108+
"test": "vscode-test",
106109
"release": "release-it"
107110
},
108111
"dependencies": {

src/test/extension.test.ts

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import * as vscode from "vscode";
66
* Helper function to wait for extension activation with timeout
77
* Extension should activate automatically when Helm documents are opened
88
*/
9-
async function waitForExtensionActivation(extensionId: string, timeout: number = 10000): Promise<vscode.Extension<any>> {
9+
async function waitForExtensionActivation(
10+
extensionId: string,
11+
timeout: number = 1000,
12+
): Promise<vscode.Extension<any>> {
1013
const startTime = Date.now();
1114

1215
while (Date.now() - startTime < timeout) {
@@ -15,112 +18,133 @@ async function waitForExtensionActivation(extensionId: string, timeout: number =
1518
return ext;
1619
}
1720

18-
await new Promise(resolve => setTimeout(resolve, 100));
21+
await new Promise((resolve) => setTimeout(resolve, 100));
1922
}
2023

21-
throw new Error(`Extension ${extensionId} failed to activate within ${timeout}ms`);
24+
throw new Error(
25+
`Extension ${extensionId} failed to activate within ${timeout}ms`,
26+
);
2227
}
2328

2429
/**
2530
* Helper function to open a Helm template file and wait for language server
2631
*/
27-
async function openHelmDocument(workspaceFolder: vscode.WorkspaceFolder): Promise<{ document: vscode.TextDocument; uri: vscode.Uri }> {
32+
async function openHelmDocument(
33+
workspaceFolder: vscode.WorkspaceFolder,
34+
): Promise<{ document: vscode.TextDocument; uri: vscode.Uri }> {
2835
const docPath = path.join(
2936
workspaceFolder.uri.fsPath,
30-
'src', 'test', 'fixtures', 'testChart', 'templates', 'deployment.yaml'
37+
"src",
38+
"test",
39+
"fixtures",
40+
"testChart",
41+
"templates",
42+
"deployment.yaml",
3143
);
3244
const docUri = vscode.Uri.file(docPath);
3345
const document = await vscode.workspace.openTextDocument(docUri);
3446
await vscode.window.showTextDocument(document);
3547

3648
// Give language server a moment to initialize
37-
await new Promise(resolve => setTimeout(resolve, 1000));
49+
await new Promise((resolve) => setTimeout(resolve, 1000));
3850

3951
return { document, uri: docUri };
4052
}
4153

4254
suite("Extension Test Suite", () => {
43-
vscode.window.showInformationMessage('Starting Helm LS extension tests');
55+
vscode.window.showInformationMessage("Starting Helm LS extension tests");
4456

4557
test("Extension loads and activates when opening Helm documents", async function () {
46-
this.timeout(30000);
58+
this.timeout(3000);
4759

4860
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
49-
assert.ok(workspaceFolder, 'No workspace folder found');
61+
assert.ok(workspaceFolder, "No workspace folder found");
5062

5163
// Extension should not be active initially
52-
const extBefore = vscode.extensions.getExtension('helm-ls.helm-ls');
53-
assert.ok(extBefore, 'Extension should be installed');
64+
const extBefore = vscode.extensions.getExtension("helm-ls.helm-ls");
65+
assert.ok(extBefore, "Extension should be installed");
5466

5567
// Open a Helm file - this should trigger activation via onLanguage:helm
5668
await openHelmDocument(workspaceFolder);
5769

5870
// Wait for extension to activate automatically
59-
const ext = await waitForExtensionActivation('helm-ls.helm-ls');
60-
assert.ok(ext.isActive, 'Extension should be activated after opening Helm document');
61-
assert.strictEqual(ext.id, 'helm-ls.helm-ls');
71+
const ext = await waitForExtensionActivation("helm-ls.helm-ls");
72+
assert.ok(
73+
ext.isActive,
74+
"Extension should be activated after opening Helm document",
75+
);
76+
assert.strictEqual(ext.id, "helm-ls.helm-ls");
6277
});
6378

6479
test("Hover support for Helm templates", async function () {
65-
this.timeout(30000);
80+
this.timeout(3000);
6681

6782
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
68-
assert.ok(workspaceFolder, 'No workspace folder found');
83+
assert.ok(workspaceFolder, "No workspace folder found");
6984

7085
// Ensure extension is activated
71-
await waitForExtensionActivation('helm-ls.helm-ls');
86+
await waitForExtensionActivation("helm-ls.helm-ls");
7287

7388
const { uri: docUri } = await openHelmDocument(workspaceFolder);
7489

7590
// Test hover on .Values.replicaCount (line 9, assuming it's around column 25)
7691
const helmPosition = new vscode.Position(8, 25);
7792
const helmHovers = await vscode.commands.executeCommand<vscode.Hover[]>(
78-
'vscode.executeHoverProvider',
93+
"vscode.executeHoverProvider",
7994
docUri,
80-
helmPosition
95+
helmPosition,
8196
);
8297

83-
assert.ok(helmHovers && helmHovers.length > 0, 'Should have hover information for Helm property');
98+
assert.ok(
99+
helmHovers && helmHovers.length > 0,
100+
"Should have hover information for Helm property",
101+
);
84102

85103
const helmHoverContent = helmHovers[0].contents[0] as vscode.MarkdownString;
86-
assert.ok(helmHoverContent, 'Hover content should exist');
104+
assert.ok(helmHoverContent, "Hover content should exist");
87105

88106
// Check for expected content (replicaCount value from values.yaml)
89107
assert.ok(
90-
helmHoverContent.value.includes('1') || helmHoverContent.value.includes('replicaCount'),
91-
`Hover should show replicaCount value or reference. Got: ${helmHoverContent.value}`
108+
helmHoverContent.value.includes("1") ||
109+
helmHoverContent.value.includes("replicaCount"),
110+
`Hover should show replicaCount value or reference. Got: ${helmHoverContent.value}`,
92111
);
93112
});
94113

95114
test("Hover support for YAML schema", async function () {
96-
this.timeout(30000);
115+
this.timeout(3000);
97116

98117
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
99-
assert.ok(workspaceFolder, 'No workspace folder found');
118+
assert.ok(workspaceFolder, "No workspace folder found");
100119

101120
// Ensure extension is activated
102-
await waitForExtensionActivation('helm-ls.helm-ls');
121+
await waitForExtensionActivation("helm-ls.helm-ls");
103122

104123
const { uri: docUri } = await openHelmDocument(workspaceFolder);
105124

106125
// Test hover on 'spec' property (line 7)
107126
const yamlPosition = new vscode.Position(6, 3);
108127
const yamlHovers = await vscode.commands.executeCommand<vscode.Hover[]>(
109-
'vscode.executeHoverProvider',
128+
"vscode.executeHoverProvider",
110129
docUri,
111-
yamlPosition
130+
yamlPosition,
112131
);
113132

114-
assert.ok(yamlHovers && yamlHovers.length > 0, 'Should have hover information for YAML property');
133+
assert.ok(
134+
yamlHovers && yamlHovers.length > 0,
135+
"Should have hover information for YAML property",
136+
);
115137

116138
const yamlHoverContent = yamlHovers[0].contents[0] as vscode.MarkdownString;
117-
assert.ok(yamlHoverContent, 'YAML hover content should exist');
139+
assert.ok(yamlHoverContent, "YAML hover content should exist");
118140

119141
// Check for Kubernetes documentation
120142
const content = yamlHoverContent.value.toLowerCase();
121143
assert.ok(
122-
content.includes('deployment') || content.includes('spec') || content.includes('specification'),
123-
`Hover should show Kubernetes schema info. Got: ${yamlHoverContent.value}`
144+
content.includes("deployment") ||
145+
content.includes("spec") ||
146+
content.includes("specification"),
147+
`Hover should show Kubernetes schema info. Got: ${yamlHoverContent.value}`,
124148
);
125149
});
126150
});

0 commit comments

Comments
 (0)