Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
run: npm run test:unit -- --coverage

test-integration:
if: false
continue-on-error: true
strategy:
fail-fast: true
Expand All @@ -48,7 +47,7 @@ jobs:
node_version: ${{ env.NODE_VERSION}}

- name: Create Folder
run: mkdir -p out/coverage/.nyc_output
run: mkdir -p ${{ github.workspace }}/out/coverage/.nyc_output

- name: Run Test Linux
run: xvfb-run -a npm test
Expand Down Expand Up @@ -81,7 +80,7 @@ jobs:
build-vsix:
name: Create VSIX
runs-on: ubuntu-latest
needs: [lint] # test-unit, test-integration,
needs: [lint, test-integration] # test-unit, test-integration,
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
6 changes: 4 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/src/test/fixtures/fake-psh",
"${workspaceFolder}/src/test/fixtures/fake-upsun",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
"--disable-extensions",
"--disable-workspace-trust",
],
// "sourceMaps": true,
// "trace": true,
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
Expand Down
20 changes: 18 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,21 @@
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"typescript.tsc.autoDetect": "on",

"mochaExplorer.files": "src/test/**/*.test.ts",
"mochaExplorer.require": "ts-node/register",
//"mochaExplorer.require": "source-map-support/register",
//"mochaExplorer.files": "out/test/**/*.js",
"mochaExplorer.watch": "src/**/*.ts",
"mochaExplorer.ui": "tdd",
"mochaExplorer.launcherScript": "node_modules/mocha-explorer-launcher-scripts/vscode-test",
"mochaExplorer.autoload": false,
"mochaExplorer.ipcRole": "server",
"mochaExplorer.ipcTimeout": 30000,
"mochaExplorer.env": {
"VSCODE_VERSION": "1.96.3", //"insiders",
"VSCODE_LAUNCH_ARGS": "[\"./src/test/fixtures/fake-upsun\"]",
"ELECTRON_RUN_AS_NODE": null
}
}
55 changes: 54 additions & 1 deletion package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@
"format-check": "prettier --check 'src/**/*.ts' '.github/**/*.yml'",
"format-fix": "prettier --write 'src/**/*.ts' '.github/**/*.yml' gulpfile.js",
"checkDependencies": "gulp checkDependencies",
"test": "node ./out/test/runTest.js"
"test": "node ./out/test/runTest.js",
"test-new": "vscode-test"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
Expand All @@ -342,13 +343,14 @@
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"@vscode/l10n-dev": "^0.0.35",
"@vscode/test-electron": "^2.3.8",
"@vscode/test-electron": "^2.4.1",
"@vscode/vsce": "^3.2.1",
"chai": "^4.3.6",
"eslint": "^8.11.0",
"glob": "^7.2.0",
"gulp": "^5.0.0",
"mocha": "^9.2.2",
"mocha-explorer-launcher-scripts": "^0.4.0",
"nyc": "^15.1.0",
"prettier": "^3.4.2",
"source-map-support": "^0.5.21",
Expand Down
2 changes: 1 addition & 1 deletion src/command/global/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function registerSettingToken(context: vscode.ExtensionContext) {
URI_EXTENSION_SETTING_TOKEN,
async () => {
const store = new PshStorage(context);
await store.setToken();
await store.setTokenInteractive();
},
),
);
Expand Down
17 changes: 13 additions & 4 deletions src/pshstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@ export class PshStorage {
*
* Open InputBox to enter the token value.
*/
async setToken() {
const token: string =
(await vscode.window.showInputBox({
//TODO move on UI code (not tested)
setTokenInteractive() {
vscode.window
.showInputBox({
password: true,
title: 'Upsun Token',
})) ?? '';
})
.then((token) => {
this.setToken(token ?? '');
});
}

/**
* Define Token into settings(boolean) and SecretStorage(value).
*/
setToken(token: string) {
if (token !== '') {
this.secretStorage.store(SECRET_TOKEN, token);
vscode.workspace.getConfiguration().update(SECRET_TOKEN, true);
Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/fake-upsun/.upsun/local/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: erwlgagf6enrq
host: api.upsun.com
4 changes: 3 additions & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as path from 'path';

import { runTests } from '@vscode/test-electron';
import { Console } from 'console';

// Use from CLI not on VScode laucnher !!
async function main() {
try {
// The folder containing the Extension Manifest package.json
Expand All @@ -13,7 +15,7 @@ async function main() {
const extensionTestsPath = path.resolve(__dirname, './suite/index');

const launchArgs = [
path.resolve(__dirname, '../../src/test/fixtures/fake-project1/'),
path.resolve(__dirname, '../../src/test/fixtures/fake-upsun'),
];

// Download VS Code, unzip it and run the integration test
Expand Down
38 changes: 19 additions & 19 deletions src/test/suite/command/environment/register.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import * as path from 'path';
import { assert } from 'chai';
import * as vscode from 'vscode';
import { registerEnvironment } from '../../../../command/environment/register';
// import { registerEnvironment } from '../../../../command/environment/register';

export const rootPath = path.resolve(__dirname, '../');
const packageJSON: any = require(path.resolve(rootPath, 'package.json'));
export const extensionId = `${packageJSON.publisher}.${packageJSON.name}`;
// export const rootPath = path.resolve(__dirname, '../../../');
// const packageJSON: any = require(path.resolve(rootPath, 'package.json'));
// export const extensionId = `${packageJSON.publisher}.${packageJSON.name}`;

suite('Env Test Suite', () => {
test('Environement.register', async () => {
const ext = vscode.extensions.getExtension(extensionId);
if (ext) {
//const extCtx = await ext.activate();
//const extCtx = await vscode.commands.executeCommand("getContext") as vscode.ExtensionContext;
//registerEnvironment(extCtx);
// assert.isDefined(extCtx.subscriptions.push() )
// assert.strictEqual(ctx.projectId, prj);
// assert.strictEqual(ctx.toString(), ` -p ${prj}`);
} else {
assert.fail();
}
});
});
// suite('Env Test Suite', () => {
// test('Environement.register', async () => {
// const ext = vscode.extensions.getExtension(extensionId);
// if (ext) {
// //const extCtx = await ext.activate();
// //const extCtx = await vscode.commands.executeCommand("getContext") as vscode.ExtensionContext;
// //registerEnvironment(extCtx);
// // assert.isDefined(extCtx.subscriptions.push() )
// // assert.strictEqual(ctx.projectId, prj);
// // assert.strictEqual(ctx.toString(), ` -p ${prj}`);
// } else {
// assert.fail();
// }
// });
// });
2 changes: 1 addition & 1 deletion src/test/suite/command/environment/ssh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ suite('Env/SSH Test Suite', () => {
} catch (e) {
assert.fail();
}
});
}).skip();
});
2 changes: 1 addition & 1 deletion src/test/suite/command/environment/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ suite('Env/URL Test Suite', () => {
} catch (e) {
assert.fail();
}
});
}).skip();
});
10 changes: 7 additions & 3 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as vscode from 'vscode';
import { activate } from '../../extension';

import * as path from 'path';
export const rootPath = path.resolve(__dirname, '../');
export const rootPath = path.resolve(__dirname, '../../../');
const packageJSON: any = require(path.resolve(rootPath, 'package.json'));
export const extensionId = `${packageJSON.publisher}.${packageJSON.name}`;

Expand All @@ -13,15 +13,19 @@ suite('Extension Test Suite', () => {
let gitExtension: any | undefined;

if (ext) {
// Extension Found!
if (!ext.isActive) {
// Not active, but activate them!
ext.activate().then(() => {
new Promise((f) => setTimeout(f, 1000));
assert.isTrue(ext.isActive);
});
} else {
// And is active.
assert.isTrue(ext.isActive);
}

assert.isTrue(ext.isActive);
} else {
// Not extension found!
assert.fail();
}
});
Expand Down
Loading