Skip to content

Commit

Permalink
fix: do not activate extension if config is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Oct 2, 2024
1 parent ff07a34 commit 5b21239
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@
"build": "tsup --minify --clean",
"watch": "tsup --watch --sourcemap",
"test": "npm run lint && npm run test-e2e",
"test-e2e": "npm run test-e2e:basic && npm run test-e2e:settings-view && npm run test-e2e:vscode-settings",
"test-e2e": "npm run test-e2e:basic && npm run test-e2e:settings-view && npm run test-e2e:vscode-settings && npm run test-e2e:empty",
"test-e2e:basic": "wdio run ./tests/e2e/basic/wdio.conf.ts",
"test-e2e:settings-view": "wdio run ./tests/e2e/settings-view/wdio.conf.ts",
"test-e2e:vscode-settings": "wdio run ./tests/e2e/vscode-settings/wdio.conf.ts",
"test-e2e:empty": "wdio run ./tests/e2e/empty/wdio.conf.ts",
"eslint": "eslint src --ext ts --cache",
"lint": "eslint --cache . && prettier --check .",
"reformat": "eslint --fix . && prettier --write .",
Expand Down
12 changes: 12 additions & 0 deletions samples/empty/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "empty",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
8 changes: 8 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ class TestplaneExtension {
// TODO: should support few workspaces
const wf = folders[0];
const config = await getVSCodeConfig(wf);

if (!config.configPath) {
logger.error("Failed to start: Testplane config is not found");
this._testController.items.delete(this._loadingTestItem.id);

return;
}

const childProc = await createChildProcess(wf, config);

const { api, handlers } = createTestplaneMasterRpc({
Expand Down
19 changes: 19 additions & 0 deletions tests/e2e/empty/specs/activate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from "@wdio/globals";
import { VSCodePO } from "../../page-objects";

describe("Activation on open Testing bar", () => {
it("should do not try to read tests", async () => {
const vscodePO = await VSCodePO.create();
const testingViewControl = vscodePO.getTestingViewControl();
await testingViewControl.open();

const sidebar = vscodePO.getTestingSideBar();
const [firstSection] = await sidebar.getSections();
const items = await firstSection.getVisibleItems();

expect(items).toHaveLength(0);

const webview = await vscodePO.getWebviewByTitle("Testplane");
expect(webview.elem).toBeDisplayed();
});
});
4 changes: 4 additions & 0 deletions tests/e2e/empty/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.common.json",
"include": ["specs", "wdio.conf.ts"]
}
8 changes: 8 additions & 0 deletions tests/e2e/empty/wdio.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import path from "node:path";
import { getWdioConfig } from "../utils";
import type { Options } from "@wdio/types";

export const config: Options.Testrunner = getWdioConfig({
extensionPath: process.cwd(),
workspacePath: path.resolve(process.cwd(), "samples/empty"),
});

0 comments on commit 5b21239

Please sign in to comment.