diff --git a/package.json b/package.json index 2299ed0..8a74c4b 100644 --- a/package.json +++ b/package.json @@ -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 .", diff --git a/samples/empty/package.json b/samples/empty/package.json new file mode 100644 index 0000000..7cf0941 --- /dev/null +++ b/samples/empty/package.json @@ -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" +} diff --git a/src/extension.ts b/src/extension.ts index a7c3b30..7d20e4c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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({ diff --git a/tests/e2e/empty/specs/activate.ts b/tests/e2e/empty/specs/activate.ts new file mode 100644 index 0000000..6922ae7 --- /dev/null +++ b/tests/e2e/empty/specs/activate.ts @@ -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(); + }); +}); diff --git a/tests/e2e/empty/tsconfig.json b/tests/e2e/empty/tsconfig.json new file mode 100644 index 0000000..e06a4a9 --- /dev/null +++ b/tests/e2e/empty/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.common.json", + "include": ["specs", "wdio.conf.ts"] +} diff --git a/tests/e2e/empty/wdio.conf.ts b/tests/e2e/empty/wdio.conf.ts new file mode 100644 index 0000000..a42ed00 --- /dev/null +++ b/tests/e2e/empty/wdio.conf.ts @@ -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"), +});