Skip to content

Commit

Permalink
chore: Add extension dependency redhat.vscode-commons (fabric8-analyt…
Browse files Browse the repository at this point in the history
…ics#487)

* chore: Add extension dependency redhat.vscode-commons

* chore: Add extension dependency redhat.vscode-commons

* bump vscode engine to 1.50.0

* Add extension dependency redhat.vscode-commons

* update vscode engine to 1.50.0

* update resource

* update pkg.json

* update pkg.json

* update pkg.json

* fix test case

* make async

* add dep

* replace extensionPack

* add sleep

* remove disable-extensions

* test script fix

* minor cleanup

* change to arrow fn and add deepEqual

* use include

* add ts-ignore
  • Loading branch information
mathur07 authored Feb 8, 2021
1 parent 2cfc826 commit e0268dd
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 47 deletions.
24 changes: 18 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,31 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}" ],
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/*.js"],
"outFiles": [
"${workspaceFolder}/dist/*.js"
],
"preLaunchTask": "npm: webpack-dev"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["${workspaceFolder}/test/resources/sampleNodeApp/", "--disable-extensions", "--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"args": [
"${workspaceFolder}/test/resources/sampleNodeApp/",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: test-compile"
},
{
Expand All @@ -34,7 +44,9 @@
"port": 6009,
"restart": true,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/server.js"]
"outFiles": [
"${workspaceFolder}/dist/server.js"
]
}
]
}
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"author": "Red Hat",
"publisher": "redhat",
"preview": true,
"extensionDependencies": [
"redhat.vscode-commons"
],
"contributors": [
{
"name": "Jaivardhan Kumar",
Expand Down Expand Up @@ -39,7 +42,7 @@
],
"icon": "icon/openshift_logo.png",
"engines": {
"vscode": "^1.49.0"
"vscode": "^1.50.0"
},
"activationEvents": [
"onCommand:extension.fabric8AnalyticsWidgetFullStack",
Expand Down Expand Up @@ -240,7 +243,7 @@
"@types/mocha": "^5.2.0",
"@types/node": "^12.12.0",
"@types/sinon": "^7.5.0",
"@types/vscode": "^1.47.0",
"@types/vscode": "^1.50.0",
"chai": "^4.1.2",
"decache": "^4.4.0",
"glob": "^7.1.3",
Expand Down
47 changes: 17 additions & 30 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,25 @@ suite('Fabric8 Analytics Extension', () => {
assert.ok(vscode.extensions.getExtension('redhat.fabric8-analytics'));
});

test('should activate', function () {
this.timeout(1 * 60 * 1000);
return vscode.extensions
test('should activate', async () => {
const api = await vscode.extensions
.getExtension('redhat.fabric8-analytics')
.activate()
.then(api => {
assert.ok(true);
});
});
.activate();
assert.ok(true);
}).timeout(1 * 60 * 1000);

test('should register all fabric8 commands', function () {
return vscode.commands.getCommands(true).then(commands => {
const FABRIC8_COMMANDS: string[] = [
Commands.TRIGGER_FULL_STACK_ANALYSIS,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_EDITOR,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_EXPLORER,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_PIE_BTN,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_STATUS_BAR,
Commands.TRIGGER_STACK_LOGS
];
let foundFabric8Commands = commands.filter(function (value) {
return (
FABRIC8_COMMANDS.indexOf(value) >= 0 ||
value.startsWith('extension.fabric8')
);
});
assert.equal(
foundFabric8Commands.length,
FABRIC8_COMMANDS.length,
'Some fabric8 commands are not registered properly or a new command is not added to the test'
);
});

test('should register all fabric8 commands', async function () {
const FABRIC8_COMMANDS: string[] = [
Commands.TRIGGER_FULL_STACK_ANALYSIS,
Commands.TRIGGER_STACK_LOGS,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_EDITOR,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_EXPLORER,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_PIE_BTN,
Commands.TRIGGER_FULL_STACK_ANALYSIS_FROM_STATUS_BAR,
];
// @ts-ignore
assert.ok((await vscode.commands.getCommands(true)).includes(...FABRIC8_COMMANDS));
});

test('should trigger fabric8-analytics full stack report activate', async () => {
Expand Down
3 changes: 3 additions & 0 deletions test/resources/sampleNodeApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"author": "Red Hat",
"publisher": "redhat",
"preview": true,
"extensionDependencies": [
"redhat.vscode-commons"
],
"contributors": [
{
"name": "Jaivardhan Kumar",
Expand Down
23 changes: 18 additions & 5 deletions test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import * as cp from 'child_process';
import * as path from 'path';

import { runTests } from 'vscode-test';
import {
downloadAndUnzipVSCode,
resolveCliPathFromVSCodeExecutablePath,
runTests
} from 'vscode-test';

async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

// The path to the extension test script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './');

const vscodeExecutablePath = await downloadAndUnzipVSCode('1.50.0');
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath)
// Use cp.spawn / cp.exec for custom setup
cp.spawnSync(cliPath, ['--install-extension', 'redhat.vscode-commons'], {
encoding: 'utf-8',
stdio: 'inherit'
});
// Download VS Code, unzip it and run the integration test
await runTests({ version: '1.49.0', extensionDevelopmentPath, extensionTestsPath, launchArgs: [path.resolve(__dirname, '../../test/resources/sampleNodeApp/')] });
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [path.resolve(__dirname, '../../test/resources/sampleNodeApp/')] });
} catch (err) {
console.error(`Failed to run tests. ${err}`);
process.exit(1);
Expand Down
8 changes: 7 additions & 1 deletion test/vscontext.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class DummyMemento implements vscode.Memento {
dummyMomentoData[key] = value;
return Promise.resolve(dummyMomentoData);
}
public setKeysForSync(keys: string[]): void {
return;
}
}

export const context: vscode.ExtensionContext = {
Expand All @@ -26,7 +29,10 @@ export const context: vscode.ExtensionContext = {
},
extensionUri: vscode.Uri.file(''),
environmentVariableCollection: null,
extensionMode: vscode.ExtensionMode.Test
extensionMode: vscode.ExtensionMode.Test,
storageUri: undefined,
logUri: undefined,
globalStorageUri: undefined
};


0 comments on commit e0268dd

Please sign in to comment.