Skip to content

Commit 39aa409

Browse files
committed
fix: auto path for model.json on Windows, include server/node_modules
1 parent 7d4feda commit 39aa409

10 files changed

Lines changed: 100 additions & 178 deletions

File tree

vscode-extension/.vscodeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**/tsconfig.json
55
**/jest.config*
66
**/coverage/**
7-
server/node_modules/**
87
client/node_modules/**
98
node_modules/**
109
**/.gitignore
10+
model.json

vscode-extension/client/src/extension.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { ExtensionContext } from 'vscode';
55
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node';
66
import { registerCommands } from './commands';
77
import { FamixModelProvider } from './modelTreeProvider';
8-
import { ModelWebviewProvider } from './modelWebviewProvider';
98

109
let client: LanguageClient;
1110
const extensionName = 'ts2famixExtension';
@@ -25,36 +24,24 @@ export async function activate(context: ExtensionContext) {
2524
await client.start();
2625

2726
const modelProvider = new FamixModelProvider();
28-
const webviewProvider = new ModelWebviewProvider();
2927
vscode.window.registerTreeDataProvider('ts2famixModel', modelProvider);
3028

31-
const getModelPath = () => {
29+
const refreshModel = () => {
3230
const config = vscode.workspace.getConfiguration('ts2famix');
3331
let modelPath = config.get<string>('FamixModelOutputFilePath', '');
32+
3433
if (!modelPath) {
3534
const workspaceFolders = vscode.workspace.workspaceFolders;
3635
if (workspaceFolders && workspaceFolders.length > 0) {
3736
modelPath = path.join(workspaceFolders[0].uri.fsPath, 'model.json');
3837
}
3938
}
40-
return modelPath;
41-
};
42-
43-
const refreshModel = () => {
44-
const modelPath = getModelPath();
39+
4540
if (modelPath && fs.existsSync(modelPath)) {
4641
modelProvider.refresh(modelPath);
4742
}
4843
};
4944

50-
// Commande pour ouvrir la webview
51-
context.subscriptions.push(
52-
vscode.commands.registerCommand('ts2famix.showDiagram', () => {
53-
const modelPath = getModelPath();
54-
webviewProvider.show(modelPath, context);
55-
})
56-
);
57-
5845
const modelWatcher = vscode.workspace.createFileSystemWatcher('**/*.json');
5946
modelWatcher.onDidChange(refreshModel);
6047
modelWatcher.onDidCreate(refreshModel);
@@ -68,4 +55,4 @@ export async function activate(context: ExtensionContext) {
6855
export function deactivate(): Thenable<void> | undefined {
6956
if (!client) { return undefined; }
7057
return client.stop();
71-
}
58+
}

vscode-extension/client/src/test/runTest.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import * as path from 'path';
22
import { runTests } from '@vscode/test-electron';
33

4+
// https://code.visualstudio.com/api/working-with-extensions/testing-extension#custom-setup-with-atvscodetestelectron
45
async function main() {
56
try {
67
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
78
const extensionTestsPath = path.resolve(__dirname, './suite/index');
8-
const workspacePath = path.resolve(__dirname, '../../src/test/fixtures/project-with-tsconfig');
9-
9+
1010
await runTests({
1111
extensionDevelopmentPath,
1212
extensionTestsPath,
1313
launchArgs: [
14-
workspacePath,
15-
'--disable-extensions'
14+
'--disable-extensions' // Disable all other extensions
1615
]
1716
});
1817
} catch {

vscode-extension/client/src/test/suite/smoke/smoke.test.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { TestHelper } from '../../helper';
22
import * as vscode from 'vscode';
33
import * as assert from 'assert';
44

5-
suite('Smoke Tests', function() {
6-
this.timeout(30000);
5+
suite('Smoke Tests', () => {
76
test('Extension loads and activates without errors', async () => {
87
const extensionId = TestHelper.getExtensionId();
98
const extension = vscode.extensions.getExtension(extensionId);
@@ -38,40 +37,10 @@ suite('Smoke Tests', function() {
3837
const response = await client.sendRequest<{result?: null; error?: string;}>('generateModelForProject', { filePath: mockFilePath });
3938

4039
assert.ok(response, 'Should receive a response from the server');
41-
assert.strictEqual(response.result, null, 'Response should indicate failure due to mock path');
42-
//assert.ok(response.error, 'Response should include an error message');
40+
assert.strictEqual(response.result, undefined, 'Response should indicate failure due to mock path');
41+
assert.ok(response.error, 'Response should include an error message');
4342
} catch (error) {
4443
assert.fail(`Failed to communicate with the server: ${error}`);
4544
}
4645
});
47-
test('Generates Famix model for a TypeScript project', async function() {
48-
const fs = require('fs');
49-
const path = require('path');
50-
51-
const fixturePath = path.resolve(__dirname, '../../../../src/test/fixtures/project-with-tsconfig');
52-
const modelPath = path.join(fixturePath, 'model.json');
53-
54-
// S'assurer que model.json n'existe pas avant le test
55-
if (fs.existsSync(modelPath)) {
56-
fs.unlinkSync(modelPath);
57-
}
58-
assert.ok(!fs.existsSync(modelPath), 'model.json should not exist before the test');
59-
60-
// Configurer le chemin du modèle
61-
const config = vscode.workspace.getConfiguration('ts2famix');
62-
await config.update('FamixModelOutputFilePath', modelPath, vscode.ConfigurationTarget.Global);
63-
64-
// Invoquer la commande de génération
65-
await vscode.commands.executeCommand('ts2famix.generateModelForProject');
66-
67-
// Attendre que le fichier soit généré
68-
await new Promise(resolve => setTimeout(resolve, 8000));
69-
70-
// Vérifier que model.json existe
71-
assert.ok(fs.existsSync(modelPath), 'model.json should exist after generation');
72-
73-
// Nettoyer
74-
fs.unlinkSync(modelPath);
75-
assert.ok(!fs.existsSync(modelPath), 'model.json should be deleted after the test');
76-
});
7746
});

0 commit comments

Comments
 (0)