From ebc607588049b4e8e6738209b6c71883a8a0be9f Mon Sep 17 00:00:00 2001 From: DudaGod Date: Mon, 7 Oct 2024 12:06:29 +0300 Subject: [PATCH] fix: errors --- package-lock.json | 50 +++++++++++++++++++ package.json | 17 ++++--- samples/vscode-settings/testplane.config.ts | 28 +---------- src/config/index.ts | 4 +- src/config/settings.ts | 2 +- src/config/utils.ts | 11 ++-- .../specs/use-vscode-settings.ts | 7 +-- 7 files changed, 73 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index 59959d9..15c9bea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "@wdio/mocha-framework": "^8.40.3", "@wdio/spec-reporter": "^8.40.3", "birpc": "^0.2.17", + "concurrently": "^9.0.1", "error-stack-parser": "^2.1.4", "eslint": "^8.56.0", "eslint-config-gemini-testing": "^3.0.0", @@ -5212,6 +5213,46 @@ "typedarray": "^0.0.6" } }, + "node_modules/concurrently": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.0.1.tgz", + "integrity": "sha512-wYKvCd/f54sTXJMSfV6Ln/B8UrfLBKOYa+lzc6CHay3Qek+LorVSBdMVfyewFhRbH0Rbabsk4D+3PL/VjQ5gzg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/consola": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/consola/-/consola-3.2.3.tgz", @@ -13283,6 +13324,15 @@ "node": ">=8" } }, + "node_modules/shell-quote": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", + "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", diff --git a/package.json b/package.json index 8a74c4b..4c91b25 100644 --- a/package.json +++ b/package.json @@ -40,14 +40,14 @@ ] }, "configuration": { - "title": "Testplane", - "properties": { - "testplane.configPath": { - "markdownDescription": "The path to the Testplane [configuration file](https://testplane.io/docs/v8/config/main/)", - "type": "string", - "scope": "window" - } + "title": "Testplane", + "properties": { + "testplane.configPath": { + "markdownDescription": "The path to the Testplane [configuration file](https://testplane.io/docs/v8/config/main/)", + "type": "string", + "scope": "window" } + } } }, "repository": { @@ -60,7 +60,7 @@ "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 && npm run test-e2e:empty", + "test-e2e": "concurrently -c 'auto' 'npm:test-e2e:basic' 'npm:test-e2e:settings-view' 'npm:test-e2e:vscode-settings' 'npm: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", @@ -88,6 +88,7 @@ "@wdio/mocha-framework": "^8.40.3", "@wdio/spec-reporter": "^8.40.3", "birpc": "^0.2.17", + "concurrently": "^9.0.1", "error-stack-parser": "^2.1.4", "eslint": "^8.56.0", "eslint-config-gemini-testing": "^3.0.0", diff --git a/samples/vscode-settings/testplane.config.ts b/samples/vscode-settings/testplane.config.ts index ba363d6..214d431 100644 --- a/samples/vscode-settings/testplane.config.ts +++ b/samples/vscode-settings/testplane.config.ts @@ -1,27 +1 @@ -export default { - gridUrl: "http://localhost:4444/wd/hub", - baseUrl: "http://localhost", - pageLoadTimeout: 0, - httpTimeout: 60000, - testTimeout: 90000, - resetCursor: false, - takeScreenshotOnFails: { - testFail: false, - assertViewFail: false, - }, - sets: { - desktop: { - files: ["tests/**/*.testplane.ts"], - browsers: ["chrome"], - }, - }, - browsers: { - chrome: { - automationProtocol: "devtools", - headless: true, - desiredCapabilities: { - browserName: "chrome", - }, - }, - }, -}; +throw new Error("This config should not be used"); diff --git a/src/config/index.ts b/src/config/index.ts index 28f2f9f..7d86fdf 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,12 +1,12 @@ import * as vscode from "vscode"; import { getVSCodeSettings, type VSCodeSettings } from "./settings"; -import { findTpnConfigFile } from "./utils"; +import { findTestplaneConfigFile } from "./utils"; export type VSCodeConfig = VSCodeSettings; export const getVSCodeConfig = async (wf?: vscode.WorkspaceFolder): Promise => { const settings = getVSCodeSettings(wf); - const configPath = settings.configPath ? settings.configPath : await findTpnConfigFile(); + const configPath = settings.configPath ? settings.configPath : await findTestplaneConfigFile(); return { configPath }; }; diff --git a/src/config/settings.ts b/src/config/settings.ts index 0b71f13..07c5ba3 100644 --- a/src/config/settings.ts +++ b/src/config/settings.ts @@ -18,7 +18,7 @@ export const getVSCodeSettings = (wf?: vscode.WorkspaceFolder): VSCodeSettings = defaultValue, }); - const configPath = get("configPath"); + const configPath = get("configPath"); return { configPath: resolveConfigPath(configPath, wf), diff --git a/src/config/utils.ts b/src/config/utils.ts index 38e0e3d..7e53902 100644 --- a/src/config/utils.ts +++ b/src/config/utils.ts @@ -3,10 +3,15 @@ import * as vscode from "vscode"; import _ from "lodash"; import { CONFIG_GLOB, CONFIG_GLOB_EXCLUDE } from "../constants"; -export const findTpnConfigFile = async (): Promise => { - const configs = (await vscode.workspace.findFiles(CONFIG_GLOB, CONFIG_GLOB_EXCLUDE)).sort((a, b) => { +export const findTestplaneConfigFile = async (): Promise => { + const configs = await vscode.workspace.findFiles(CONFIG_GLOB, CONFIG_GLOB_EXCLUDE); + const consfigsSortedByNesting = configs.sort((a, b) => { return a.fsPath.split(path.sep).length - b.fsPath.split(path.sep).length; }); - return _.isEmpty(configs) ? undefined : configs[0].fsPath; + if (_.isEmpty(consfigsSortedByNesting)) { + return; + } + + return configs[0].fsPath; }; diff --git a/tests/e2e/vscode-settings/specs/use-vscode-settings.ts b/tests/e2e/vscode-settings/specs/use-vscode-settings.ts index b5aeda3..8b32f0a 100644 --- a/tests/e2e/vscode-settings/specs/use-vscode-settings.ts +++ b/tests/e2e/vscode-settings/specs/use-vscode-settings.ts @@ -11,11 +11,8 @@ describe(".vscode/settings.json", () => { await sidebar.waitTestsRead(); const [firstSection] = await sidebar.getSections(); - const [mainTreeItem] = await firstSection.getVisibleItems(); + const visibleItems = await firstSection.getVisibleItems(); - await mainTreeItem.expandAll(); - const testsFullTitle = await mainTreeItem.getTestsFullTitle(); - - expect(testsFullTitle).toEqual(["tests test.testplane.ts success another-bro"]); + expect(visibleItems).toHaveLength(1); }); });