From ada05f0a9667bad13475ce872d734c20e01bf5e8 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sun, 1 Dec 2024 18:02:09 +0200 Subject: [PATCH 01/58] test(temp): delete non e2e workflows Signed-off-by: Zacharias Fragkiadakis --- .github/workflows/code-linting.yaml | 28 --------------------------- .github/workflows/commit-linting.yaml | 13 ------------- .github/workflows/pr-linting.yaml | 13 ------------- 3 files changed, 54 deletions(-) delete mode 100644 .github/workflows/code-linting.yaml delete mode 100644 .github/workflows/commit-linting.yaml delete mode 100644 .github/workflows/pr-linting.yaml diff --git a/.github/workflows/code-linting.yaml b/.github/workflows/code-linting.yaml deleted file mode 100644 index 3a501da7..00000000 --- a/.github/workflows/code-linting.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: CI -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - lint-code: - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - - name: Install Node.js - uses: actions/setup-node@v4.1.0 - with: - node-version: 20.x - cache: 'pnpm' - - name: Install Dependencies - run: npx npm-run-all -l verify-deps:* - - name: Lint Code - run: pnpm run lint - - name: Test Typings - run: pnpm run test:typings diff --git a/.github/workflows/commit-linting.yaml b/.github/workflows/commit-linting.yaml deleted file mode 100644 index ffcb55ef..00000000 --- a/.github/workflows/commit-linting.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: CI -on: - pull_request: - branches: [ main ] - -jobs: - lint-commit-messages: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: wagoid/commitlint-github-action@v5 diff --git a/.github/workflows/pr-linting.yaml b/.github/workflows/pr-linting.yaml deleted file mode 100644 index 3b621d52..00000000 --- a/.github/workflows/pr-linting.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: CI -on: - pull_request: - types: ['opened', 'edited', 'reopened', 'synchronize'] - -jobs: - lint-pr-title: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install Dependencies - run: npm install @commitlint/config-conventional@v17 - - uses: JulienKode/pull-request-name-linter-action@v0.5.0 From 9f6cee99ae9ed7cc569fb7b0db5148cbe169a0c1 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sun, 1 Dec 2024 18:37:55 +0200 Subject: [PATCH 02/58] test(temp): remove macos from e2e workflow Signed-off-by: Zacharias Fragkiadakis --- .github/workflows/e2e-testing.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-testing.yaml b/.github/workflows/e2e-testing.yaml index 59d711f2..df3230ab 100644 --- a/.github/workflows/e2e-testing.yaml +++ b/.github/workflows/e2e-testing.yaml @@ -9,7 +9,8 @@ jobs: test-e2e: strategy: matrix: - os: [macos-latest, ubuntu-latest] + # os: [macos-latest, ubuntu-latest] + os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: From 5a16bbddc77a81215d396daa878e37576be9a3db Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sun, 1 Dec 2024 21:04:39 +0200 Subject: [PATCH 03/58] test(e2e): add initial test for path to rad binary setting - adds test/e2e/helpers/actions.ts and test/e2e/helpers/queries.ts and extracts 2 helper functions - adds new test/e2e/specs/settings.spec.ts suite and implements initial test - sets order of suites to: 1. onboarding (sequential) 2. rest of the settings (parallel) Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 84 +++++++++++++++++++++++++++++++++ test/e2e/wdio.conf.ts | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 test/e2e/specs/settings.spec.ts diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts new file mode 100644 index 00000000..076bf225 --- /dev/null +++ b/test/e2e/specs/settings.spec.ts @@ -0,0 +1,84 @@ +import { browser } from '@wdio/globals' +import type { SettingsEditor, Workbench } from 'wdio-vscode-service' +import isEqual from 'lodash/isEqual' +import { Key } from 'webdriverio' +import { getFirstWelcomeViewText } from '../helpers/queries' +import { openRadicleViewContainer } from '../helpers/actions' + +describe('Settings', () => { + let workbench: Workbench + let settings: SettingsEditor + + before(async () => { + workbench = await browser.getWorkbench() + settings = await workbench.openSettings() + }) + + after(async () => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access + if (settings && (await settings.elem.isExisting())) { + await browser.keys([Key.Ctrl, 'w']) + } + }) + + describe('Path to Rad Binary', () => { + it('warns the user if the rad binary is not found', async () => { + const pathToRadBinary = await settings.findSetting( + 'Path To Rad Binary', + 'Radicle', + 'Advanced', + ) + await pathToRadBinary.setValue('/tmp') + await openRadicleViewContainer(workbench) + + await expectRadCliBinaryNotFoundToBeVisible(workbench) + + /** + * `.setValue('')` updates the value of the input but does not trigger an + * update in the extension. Not sure if this is a bug in the extension, vscode, or + * webdriverio. + * + * The following is a workaround that does trigger an update in the extension. + */ + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access + await (await pathToRadBinary.textSetting$).click() + await browser.keys([Key.Ctrl, 'a']) + await browser.keys(Key.Backspace) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) + }) + + // describe('Setting: Path To Node Home', () => { }) +}) + +async function expectRadCliBinaryNotFoundToBeVisible(workbench: Workbench) { + return await browser.waitUntil(async () => { + const welcomeText = await getFirstWelcomeViewText(workbench) + + return isEqual(welcomeText, [ + /* eslint-disable max-len */ + 'Failed resolving the Radicle CLI binary.', + "Please ensure it is installed on your machine and either that it is globally accessible in the shell as `rad` or that its path is correctly defined in the extension's settings.", + "Please expect the extention's capabilities to remain severely limited until this issue is resolved.", + /* eslint-enable max-len */ + ]) + }) +} + +async function expectCliCommandsAndPatchesToBeVisible(workbench: Workbench) { + const sidebarView = workbench.getSideBar().getContent() + await sidebarView.wait() + + return await browser.waitUntil(async () => { + let sectionsFound = false + try { + await sidebarView.getSection('CLI COMMANDS') + await sidebarView.getSection('PATCHES') + sectionsFound = true + // eslint-disable-next-line prettier-vue/prettier + } catch { } + + return sectionsFound + }) +} diff --git a/test/e2e/wdio.conf.ts b/test/e2e/wdio.conf.ts index d95a3414..c290ab5c 100644 --- a/test/e2e/wdio.conf.ts +++ b/test/e2e/wdio.conf.ts @@ -29,7 +29,7 @@ export const config: Options.Testrunner = { transpileOnly: true, }, }, - specs: ['./specs/**/*.ts'], + specs: ['./specs/onboarding.spec.ts', './specs/**/*.spec.ts'], maxInstances: 10, capabilities: [ { From 8b8269e712a9fc54974c35de439df9793ea9e042 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Thu, 26 Dec 2024 18:14:40 +0200 Subject: [PATCH 04/58] test(e2e): test recognition when directory is created after the setting is updated Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 80 +++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 076bf225..6b2ec58f 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,9 +1,13 @@ import { browser } from '@wdio/globals' -import type { SettingsEditor, Workbench } from 'wdio-vscode-service' +import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' +import { $ } from 'zx' +import { extTempDir } from 'src/constants' import { getFirstWelcomeViewText } from '../helpers/queries' import { openRadicleViewContainer } from '../helpers/actions' +import { pathToNodeHome } from '../constants/config' +import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' describe('Settings', () => { let workbench: Workbench @@ -21,38 +25,51 @@ describe('Settings', () => { } }) - describe('Path to Rad Binary', () => { - it('warns the user if the rad binary is not found', async () => { - const pathToRadBinary = await settings.findSetting( + describe('VS Code, when updating the "Path to Rad Binary" setting,', () => { + let pathToRadBinarySetting: Setting + + before(async () => { + pathToRadBinarySetting = await settings.findSetting( 'Path To Rad Binary', 'Radicle', 'Advanced', ) - await pathToRadBinary.setValue('/tmp') + }) + + afterEach(async () => { + await clearSettingInput(pathToRadBinarySetting) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) + + it('warns the user if the rad binary is not found', async () => { + await pathToRadBinarySetting.setValue('/tmp') await openRadicleViewContainer(workbench) - await expectRadCliBinaryNotFoundToBeVisible(workbench) + await expectRadBinaryNotFoundToBeVisible(workbench) + }) + + // This functionality does not seem to work + // eslint-disable-next-line max-len + it.skip('recognizes if the directory is created *after* the setting is updated', async () => { + const tempNodeHomePath = `${extTempDir}/.radicle/installation-backup` + await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`) + + await expectRadBinaryNotFoundToBeVisible(workbench) - /** - * `.setValue('')` updates the value of the input but does not trigger an - * update in the extension. Not sure if this is a bug in the extension, vscode, or - * webdriverio. - * - * The following is a workaround that does trigger an update in the extension. - */ - // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access - await (await pathToRadBinary.textSetting$).click() - await browser.keys([Key.Ctrl, 'a']) - await browser.keys(Key.Backspace) + await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` await expectCliCommandsAndPatchesToBeVisible(workbench) + + await clearSettingInput(pathToRadBinarySetting) + await $`rm -rf ${tempNodeHomePath}` }) }) // describe('Setting: Path To Node Home', () => { }) }) -async function expectRadCliBinaryNotFoundToBeVisible(workbench: Workbench) { +async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { return await browser.waitUntil(async () => { const welcomeText = await getFirstWelcomeViewText(workbench) @@ -66,19 +83,16 @@ async function expectRadCliBinaryNotFoundToBeVisible(workbench: Workbench) { }) } -async function expectCliCommandsAndPatchesToBeVisible(workbench: Workbench) { - const sidebarView = workbench.getSideBar().getContent() - await sidebarView.wait() - - return await browser.waitUntil(async () => { - let sectionsFound = false - try { - await sidebarView.getSection('CLI COMMANDS') - await sidebarView.getSection('PATCHES') - sectionsFound = true - // eslint-disable-next-line prettier-vue/prettier - } catch { } - - return sectionsFound - }) +async function clearSettingInput(setting: Setting) { + /** + * `.setValue('')` updates the value of the input but does not trigger an + * update in the extension. Not sure if this is a bug in the extension, vscode, or + * webdriverio. + * + * The following is a workaround that does trigger an update in the extension. + */ + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access + await (await setting.textSetting$).click() + await browser.keys([Key.Ctrl, 'a']) + await browser.keys(Key.Backspace) } From 958a36b87cfeb61f027324f65bcce8d8e053a81a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:10:14 +0200 Subject: [PATCH 05/58] test(debug): simplify settings.spec.ts Signed-off-by: Zacharias Fragkiadakis --- .github/workflows/e2e-testing.yaml | 5 +- test/e2e/specs/settings.spec.ts | 101 ++++++++++------------------- test/e2e/wdio.conf.ts | 2 +- 3 files changed, 38 insertions(+), 70 deletions(-) diff --git a/.github/workflows/e2e-testing.yaml b/.github/workflows/e2e-testing.yaml index df3230ab..719d36a4 100644 --- a/.github/workflows/e2e-testing.yaml +++ b/.github/workflows/e2e-testing.yaml @@ -8,9 +8,10 @@ on: jobs: test-e2e: strategy: + fail-fast: false matrix: - # os: [macos-latest, ubuntu-latest] - os: [ubuntu-latest] + os: [macos-latest, ubuntu-latest] + # os: [macos-latest] runs-on: ${{ matrix.os }} steps: diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 6b2ec58f..6a010db7 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,86 +1,53 @@ import { browser } from '@wdio/globals' -import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' +import type { Setting, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' -import { $ } from 'zx' -import { extTempDir } from 'src/constants' import { getFirstWelcomeViewText } from '../helpers/queries' -import { openRadicleViewContainer } from '../helpers/actions' -import { pathToNodeHome } from '../constants/config' import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' describe('Settings', () => { - let workbench: Workbench - let settings: SettingsEditor + it('warns the user if the rad binary is not found', async () => { + const workbench = await browser.getWorkbench() + const settings = await workbench.openSettings() + const pathToRadBinarySetting = await settings.findSetting( + 'Path To Rad Binary', + 'Radicle', + 'Advanced', + ) - before(async () => { - workbench = await browser.getWorkbench() - settings = await workbench.openSettings() - }) - - after(async () => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access - if (settings && (await settings.elem.isExisting())) { - await browser.keys([Key.Ctrl, 'w']) - } - }) - - describe('VS Code, when updating the "Path to Rad Binary" setting,', () => { - let pathToRadBinarySetting: Setting - - before(async () => { - pathToRadBinarySetting = await settings.findSetting( - 'Path To Rad Binary', - 'Radicle', - 'Advanced', - ) - }) - - afterEach(async () => { - await clearSettingInput(pathToRadBinarySetting) - - await expectCliCommandsAndPatchesToBeVisible(workbench) - }) + // await openRadicleViewContainer(workbench) + await expectCliCommandsAndPatchesToBeVisible(workbench) - it('warns the user if the rad binary is not found', async () => { - await pathToRadBinarySetting.setValue('/tmp') - await openRadicleViewContainer(workbench) + await browser.pause(1000) + await pathToRadBinarySetting.setValue('/tmp') - await expectRadBinaryNotFoundToBeVisible(workbench) - }) + await expectRadBinaryNotFoundToBeVisible(workbench) - // This functionality does not seem to work - // eslint-disable-next-line max-len - it.skip('recognizes if the directory is created *after* the setting is updated', async () => { - const tempNodeHomePath = `${extTempDir}/.radicle/installation-backup` - await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`) + await clearSettingInput(pathToRadBinarySetting) - await expectRadBinaryNotFoundToBeVisible(workbench) - - await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` - - await expectCliCommandsAndPatchesToBeVisible(workbench) - - await clearSettingInput(pathToRadBinarySetting) - await $`rm -rf ${tempNodeHomePath}` - }) + await expectCliCommandsAndPatchesToBeVisible(workbench) }) - - // describe('Setting: Path To Node Home', () => { }) }) async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { - return await browser.waitUntil(async () => { - const welcomeText = await getFirstWelcomeViewText(workbench) - - return isEqual(welcomeText, [ - /* eslint-disable max-len */ - 'Failed resolving the Radicle CLI binary.', - "Please ensure it is installed on your machine and either that it is globally accessible in the shell as `rad` or that its path is correctly defined in the extension's settings.", - "Please expect the extention's capabilities to remain severely limited until this issue is resolved.", - /* eslint-enable max-len */ - ]) - }) + await browser.waitUntil( + async () => { + const welcomeText = await getFirstWelcomeViewText(workbench) + + console.log({ welcomeText }) + + return isEqual(welcomeText, [ + /* eslint-disable max-len */ + 'Failed resolving the Radicle CLI binary.', + "Please ensure it is installed on your machine and either that it is globally accessible in the shell as `rad` or that its path is correctly defined in the extension's settings.", + "Please expect the extention's capabilities to remain severely limited until this issue is resolved.", + /* eslint-enable max-len */ + ]) + }, + { + timeoutMsg: 'expected the rad binary not found message to be visible', + }, + ) } async function clearSettingInput(setting: Setting) { diff --git a/test/e2e/wdio.conf.ts b/test/e2e/wdio.conf.ts index c290ab5c..801eed67 100644 --- a/test/e2e/wdio.conf.ts +++ b/test/e2e/wdio.conf.ts @@ -29,7 +29,7 @@ export const config: Options.Testrunner = { transpileOnly: true, }, }, - specs: ['./specs/onboarding.spec.ts', './specs/**/*.spec.ts'], + specs: [['./specs/onboarding.spec.ts', './specs/settings.spec.ts']], maxInstances: 10, capabilities: [ { From 2eb824939e6a1492dba021ab2ad1c3d51acc9438 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:14:13 +0200 Subject: [PATCH 06/58] test(debug): increase pause before updating setting to 5s Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 6a010db7..1d1863e4 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -18,7 +18,7 @@ describe('Settings', () => { // await openRadicleViewContainer(workbench) await expectCliCommandsAndPatchesToBeVisible(workbench) - await browser.pause(1000) + await browser.pause(5000) await pathToRadBinarySetting.setValue('/tmp') await expectRadBinaryNotFoundToBeVisible(workbench) From 768355218121d678ad189041f63ef33c54960795 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:17:42 +0200 Subject: [PATCH 07/58] revert: "test(debug): increase pause before updating setting to 5s" This reverts commit a7a917932deb14b8e8c845c1d23b1db9dc848028. Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 1d1863e4..6a010db7 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -18,7 +18,7 @@ describe('Settings', () => { // await openRadicleViewContainer(workbench) await expectCliCommandsAndPatchesToBeVisible(workbench) - await browser.pause(5000) + await browser.pause(1000) await pathToRadBinarySetting.setValue('/tmp') await expectRadBinaryNotFoundToBeVisible(workbench) From af7d49c620ae1f315a5d8ef6f00e5593d9cae24c Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:18:50 +0200 Subject: [PATCH 08/58] test(debug): open radicle view container before initial assertion Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 6a010db7..c3763806 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -4,6 +4,7 @@ import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { getFirstWelcomeViewText } from '../helpers/queries' import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' +import { openRadicleViewContainer } from '../helpers/actions' describe('Settings', () => { it('warns the user if the rad binary is not found', async () => { @@ -15,7 +16,7 @@ describe('Settings', () => { 'Advanced', ) - // await openRadicleViewContainer(workbench) + await openRadicleViewContainer(workbench) await expectCliCommandsAndPatchesToBeVisible(workbench) await browser.pause(1000) From 97ab6d6fa8dc9ec431268794037e1228d16dfc56 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:22:43 +0200 Subject: [PATCH 09/58] test: open radicle view container *after* changing input value (works on both platforms!) Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index c3763806..2705f6cf 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -16,12 +16,12 @@ describe('Settings', () => { 'Advanced', ) - await openRadicleViewContainer(workbench) await expectCliCommandsAndPatchesToBeVisible(workbench) await browser.pause(1000) await pathToRadBinarySetting.setValue('/tmp') + await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) await clearSettingInput(pathToRadBinarySetting) From 1e177979d9a07d38007020cca7a85a424b46fbe0 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:31:19 +0200 Subject: [PATCH 10/58] test: hoist variables outside of test case, in describe Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 2705f6cf..b92a5c59 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,5 +1,5 @@ import { browser } from '@wdio/globals' -import type { Setting, Workbench } from 'wdio-vscode-service' +import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { getFirstWelcomeViewText } from '../helpers/queries' @@ -7,10 +7,14 @@ import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' import { openRadicleViewContainer } from '../helpers/actions' describe('Settings', () => { + let workbench: Workbench + let settings: SettingsEditor + let pathToRadBinarySetting: Setting + it('warns the user if the rad binary is not found', async () => { - const workbench = await browser.getWorkbench() - const settings = await workbench.openSettings() - const pathToRadBinarySetting = await settings.findSetting( + workbench = await browser.getWorkbench() + settings = await workbench.openSettings() + pathToRadBinarySetting = await settings.findSetting( 'Path To Rad Binary', 'Radicle', 'Advanced', From cf97cd745f46b1733c56dfbfa4369b40c6294929 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:40:38 +0200 Subject: [PATCH 11/58] revert: "test: hoist variables outside of test case, in describe" This reverts commit a397eb98472014969e14c6f2723f856c8fd96b32. Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index b92a5c59..2705f6cf 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,5 +1,5 @@ import { browser } from '@wdio/globals' -import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' +import type { Setting, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { getFirstWelcomeViewText } from '../helpers/queries' @@ -7,14 +7,10 @@ import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' import { openRadicleViewContainer } from '../helpers/actions' describe('Settings', () => { - let workbench: Workbench - let settings: SettingsEditor - let pathToRadBinarySetting: Setting - it('warns the user if the rad binary is not found', async () => { - workbench = await browser.getWorkbench() - settings = await workbench.openSettings() - pathToRadBinarySetting = await settings.findSetting( + const workbench = await browser.getWorkbench() + const settings = await workbench.openSettings() + const pathToRadBinarySetting = await settings.findSetting( 'Path To Rad Binary', 'Radicle', 'Advanced', From f786db61be140ee8b120ee1b30d6224f4876fbd2 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 18:53:32 +0200 Subject: [PATCH 12/58] test: update not found assertion interval to .5s and timeout to 20s Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 2705f6cf..3d9b48f2 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -47,6 +47,8 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { }, { timeoutMsg: 'expected the rad binary not found message to be visible', + timeout: 20000, + interval: 500, }, ) } From 37fcc82362d9d63f3b2a6c129cd50ffeaae2082d Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 19:03:05 +0200 Subject: [PATCH 13/58] test: add todo to fine-tune timeouts and intervals Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 3d9b48f2..cf584c48 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -47,6 +47,7 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { }, { timeoutMsg: 'expected the rad binary not found message to be visible', + // TODO: zac fine tune these (globally?) timeout: 20000, interval: 500, }, From f712dc352c619e8c40dc958e982034fdb89e9c70 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 19:03:21 +0200 Subject: [PATCH 14/58] revert: ""revert: hoist variables outside of test case, in describe"" This reverts commit b9358c2f3d2e957c313269f098cb5b9afe63e275. Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index cf584c48..9e683746 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,5 +1,5 @@ import { browser } from '@wdio/globals' -import type { Setting, Workbench } from 'wdio-vscode-service' +import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { getFirstWelcomeViewText } from '../helpers/queries' @@ -7,10 +7,14 @@ import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' import { openRadicleViewContainer } from '../helpers/actions' describe('Settings', () => { + let workbench: Workbench + let settings: SettingsEditor + let pathToRadBinarySetting: Setting + it('warns the user if the rad binary is not found', async () => { - const workbench = await browser.getWorkbench() - const settings = await workbench.openSettings() - const pathToRadBinarySetting = await settings.findSetting( + workbench = await browser.getWorkbench() + settings = await workbench.openSettings() + pathToRadBinarySetting = await settings.findSetting( 'Path To Rad Binary', 'Radicle', 'Advanced', From 5ea225b9165af59f28ef274ec08e8345d1aadc2a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 19:16:09 +0200 Subject: [PATCH 15/58] test: add case for entering a valid path Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 9e683746..e20bace2 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -2,9 +2,11 @@ import { browser } from '@wdio/globals' import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' +import { $ } from 'zx' import { getFirstWelcomeViewText } from '../helpers/queries' import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' import { openRadicleViewContainer } from '../helpers/actions' +import { pathToNodeHome } from '../constants/config' describe('Settings', () => { let workbench: Workbench @@ -32,6 +34,28 @@ describe('Settings', () => { await expectCliCommandsAndPatchesToBeVisible(workbench) }) + + it('recognizes the rad binary when a valid path is specified', async () => { + const tempNodeHomePath = `${pathToNodeHome}.temp` + await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` + + await browser.pause(1000) + await pathToRadBinarySetting.setValue(`/tmp`) + + await openRadicleViewContainer(workbench) + await expectRadBinaryNotFoundToBeVisible(workbench) + + await browser.pause(1000) + await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + + await $`rm -rf ${tempNodeHomePath}` + + await clearSettingInput(pathToRadBinarySetting) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) }) async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { From cc67ac5a67b7ad3224b633417cc964b5fb88a567 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 19:20:04 +0200 Subject: [PATCH 16/58] test: increase timeout and decrease interval on cli and patches assertion Signed-off-by: Zacharias Fragkiadakis --- test/e2e/helpers/assertions.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/helpers/assertions.ts b/test/e2e/helpers/assertions.ts index 539d5c31..4bca11fb 100644 --- a/test/e2e/helpers/assertions.ts +++ b/test/e2e/helpers/assertions.ts @@ -23,6 +23,11 @@ export async function expectStandardSidebarViewsToBeVisible(workbench: Workbench return false } }, - { timeoutMsg: 'expected the standard sidebar views to be visible' }, + { + timeoutMsg: 'expected the standard sidebar views to be visible', + // TODO: zac fine tune these (globally?) + timeout: 20000, + interval: 500, + }, ) } From 8e02f89d15d645287d5a75a185a7bee5acd236b9 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Fri, 27 Dec 2024 19:43:02 +0200 Subject: [PATCH 17/58] test: clear setting input before updating it Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index e20bace2..f6639a51 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -46,7 +46,7 @@ describe('Settings', () => { await expectRadBinaryNotFoundToBeVisible(workbench) await browser.pause(1000) - await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`) + await setSettingInputValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) await expectCliCommandsAndPatchesToBeVisible(workbench) @@ -95,3 +95,8 @@ async function clearSettingInput(setting: Setting) { await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } + +async function setSettingInputValue(setting: Setting, value: string) { + await clearSettingInput(setting) + await setting.setValue(value) +} From c9a6a0d3af5be490cdfefcdabd49be57df0e22dd Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 10:09:42 +0200 Subject: [PATCH 18/58] test: remove pauses before updating input value Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index f6639a51..a01b78c2 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -39,13 +39,11 @@ describe('Settings', () => { const tempNodeHomePath = `${pathToNodeHome}.temp` await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` - await browser.pause(1000) await pathToRadBinarySetting.setValue(`/tmp`) await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) - await browser.pause(1000) await setSettingInputValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) await expectCliCommandsAndPatchesToBeVisible(workbench) From 5838d68d9823de4cad21ce12397218e0883b16e4 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 10:15:27 +0200 Subject: [PATCH 19/58] test: log input value before clearing it Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index a01b78c2..f13b5a92 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -81,6 +81,9 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { } async function clearSettingInput(setting: Setting) { + const inputValue = await setting.getValue() + console.log({ inputValue }) + /** * `.setValue('')` updates the value of the input but does not trigger an * update in the extension. Not sure if this is a bug in the extension, vscode, or From 54613c3ae2c346b5d7b5bb668e3f2d0d9615eb4a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 11:53:36 +0200 Subject: [PATCH 20/58] test(e2e): imrpove helper functions for manipulating settings Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 68 ++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index f13b5a92..012ec441 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,5 +1,6 @@ import { browser } from '@wdio/globals' -import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' +import { TextSetting } from 'wdio-vscode-service' +import type { SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { $ } from 'zx' @@ -11,26 +12,22 @@ import { pathToNodeHome } from '../constants/config' describe('Settings', () => { let workbench: Workbench let settings: SettingsEditor - let pathToRadBinarySetting: Setting + let pathToRadBinarySetting: TextSetting it('warns the user if the rad binary is not found', async () => { workbench = await browser.getWorkbench() settings = await workbench.openSettings() - pathToRadBinarySetting = await settings.findSetting( - 'Path To Rad Binary', - 'Radicle', - 'Advanced', - ) + pathToRadBinarySetting = await findPathToRadBinarySetting(settings) await expectCliCommandsAndPatchesToBeVisible(workbench) await browser.pause(1000) - await pathToRadBinarySetting.setValue('/tmp') + await setTextSettingValue(pathToRadBinarySetting, '/tmp') await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) - await clearSettingInput(pathToRadBinarySetting) + await clearTextSetting(pathToRadBinarySetting) await expectCliCommandsAndPatchesToBeVisible(workbench) }) @@ -39,18 +36,18 @@ describe('Settings', () => { const tempNodeHomePath = `${pathToNodeHome}.temp` await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` - await pathToRadBinarySetting.setValue(`/tmp`) + await setTextSettingValue(pathToRadBinarySetting, `/tmp`) await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) - await setSettingInputValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) + await setTextSettingValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) await expectCliCommandsAndPatchesToBeVisible(workbench) await $`rm -rf ${tempNodeHomePath}` - await clearSettingInput(pathToRadBinarySetting) + await clearTextSetting(pathToRadBinarySetting) await expectCliCommandsAndPatchesToBeVisible(workbench) }) @@ -80,10 +77,38 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { ) } -async function clearSettingInput(setting: Setting) { - const inputValue = await setting.getValue() - console.log({ inputValue }) +async function findPathToRadBinarySetting(settings: SettingsEditor) { + const pathToRadBinarySetting = await settings.findSetting( + 'Path To Rad Binary', + 'Radicle', + 'Advanced', + ) + + if (!(pathToRadBinarySetting instanceof TextSetting)) { + throw new TypeError('expected pathToRadBinarySetting to be a TextSetting') + } + + return pathToRadBinarySetting +} + +async function getTextSettingInput(setting: TextSetting) { + return (await setting.textSetting$) as WebdriverIO.Element +} + +/** + * Workaround to get the value of a `TextSetting`. + * The `getValue` method of a `TextSetting` seems to be wrongly implemented and returns null. + */ +async function getTextSettingValue(setting: TextSetting) { + return await (await getTextSettingInput(setting)).getValue() +} +async function setTextSettingValue(setting: TextSetting, value: string) { + await clearTextSetting(setting) + await setting.setValue(value) +} + +async function clearTextSetting(setting: TextSetting) { /** * `.setValue('')` updates the value of the input but does not trigger an * update in the extension. Not sure if this is a bug in the extension, vscode, or @@ -91,13 +116,12 @@ async function clearSettingInput(setting: Setting) { * * The following is a workaround that does trigger an update in the extension. */ - // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access - await (await setting.textSetting$).click() + if ((await getTextSettingValue(setting)) === '') { + return + } + + const input = await getTextSettingInput(setting) + await input.click() await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } - -async function setSettingInputValue(setting: Setting, value: string) { - await clearSettingInput(setting) - await setting.setValue(value) -} From 8fc5080cece77c878b5b91dcc71ab4b3cc8fa5e2 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:02:36 +0200 Subject: [PATCH 21/58] test(e2e): remove TextSetting import in favor of Setting Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 012ec441..f2a33bd2 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,6 +1,5 @@ import { browser } from '@wdio/globals' -import { TextSetting } from 'wdio-vscode-service' -import type { SettingsEditor, Workbench } from 'wdio-vscode-service' +import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { $ } from 'zx' @@ -12,12 +11,16 @@ import { pathToNodeHome } from '../constants/config' describe('Settings', () => { let workbench: Workbench let settings: SettingsEditor - let pathToRadBinarySetting: TextSetting + let pathToRadBinarySetting: Setting it('warns the user if the rad binary is not found', async () => { workbench = await browser.getWorkbench() settings = await workbench.openSettings() - pathToRadBinarySetting = await findPathToRadBinarySetting(settings) + pathToRadBinarySetting = await settings.findSetting( + 'Path To Rad Binary', + 'Radicle', + 'Advanced', + ) await expectCliCommandsAndPatchesToBeVisible(workbench) @@ -77,21 +80,7 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { ) } -async function findPathToRadBinarySetting(settings: SettingsEditor) { - const pathToRadBinarySetting = await settings.findSetting( - 'Path To Rad Binary', - 'Radicle', - 'Advanced', - ) - - if (!(pathToRadBinarySetting instanceof TextSetting)) { - throw new TypeError('expected pathToRadBinarySetting to be a TextSetting') - } - - return pathToRadBinarySetting -} - -async function getTextSettingInput(setting: TextSetting) { +async function getTextSettingInput(setting: Setting) { return (await setting.textSetting$) as WebdriverIO.Element } @@ -99,16 +88,16 @@ async function getTextSettingInput(setting: TextSetting) { * Workaround to get the value of a `TextSetting`. * The `getValue` method of a `TextSetting` seems to be wrongly implemented and returns null. */ -async function getTextSettingValue(setting: TextSetting) { +async function getTextSettingValue(setting: Setting) { return await (await getTextSettingInput(setting)).getValue() } -async function setTextSettingValue(setting: TextSetting, value: string) { +async function setTextSettingValue(setting: Setting, value: string) { await clearTextSetting(setting) await setting.setValue(value) } -async function clearTextSetting(setting: TextSetting) { +async function clearTextSetting(setting: Setting) { /** * `.setValue('')` updates the value of the input but does not trigger an * update in the extension. Not sure if this is a bug in the extension, vscode, or From da2b6d90de998f7a83311a0e1ac90ad2ec3fc48f Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:15:22 +0200 Subject: [PATCH 22/58] test(e2e): add test for recognizing directory after updating setting Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index f2a33bd2..03fd88ae 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -54,6 +54,28 @@ describe('Settings', () => { await expectCliCommandsAndPatchesToBeVisible(workbench) }) + + // This functionality does not seem to work + it('recognizes if the directory is created *after* the setting is updated', async () => { + const tempNodeHomePath = `${pathToNodeHome}.temp` + + await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) + + await openRadicleViewContainer(workbench) + await expectRadBinaryNotFoundToBeVisible(workbench) + + await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` + + await expectCliCommandsAndPatchesToBeVisible(workbench) + + await clearTextSetting(pathToRadBinarySetting) + + await $`rm -rf ${tempNodeHomePath}` + + await clearTextSetting(pathToRadBinarySetting) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) }) async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { From 214f57a2260b8f24fc3439c065df7053c461c81c Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:19:27 +0200 Subject: [PATCH 23/58] test(e2e): skip directory creation recognition case Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 03fd88ae..54d21688 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -56,7 +56,8 @@ describe('Settings', () => { }) // This functionality does not seem to work - it('recognizes if the directory is created *after* the setting is updated', async () => { + // eslint-disable-next-line max-len + it.skip('recognizes if the directory is created *after* the setting is updated', async () => { const tempNodeHomePath = `${pathToNodeHome}.temp` await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) From 189c95db8b0362017adc8139204970fd4dd9355a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:22:49 +0200 Subject: [PATCH 24/58] test(e2e): close radicle view container after onboarding suite Signed-off-by: Zacharias Fragkiadakis --- test/e2e/helpers/actions.ts | 10 ++++++++++ test/e2e/specs/onboarding.spec.ts | 6 +++++- test/e2e/specs/settings.spec.ts | 6 +++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/test/e2e/helpers/actions.ts b/test/e2e/helpers/actions.ts index b9fabbcf..268978d7 100644 --- a/test/e2e/helpers/actions.ts +++ b/test/e2e/helpers/actions.ts @@ -13,3 +13,13 @@ export async function openRadicleViewContainer(workbench: Workbench) { await radicleViewControl?.openView() } + +export async function closeRadicleViewContainer(workbench: Workbench) { + const activityBar = workbench.getActivityBar() + await activityBar.wait() + + const radicleViewControl = await activityBar.getViewControl('Radicle') + await radicleViewControl?.wait() + + await radicleViewControl?.closeView() +} diff --git a/test/e2e/specs/onboarding.spec.ts b/test/e2e/specs/onboarding.spec.ts index fff8b4e2..92cba08a 100644 --- a/test/e2e/specs/onboarding.spec.ts +++ b/test/e2e/specs/onboarding.spec.ts @@ -5,7 +5,7 @@ import { $, cd } from 'zx' import type * as VsCode from 'vscode' import isEqual from 'lodash/isEqual' import { expectStandardSidebarViewsToBeVisible } from '../helpers/assertions' -import { openRadicleViewContainer } from '../helpers/actions' +import { closeRadicleViewContainer, openRadicleViewContainer } from '../helpers/actions' import { getFirstWelcomeViewText } from '../helpers/queries' import { backupNodeHomePath, e2eTestDirPath, nodeHomePath } from '../constants/config' @@ -16,6 +16,10 @@ describe('Onboarding Flow', () => { workbench = await browser.getWorkbench() }) + after(async () => { + await closeRadicleViewContainer(workbench) + }) + describe('VS Code, *before* Radicle is installed,', () => { after(async () => { await $`mv ${backupNodeHomePath} ${nodeHomePath}` diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 54d21688..9b4e94c1 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -5,7 +5,7 @@ import { Key } from 'webdriverio' import { $ } from 'zx' import { getFirstWelcomeViewText } from '../helpers/queries' import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' -import { openRadicleViewContainer } from '../helpers/actions' +import { closeRadicleViewContainer, openRadicleViewContainer } from '../helpers/actions' import { pathToNodeHome } from '../constants/config' describe('Settings', () => { @@ -13,6 +13,10 @@ describe('Settings', () => { let settings: SettingsEditor let pathToRadBinarySetting: Setting + after(async () => { + await closeRadicleViewContainer(workbench) + }) + it('warns the user if the rad binary is not found', async () => { workbench = await browser.getWorkbench() settings = await workbench.openSettings() From 7b62e7bcc46e345f9ffadca46399bfa6275e48c0 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:25:43 +0200 Subject: [PATCH 25/58] test(e2e): move worbench and settings init to a before statement Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 9b4e94c1..e72b0b92 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -13,13 +13,16 @@ describe('Settings', () => { let settings: SettingsEditor let pathToRadBinarySetting: Setting + before(async () => { + workbench = await browser.getWorkbench() + settings = await workbench.openSettings() + }) + after(async () => { await closeRadicleViewContainer(workbench) }) it('warns the user if the rad binary is not found', async () => { - workbench = await browser.getWorkbench() - settings = await workbench.openSettings() pathToRadBinarySetting = await settings.findSetting( 'Path To Rad Binary', 'Radicle', From da9564bf7fe49e09c6e9e11ff92c94cabc595fb2 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:26:33 +0200 Subject: [PATCH 26/58] test(e2e): open radicle view container before running settings suite Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index e72b0b92..af84ae42 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -16,6 +16,7 @@ describe('Settings', () => { before(async () => { workbench = await browser.getWorkbench() settings = await workbench.openSettings() + await openRadicleViewContainer(workbench) }) after(async () => { From ff85bd7eeb3a33620283136a1845a938c2c9fd99 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:32:34 +0200 Subject: [PATCH 27/58] test(e2e): add describe statement for path to rad binary setting Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 85 +++++++++++++++++---------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index af84ae42..e23d8973 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -11,7 +11,6 @@ import { pathToNodeHome } from '../constants/config' describe('Settings', () => { let workbench: Workbench let settings: SettingsEditor - let pathToRadBinarySetting: Setting before(async () => { workbench = await browser.getWorkbench() @@ -23,67 +22,73 @@ describe('Settings', () => { await closeRadicleViewContainer(workbench) }) - it('warns the user if the rad binary is not found', async () => { - pathToRadBinarySetting = await settings.findSetting( - 'Path To Rad Binary', - 'Radicle', - 'Advanced', - ) + describe('VS Code, when updating the "Path to Rad Binary" setting,', () => { + let pathToRadBinarySetting: Setting - await expectCliCommandsAndPatchesToBeVisible(workbench) + before(async () => { + pathToRadBinarySetting = await settings.findSetting( + 'Path To Rad Binary', + 'Radicle', + 'Advanced', + ) + }) - await browser.pause(1000) - await setTextSettingValue(pathToRadBinarySetting, '/tmp') + it('warns the user if the rad binary is not found', async () => { + await expectCliCommandsAndPatchesToBeVisible(workbench) - await openRadicleViewContainer(workbench) - await expectRadBinaryNotFoundToBeVisible(workbench) + await browser.pause(1000) + await setTextSettingValue(pathToRadBinarySetting, '/tmp') - await clearTextSetting(pathToRadBinarySetting) + await openRadicleViewContainer(workbench) + await expectRadBinaryNotFoundToBeVisible(workbench) - await expectCliCommandsAndPatchesToBeVisible(workbench) - }) + await clearTextSetting(pathToRadBinarySetting) - it('recognizes the rad binary when a valid path is specified', async () => { - const tempNodeHomePath = `${pathToNodeHome}.temp` - await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) - await setTextSettingValue(pathToRadBinarySetting, `/tmp`) + it('recognizes the rad binary when a valid path is specified', async () => { + const tempNodeHomePath = `${pathToNodeHome}.temp` + await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` - await openRadicleViewContainer(workbench) - await expectRadBinaryNotFoundToBeVisible(workbench) + await setTextSettingValue(pathToRadBinarySetting, `/tmp`) - await setTextSettingValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) + await openRadicleViewContainer(workbench) + await expectRadBinaryNotFoundToBeVisible(workbench) - await expectCliCommandsAndPatchesToBeVisible(workbench) + await setTextSettingValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) - await $`rm -rf ${tempNodeHomePath}` + await expectCliCommandsAndPatchesToBeVisible(workbench) - await clearTextSetting(pathToRadBinarySetting) + await $`rm -rf ${tempNodeHomePath}` - await expectCliCommandsAndPatchesToBeVisible(workbench) - }) + await clearTextSetting(pathToRadBinarySetting) - // This functionality does not seem to work - // eslint-disable-next-line max-len - it.skip('recognizes if the directory is created *after* the setting is updated', async () => { - const tempNodeHomePath = `${pathToNodeHome}.temp` + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) - await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) + // This functionality does not seem to work + // eslint-disable-next-line max-len + it.skip('recognizes if the directory is created *after* the setting is updated', async () => { + const tempNodeHomePath = `${pathToNodeHome}.temp` - await openRadicleViewContainer(workbench) - await expectRadBinaryNotFoundToBeVisible(workbench) + await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) + + await openRadicleViewContainer(workbench) + await expectRadBinaryNotFoundToBeVisible(workbench) - await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` + await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` - await expectCliCommandsAndPatchesToBeVisible(workbench) + await expectCliCommandsAndPatchesToBeVisible(workbench) - await clearTextSetting(pathToRadBinarySetting) + await clearTextSetting(pathToRadBinarySetting) - await $`rm -rf ${tempNodeHomePath}` + await $`rm -rf ${tempNodeHomePath}` - await clearTextSetting(pathToRadBinarySetting) + await clearTextSetting(pathToRadBinarySetting) - await expectCliCommandsAndPatchesToBeVisible(workbench) + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) }) }) From 640aecf8452660a1cd9e1d6825f5a5e623a95aed Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:35:06 +0200 Subject: [PATCH 28/58] test(e2e): add after each statement Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index e23d8973..05059746 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -33,6 +33,12 @@ describe('Settings', () => { ) }) + afterEach(async () => { + await clearTextSetting(pathToRadBinarySetting) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + }) + it('warns the user if the rad binary is not found', async () => { await expectCliCommandsAndPatchesToBeVisible(workbench) @@ -41,10 +47,6 @@ describe('Settings', () => { await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) - - await clearTextSetting(pathToRadBinarySetting) - - await expectCliCommandsAndPatchesToBeVisible(workbench) }) it('recognizes the rad binary when a valid path is specified', async () => { @@ -61,10 +63,6 @@ describe('Settings', () => { await expectCliCommandsAndPatchesToBeVisible(workbench) await $`rm -rf ${tempNodeHomePath}` - - await clearTextSetting(pathToRadBinarySetting) - - await expectCliCommandsAndPatchesToBeVisible(workbench) }) // This functionality does not seem to work @@ -84,10 +82,6 @@ describe('Settings', () => { await clearTextSetting(pathToRadBinarySetting) await $`rm -rf ${tempNodeHomePath}` - - await clearTextSetting(pathToRadBinarySetting) - - await expectCliCommandsAndPatchesToBeVisible(workbench) }) }) }) From 5136bf640ccce9d21c7e3d65851272814c4641b6 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 12:37:47 +0200 Subject: [PATCH 29/58] test(e2e): move initial state assertion to top level before statement Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 05059746..63fc338e 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -14,8 +14,11 @@ describe('Settings', () => { before(async () => { workbench = await browser.getWorkbench() - settings = await workbench.openSettings() await openRadicleViewContainer(workbench) + + await expectCliCommandsAndPatchesToBeVisible(workbench) + + settings = await workbench.openSettings() }) after(async () => { @@ -40,8 +43,6 @@ describe('Settings', () => { }) it('warns the user if the rad binary is not found', async () => { - await expectCliCommandsAndPatchesToBeVisible(workbench) - await browser.pause(1000) await setTextSettingValue(pathToRadBinarySetting, '/tmp') From 0f19c416c56fc377af649dff10592ec207f497cd Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 15:40:51 +0200 Subject: [PATCH 30/58] test(e2e): move initial assertion after opening settings Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 63fc338e..b7b7dc37 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -14,11 +14,9 @@ describe('Settings', () => { before(async () => { workbench = await browser.getWorkbench() + settings = await workbench.openSettings() await openRadicleViewContainer(workbench) - await expectCliCommandsAndPatchesToBeVisible(workbench) - - settings = await workbench.openSettings() }) after(async () => { From bf92a8e271bfb8b63354fe315f3589c8f4af3f8a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 15:59:28 +0200 Subject: [PATCH 31/58] test(e2e): do not open radicle sidebar view before assertion Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index b7b7dc37..2c4f6542 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -44,7 +44,6 @@ describe('Settings', () => { await browser.pause(1000) await setTextSettingValue(pathToRadBinarySetting, '/tmp') - await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) }) From d458f4ebf33664f74a65e788ad1ce21a8f89e5cd Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 16:06:25 +0200 Subject: [PATCH 32/58] test(e2e): do not open radicle sidebar view before any assertions Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 2c4f6542..1bc650e9 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -53,7 +53,6 @@ describe('Settings', () => { await setTextSettingValue(pathToRadBinarySetting, `/tmp`) - await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) await setTextSettingValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) @@ -70,7 +69,6 @@ describe('Settings', () => { await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) - await openRadicleViewContainer(workbench) await expectRadBinaryNotFoundToBeVisible(workbench) await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` From 02d18a9d5eb95a4051004b440aac2edb656a552a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 28 Dec 2024 16:10:15 +0200 Subject: [PATCH 33/58] test(e2e): use chainable promises in settings.spec.ts Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 1bc650e9..a49a19e2 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,7 +1,7 @@ import { browser } from '@wdio/globals' import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' -import { Key } from 'webdriverio' +import { type ChainablePromiseElement, Key } from 'webdriverio' import { $ } from 'zx' import { getFirstWelcomeViewText } from '../helpers/queries' import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' @@ -106,8 +106,8 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { ) } -async function getTextSettingInput(setting: Setting) { - return (await setting.textSetting$) as WebdriverIO.Element +function getTextSettingInput(setting: Setting) { + return setting.textSetting$ as ChainablePromiseElement } /** @@ -115,7 +115,7 @@ async function getTextSettingInput(setting: Setting) { * The `getValue` method of a `TextSetting` seems to be wrongly implemented and returns null. */ async function getTextSettingValue(setting: Setting) { - return await (await getTextSettingInput(setting)).getValue() + return await getTextSettingInput(setting).getValue() } async function setTextSettingValue(setting: Setting, value: string) { @@ -135,8 +135,7 @@ async function clearTextSetting(setting: Setting) { return } - const input = await getTextSettingInput(setting) - await input.click() + await getTextSettingInput(setting).click() await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } From f774ec326e085d5b1bbfe72fe48caab50d69ee26 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Mon, 30 Dec 2024 20:03:15 +0200 Subject: [PATCH 34/58] chore(e2e): fix rebase ts errors Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index a49a19e2..3cecb5a1 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,12 +1,12 @@ import { browser } from '@wdio/globals' import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' -import { type ChainablePromiseElement, Key } from 'webdriverio' +import { Key } from 'webdriverio' import { $ } from 'zx' import { getFirstWelcomeViewText } from '../helpers/queries' import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' import { closeRadicleViewContainer, openRadicleViewContainer } from '../helpers/actions' -import { pathToNodeHome } from '../constants/config' +import { nodeHomePath } from '../constants/config' describe('Settings', () => { let workbench: Workbench @@ -48,8 +48,8 @@ describe('Settings', () => { }) it('recognizes the rad binary when a valid path is specified', async () => { - const tempNodeHomePath = `${pathToNodeHome}.temp` - await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` + const tempNodeHomePath = `${nodeHomePath}.temp` + await $`cp -r ${nodeHomePath} ${tempNodeHomePath}` await setTextSettingValue(pathToRadBinarySetting, `/tmp`) @@ -65,13 +65,13 @@ describe('Settings', () => { // This functionality does not seem to work // eslint-disable-next-line max-len it.skip('recognizes if the directory is created *after* the setting is updated', async () => { - const tempNodeHomePath = `${pathToNodeHome}.temp` + const tempNodeHomePath = `${nodeHomePath}.temp` await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) await expectRadBinaryNotFoundToBeVisible(workbench) - await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}` + await $`cp -r ${nodeHomePath} ${tempNodeHomePath}` await expectCliCommandsAndPatchesToBeVisible(workbench) @@ -106,16 +106,12 @@ async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { ) } -function getTextSettingInput(setting: Setting) { - return setting.textSetting$ as ChainablePromiseElement -} - /** * Workaround to get the value of a `TextSetting`. * The `getValue` method of a `TextSetting` seems to be wrongly implemented and returns null. */ async function getTextSettingValue(setting: Setting) { - return await getTextSettingInput(setting).getValue() + return await setting.textSetting$.getValue() } async function setTextSettingValue(setting: Setting, value: string) { @@ -135,7 +131,7 @@ async function clearTextSetting(setting: Setting) { return } - await getTextSettingInput(setting).click() + await setting.textSetting$.click() await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } From a7272e92808dd4991071e466d6cbf54e0c79a5a4 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Mon, 30 Dec 2024 20:08:48 +0200 Subject: [PATCH 35/58] test(e2e): remove pause before updating input Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 3cecb5a1..20a5bf00 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -41,7 +41,6 @@ describe('Settings', () => { }) it('warns the user if the rad binary is not found', async () => { - await browser.pause(1000) await setTextSettingValue(pathToRadBinarySetting, '/tmp') await expectRadBinaryNotFoundToBeVisible(workbench) From dafb965734cbddf1cad07d74a53792e5274a473f Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Mon, 30 Dec 2024 20:12:57 +0200 Subject: [PATCH 36/58] revert: "test(e2e): remove pause before updating input" This reverts commit b927a0cff7690467a0baf4dedc55a6e1c23bb7d7. Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 20a5bf00..3cecb5a1 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -41,6 +41,7 @@ describe('Settings', () => { }) it('warns the user if the rad binary is not found', async () => { + await browser.pause(1000) await setTextSettingValue(pathToRadBinarySetting, '/tmp') await expectRadBinaryNotFoundToBeVisible(workbench) From ca3a0e270fa25d432f2a881e29b404c2d87b3649 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 11:07:52 +0200 Subject: [PATCH 37/58] test(e2e): write draft for initial path to node home test Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 3cecb5a1..17720935 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -80,6 +80,43 @@ describe('Settings', () => { await $`rm -rf ${tempNodeHomePath}` }) }) + + describe('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { + it('displays error in output console', async () => { + // Close and re-open the settings editor (to clear the input) + await browser.keys([Key.Ctrl, 'w']) + await browser.pause(1000) // TODO: zac check if this is necessary + settings = await workbench.openSettings() + + // Set the path to a non-existent directory + const pathToNodeHomeSetting = await settings.findSetting( + 'Path To Node Home', + 'Radicle', + 'Advanced', + ) + await browser.pause(1000) // TODO: zac check if this is necessary + await setTextSettingValue(pathToNodeHomeSetting, '/tmp') + + // Assert that the error message is displayed in the output console + await workbench.executeCommand('Show Everything Logged in the Output Panel') + const outputView = await workbench.getBottomBar().openOutputView() + await outputView.selectChannel('Radicle') + + await browser.waitUntil( + async () => { + const text = await outputView.getText() + console.log({ text }) + + return text.some((line) => + line.includes( + 'Found non-authenticated identity ✗ Error: Radicle profile not found in', + ), + ) + }, + { timeoutMsg: 'expected the error message to be displayed in the output console' }, + ) + }) + }) }) async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { From 81971e00f2f18bd1705bf8c2e84de00e2efa6f20 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 11:30:14 +0200 Subject: [PATCH 38/58] test(e2e): clear output and join text before asserting error Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 17720935..d0019939 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -88,6 +88,11 @@ describe('Settings', () => { await browser.pause(1000) // TODO: zac check if this is necessary settings = await workbench.openSettings() + await workbench.executeCommand('Show Everything Logged in the Output Panel') + let outputView = await workbench.getBottomBar().openOutputView() + await outputView.selectChannel('Radicle') + await outputView.clearText() + // Set the path to a non-existent directory const pathToNodeHomeSetting = await settings.findSetting( 'Path To Node Home', @@ -98,19 +103,18 @@ describe('Settings', () => { await setTextSettingValue(pathToNodeHomeSetting, '/tmp') // Assert that the error message is displayed in the output console - await workbench.executeCommand('Show Everything Logged in the Output Panel') - const outputView = await workbench.getBottomBar().openOutputView() + outputView = await workbench.getBottomBar().openOutputView() await outputView.selectChannel('Radicle') await browser.waitUntil( async () => { const text = await outputView.getText() - console.log({ text }) + const joinedText = text.join('') + + console.log({ text, joinedText }) - return text.some((line) => - line.includes( - 'Found non-authenticated identity ✗ Error: Radicle profile not found in', - ), + return joinedText.includes( + 'Found non-authenticated identity ✗ Error: Radicle profile not found in', ) }, { timeoutMsg: 'expected the error message to be displayed in the output console' }, From 127f19596fd537f3a7653dbe7e3b3f34c1621e09 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 11:40:36 +0200 Subject: [PATCH 39/58] refactor(e2e): fix rebase error Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index d0019939..2fa3e712 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -4,7 +4,7 @@ import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { $ } from 'zx' import { getFirstWelcomeViewText } from '../helpers/queries' -import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions' +import { expectStandardSidebarViewsToBeVisible } from '../helpers/assertions' import { closeRadicleViewContainer, openRadicleViewContainer } from '../helpers/actions' import { nodeHomePath } from '../constants/config' @@ -16,7 +16,7 @@ describe('Settings', () => { workbench = await browser.getWorkbench() settings = await workbench.openSettings() await openRadicleViewContainer(workbench) - await expectCliCommandsAndPatchesToBeVisible(workbench) + await expectStandardSidebarViewsToBeVisible(workbench) }) after(async () => { @@ -37,7 +37,7 @@ describe('Settings', () => { afterEach(async () => { await clearTextSetting(pathToRadBinarySetting) - await expectCliCommandsAndPatchesToBeVisible(workbench) + await expectStandardSidebarViewsToBeVisible(workbench) }) it('warns the user if the rad binary is not found', async () => { @@ -57,7 +57,7 @@ describe('Settings', () => { await setTextSettingValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) - await expectCliCommandsAndPatchesToBeVisible(workbench) + await expectStandardSidebarViewsToBeVisible(workbench) await $`rm -rf ${tempNodeHomePath}` }) @@ -73,7 +73,7 @@ describe('Settings', () => { await $`cp -r ${nodeHomePath} ${tempNodeHomePath}` - await expectCliCommandsAndPatchesToBeVisible(workbench) + await expectStandardSidebarViewsToBeVisible(workbench) await clearTextSetting(pathToRadBinarySetting) From 82c966b84770371525610b37064dc4da1c22697b Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 11:52:00 +0200 Subject: [PATCH 40/58] test(e2e): do not re-select outputview Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 2fa3e712..6056e62c 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -89,7 +89,7 @@ describe('Settings', () => { settings = await workbench.openSettings() await workbench.executeCommand('Show Everything Logged in the Output Panel') - let outputView = await workbench.getBottomBar().openOutputView() + const outputView = await workbench.getBottomBar().openOutputView() await outputView.selectChannel('Radicle') await outputView.clearText() @@ -103,9 +103,6 @@ describe('Settings', () => { await setTextSettingValue(pathToNodeHomeSetting, '/tmp') // Assert that the error message is displayed in the output console - outputView = await workbench.getBottomBar().openOutputView() - await outputView.selectChannel('Radicle') - await browser.waitUntil( async () => { const text = await outputView.getText() From 98b135e6bc8d99abd0f3dbe99f2a941da3aa6858 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 11:55:35 +0200 Subject: [PATCH 41/58] test(e2e): do not select radicle channel on output view Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 6056e62c..3767a4aa 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -90,7 +90,6 @@ describe('Settings', () => { await workbench.executeCommand('Show Everything Logged in the Output Panel') const outputView = await workbench.getBottomBar().openOutputView() - await outputView.selectChannel('Radicle') await outputView.clearText() // Set the path to a non-existent directory From b9fcf69a0d5d37e96db3f1de44e29ceb7ed92b55 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:29:18 +0200 Subject: [PATCH 42/58] test(e2e): clear settings searchbox after first describe Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 3767a4aa..8e0c3012 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -34,6 +34,13 @@ describe('Settings', () => { ) }) + after(async () => { + const searchBox = await getSettingsSearchBox(settings) + await clearInput(searchBox) + + expect(searchBox.getValue()).toBe('') + }) + afterEach(async () => { await clearTextSetting(pathToRadBinarySetting) @@ -83,11 +90,6 @@ describe('Settings', () => { describe('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { it('displays error in output console', async () => { - // Close and re-open the settings editor (to clear the input) - await browser.keys([Key.Ctrl, 'w']) - await browser.pause(1000) // TODO: zac check if this is necessary - settings = await workbench.openSettings() - await workbench.executeCommand('Show Everything Logged in the Output Panel') const outputView = await workbench.getBottomBar().openOutputView() await outputView.clearText() @@ -172,3 +174,13 @@ async function clearTextSetting(setting: Setting) { await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } + +async function getSettingsSearchBox(settings: SettingsEditor) { + return await settings.elem.$(settings.locatorMap.Editor['inputArea'] as string) +} + +async function clearInput(input: WebdriverIO.Element) { + await input.setValue('') + await browser.keys([Key.Ctrl, 'a']) + await browser.keys(Key.Backspace) +} From 5ab76f247f7e9ab17176f5463bb9937aabaeb555 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:34:48 +0200 Subject: [PATCH 43/58] test(e2e): remove empty input assertion Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 8e0c3012..1396cf74 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -37,8 +37,6 @@ describe('Settings', () => { after(async () => { const searchBox = await getSettingsSearchBox(settings) await clearInput(searchBox) - - expect(searchBox.getValue()).toBe('') }) afterEach(async () => { From 76abf32c34a8d5e011631a56815711f67a6066f1 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:39:06 +0200 Subject: [PATCH 44/58] test(e2e): copy after statement to path to node home setting Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 1396cf74..582659aa 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -87,6 +87,11 @@ describe('Settings', () => { }) describe('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { + after(async () => { + const searchBox = await getSettingsSearchBox(settings) + await clearInput(searchBox) + }) + it('displays error in output console', async () => { await workbench.executeCommand('Show Everything Logged in the Output Panel') const outputView = await workbench.getBottomBar().openOutputView() From 975ff4a1d81a7cedb8993835f1ed9f56f5b2fba9 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:40:41 +0200 Subject: [PATCH 45/58] test(e2e): move findSetting to before statement Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 582659aa..001439df 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -87,6 +87,16 @@ describe('Settings', () => { }) describe('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { + let pathToNodeHomeSetting: Setting + + before(async () => { + pathToNodeHomeSetting = await settings.findSetting( + 'Path To Node Home', + 'Radicle', + 'Advanced', + ) + }) + after(async () => { const searchBox = await getSettingsSearchBox(settings) await clearInput(searchBox) @@ -98,11 +108,6 @@ describe('Settings', () => { await outputView.clearText() // Set the path to a non-existent directory - const pathToNodeHomeSetting = await settings.findSetting( - 'Path To Node Home', - 'Radicle', - 'Advanced', - ) await browser.pause(1000) // TODO: zac check if this is necessary await setTextSettingValue(pathToNodeHomeSetting, '/tmp') From 1f10c51e6f6b4dec1a27ffd3b906e655646fa661 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:41:45 +0200 Subject: [PATCH 46/58] test(e2e): remove browser pause before setting input value Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 001439df..7d9f9c4f 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -108,7 +108,6 @@ describe('Settings', () => { await outputView.clearText() // Set the path to a non-existent directory - await browser.pause(1000) // TODO: zac check if this is necessary await setTextSettingValue(pathToNodeHomeSetting, '/tmp') // Assert that the error message is displayed in the output console From c325d8281c41e241bce7b8f99f957d1ac9414f2a Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:46:47 +0200 Subject: [PATCH 47/58] test(e2e): refactor waitUntil statement Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 7d9f9c4f..aef35cfb 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -113,14 +113,9 @@ describe('Settings', () => { // Assert that the error message is displayed in the output console await browser.waitUntil( async () => { - const text = await outputView.getText() - const joinedText = text.join('') + const joinedText = (await outputView.getText()).join('') - console.log({ text, joinedText }) - - return joinedText.includes( - 'Found non-authenticated identity ✗ Error: Radicle profile not found in', - ) + return joinedText.includes('✗ Error: Radicle profile not found in') }, { timeoutMsg: 'expected the error message to be displayed in the output console' }, ) From 0d990669dc77e0e430cf9ba3dbaa9fbd6c4cea9b Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:55:01 +0200 Subject: [PATCH 48/58] test(e2e): clear setting input and wait for output update Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index aef35cfb..573190ac 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,5 +1,5 @@ import { browser } from '@wdio/globals' -import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' +import type { OutputView, Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { $ } from 'zx' @@ -111,14 +111,12 @@ describe('Settings', () => { await setTextSettingValue(pathToNodeHomeSetting, '/tmp') // Assert that the error message is displayed in the output console - await browser.waitUntil( - async () => { - const joinedText = (await outputView.getText()).join('') + await expectOutputToContain(outputView, '✗ Error: Radicle profile not found in') - return joinedText.includes('✗ Error: Radicle profile not found in') - }, - { timeoutMsg: 'expected the error message to be displayed in the output console' }, - ) + await outputView.clearText() + await clearTextSetting(pathToNodeHomeSetting) + + await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') }) }) }) @@ -186,3 +184,20 @@ async function clearInput(input: WebdriverIO.Element) { await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } + +async function expectOutputToContain(outputView: OutputView, expected: string) { + await browser.waitUntil( + async () => { + /** + * The text in the output console is split by newlines, which can be affected by the size + * of the window. To avoid this, we join the text into a single string. + */ + const joinedText = (await outputView.getText()).join('') + + return joinedText.includes(expected) + }, + { + timeoutMsg: `expected the output text to contain "${expected}"`, + }, + ) +} From a1690c81d0aa0b5ac39100cd1350def6737fe391 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:58:31 +0200 Subject: [PATCH 49/58] test(e2e): log joined text Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 573190ac..a30b919d 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -193,6 +193,7 @@ async function expectOutputToContain(outputView: OutputView, expected: string) { * of the window. To avoid this, we join the text into a single string. */ const joinedText = (await outputView.getText()).join('') + console.log({ joinedText }) return joinedText.includes(expected) }, From bb63f2b391438e6c1f3fe0e4f20a624c6d3783d3 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 09:58:29 +0200 Subject: [PATCH 50/58] test(e2e): skip first settings suite Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index a30b919d..d80dec44 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -23,7 +23,7 @@ describe('Settings', () => { await closeRadicleViewContainer(workbench) }) - describe('VS Code, when updating the "Path to Rad Binary" setting,', () => { + describe.skip('VS Code, when updating the "Path to Rad Binary" setting,', () => { let pathToRadBinarySetting: Setting before(async () => { From c66b63f6b43efc93c8f055403717679a3170f5e7 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 10:02:17 +0200 Subject: [PATCH 51/58] test(e2e): skip all settings suite Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index d80dec44..13831167 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -86,7 +86,7 @@ describe('Settings', () => { }) }) - describe('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { + describe.skip('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { let pathToNodeHomeSetting: Setting before(async () => { From 317fff0d5a4036d13b60701ab6b5c21387276ba9 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 10:05:36 +0200 Subject: [PATCH 52/58] test(debug): verify httpd is recognized in ubuntu Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index 13831167..f6a2adde 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -119,6 +119,14 @@ describe('Settings', () => { await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') }) }) + + it('receives success responses from httpd', async () => { + await workbench.executeCommand('Show Everything Logged in the Output Panel') + const outputView = await workbench.getBottomBar().openOutputView() + await outputView.clearText() + + await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') + }) }) async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { From 127bad1fb4da5d5cf12ecef6d62142124acfb647 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 10:08:23 +0200 Subject: [PATCH 53/58] test(debug): don't clear output Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index f6a2adde..198d9037 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -123,7 +123,6 @@ describe('Settings', () => { it('receives success responses from httpd', async () => { await workbench.executeCommand('Show Everything Logged in the Output Panel') const outputView = await workbench.getBottomBar().openOutputView() - await outputView.clearText() await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') }) From b89175ce691264848b8592a0a221a7ddf75e0947 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 10:19:51 +0200 Subject: [PATCH 54/58] test(debug): write new suite to verify httpd Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/httpd.spec.ts | 30 ++++++++++++++++++++++++++++++ test/e2e/wdio.conf.ts | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/e2e/specs/httpd.spec.ts diff --git a/test/e2e/specs/httpd.spec.ts b/test/e2e/specs/httpd.spec.ts new file mode 100644 index 00000000..ec7fbb0e --- /dev/null +++ b/test/e2e/specs/httpd.spec.ts @@ -0,0 +1,30 @@ +import { browser } from '@wdio/globals' +import type { OutputView } from 'wdio-vscode-service' + +describe('Httpd', () => { + it('receives success responses from httpd', async () => { + const workbench = await browser.getWorkbench() + await workbench.executeCommand('Show Everything Logged in the Output Panel') + const outputView = await workbench.getBottomBar().openOutputView() + + await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') + }) +}) + +async function expectOutputToContain(outputView: OutputView, expected: string) { + await browser.waitUntil( + async () => { + /** + * The text in the output console is split by newlines, which can be affected by the size + * of the window. To avoid this, we join the text into a single string. + */ + const joinedText = (await outputView.getText()).join('') + console.log({ joinedText }) + + return joinedText.includes(expected) + }, + { + timeoutMsg: `expected the output text to contain "${expected}"`, + }, + ) +} diff --git a/test/e2e/wdio.conf.ts b/test/e2e/wdio.conf.ts index 801eed67..1e1015e2 100644 --- a/test/e2e/wdio.conf.ts +++ b/test/e2e/wdio.conf.ts @@ -29,7 +29,7 @@ export const config: Options.Testrunner = { transpileOnly: true, }, }, - specs: [['./specs/onboarding.spec.ts', './specs/settings.spec.ts']], + specs: ['./specs/httpd.spec.ts'], maxInstances: 10, capabilities: [ { From 816b4b8deb3f0c0c203ec991d06acd57adf8754d Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 10:37:47 +0200 Subject: [PATCH 55/58] test(debug): manually set node home path to RAD_HOMe Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/httpd.spec.ts | 57 +++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/httpd.spec.ts b/test/e2e/specs/httpd.spec.ts index ec7fbb0e..eb20073a 100644 --- a/test/e2e/specs/httpd.spec.ts +++ b/test/e2e/specs/httpd.spec.ts @@ -1,5 +1,7 @@ import { browser } from '@wdio/globals' -import type { OutputView } from 'wdio-vscode-service' +import type { OutputView, Setting, SettingsEditor } from 'wdio-vscode-service' +import { Key } from 'webdriverio' +import { nodeHomePath } from '../constants/config' describe('Httpd', () => { it('receives success responses from httpd', async () => { @@ -7,6 +9,19 @@ describe('Httpd', () => { await workbench.executeCommand('Show Everything Logged in the Output Panel') const outputView = await workbench.getBottomBar().openOutputView() + const settings = await workbench.openSettings() + const pathToNodeHomeSetting = await settings.findSetting( + 'Path To Node Home', + 'Radicle', + 'Advanced', + ) + + await browser.waitUntil(async () => { + await setTextSettingValue(pathToNodeHomeSetting, nodeHomePath ?? '') + + return (await getTextSettingValue(pathToNodeHomeSetting)) === nodeHomePath + }) + await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') }) }) @@ -28,3 +43,43 @@ async function expectOutputToContain(outputView: OutputView, expected: string) { }, ) } + +/** + * Workaround to get the value of a `TextSetting`. + * The `getValue` method of a `TextSetting` seems to be wrongly implemented and returns null. + */ +async function getTextSettingValue(setting: Setting) { + return await setting.textSetting$.getValue() +} + +async function setTextSettingValue(setting: Setting, value: string) { + await clearTextSetting(setting) + await setting.setValue(value) +} + +async function clearTextSetting(setting: Setting) { + /** + * `.setValue('')` updates the value of the input but does not trigger an + * update in the extension. Not sure if this is a bug in the extension, vscode, or + * webdriverio. + * + * The following is a workaround that does trigger an update in the extension. + */ + if ((await getTextSettingValue(setting)) === '') { + return + } + + await setting.textSetting$.click() + await browser.keys([Key.Ctrl, 'a']) + await browser.keys(Key.Backspace) +} + +async function getSettingsSearchBox(settings: SettingsEditor) { + return await settings.elem.$(settings.locatorMap.Editor['inputArea'] as string) +} + +async function clearInput(input: WebdriverIO.Element) { + await input.setValue('') + await browser.keys([Key.Ctrl, 'a']) + await browser.keys(Key.Backspace) +} From f22941521350d87d0b97c7f861e517e9ea8d682f Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sat, 4 Jan 2025 10:44:02 +0200 Subject: [PATCH 56/58] test(debug): log rad self Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/httpd.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e/specs/httpd.spec.ts b/test/e2e/specs/httpd.spec.ts index eb20073a..36591933 100644 --- a/test/e2e/specs/httpd.spec.ts +++ b/test/e2e/specs/httpd.spec.ts @@ -1,6 +1,7 @@ import { browser } from '@wdio/globals' import type { OutputView, Setting, SettingsEditor } from 'wdio-vscode-service' import { Key } from 'webdriverio' +import { $ } from 'zx' import { nodeHomePath } from '../constants/config' describe('Httpd', () => { @@ -22,6 +23,9 @@ describe('Httpd', () => { return (await getTextSettingValue(pathToNodeHomeSetting)) === nodeHomePath }) + const radSelf = await $`rad self` + console.log({ radSelf }) + await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') }) }) From e5f133d239ba4f90cedef533a68f0a4d165245b4 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sun, 26 Jan 2025 12:05:13 +0200 Subject: [PATCH 57/58] test(e2e): delete settings.spec.ts Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 211 -------------------------------- 1 file changed, 211 deletions(-) delete mode 100644 test/e2e/specs/settings.spec.ts diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts deleted file mode 100644 index 198d9037..00000000 --- a/test/e2e/specs/settings.spec.ts +++ /dev/null @@ -1,211 +0,0 @@ -import { browser } from '@wdio/globals' -import type { OutputView, Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' -import isEqual from 'lodash/isEqual' -import { Key } from 'webdriverio' -import { $ } from 'zx' -import { getFirstWelcomeViewText } from '../helpers/queries' -import { expectStandardSidebarViewsToBeVisible } from '../helpers/assertions' -import { closeRadicleViewContainer, openRadicleViewContainer } from '../helpers/actions' -import { nodeHomePath } from '../constants/config' - -describe('Settings', () => { - let workbench: Workbench - let settings: SettingsEditor - - before(async () => { - workbench = await browser.getWorkbench() - settings = await workbench.openSettings() - await openRadicleViewContainer(workbench) - await expectStandardSidebarViewsToBeVisible(workbench) - }) - - after(async () => { - await closeRadicleViewContainer(workbench) - }) - - describe.skip('VS Code, when updating the "Path to Rad Binary" setting,', () => { - let pathToRadBinarySetting: Setting - - before(async () => { - pathToRadBinarySetting = await settings.findSetting( - 'Path To Rad Binary', - 'Radicle', - 'Advanced', - ) - }) - - after(async () => { - const searchBox = await getSettingsSearchBox(settings) - await clearInput(searchBox) - }) - - afterEach(async () => { - await clearTextSetting(pathToRadBinarySetting) - - await expectStandardSidebarViewsToBeVisible(workbench) - }) - - it('warns the user if the rad binary is not found', async () => { - await browser.pause(1000) - await setTextSettingValue(pathToRadBinarySetting, '/tmp') - - await expectRadBinaryNotFoundToBeVisible(workbench) - }) - - it('recognizes the rad binary when a valid path is specified', async () => { - const tempNodeHomePath = `${nodeHomePath}.temp` - await $`cp -r ${nodeHomePath} ${tempNodeHomePath}` - - await setTextSettingValue(pathToRadBinarySetting, `/tmp`) - - await expectRadBinaryNotFoundToBeVisible(workbench) - - await setTextSettingValue(pathToRadBinarySetting, `${tempNodeHomePath}/bin/rad`) - - await expectStandardSidebarViewsToBeVisible(workbench) - - await $`rm -rf ${tempNodeHomePath}` - }) - - // This functionality does not seem to work - // eslint-disable-next-line max-len - it.skip('recognizes if the directory is created *after* the setting is updated', async () => { - const tempNodeHomePath = `${nodeHomePath}.temp` - - await setTextSettingValue(pathToRadBinarySetting, tempNodeHomePath) - - await expectRadBinaryNotFoundToBeVisible(workbench) - - await $`cp -r ${nodeHomePath} ${tempNodeHomePath}` - - await expectStandardSidebarViewsToBeVisible(workbench) - - await clearTextSetting(pathToRadBinarySetting) - - await $`rm -rf ${tempNodeHomePath}` - }) - }) - - describe.skip('VS Code, when updating the "Path to Radicle to Node Home" setting,', () => { - let pathToNodeHomeSetting: Setting - - before(async () => { - pathToNodeHomeSetting = await settings.findSetting( - 'Path To Node Home', - 'Radicle', - 'Advanced', - ) - }) - - after(async () => { - const searchBox = await getSettingsSearchBox(settings) - await clearInput(searchBox) - }) - - it('displays error in output console', async () => { - await workbench.executeCommand('Show Everything Logged in the Output Panel') - const outputView = await workbench.getBottomBar().openOutputView() - await outputView.clearText() - - // Set the path to a non-existent directory - await setTextSettingValue(pathToNodeHomeSetting, '/tmp') - - // Assert that the error message is displayed in the output console - await expectOutputToContain(outputView, '✗ Error: Radicle profile not found in') - - await outputView.clearText() - await clearTextSetting(pathToNodeHomeSetting) - - await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') - }) - }) - - it('receives success responses from httpd', async () => { - await workbench.executeCommand('Show Everything Logged in the Output Panel') - const outputView = await workbench.getBottomBar().openOutputView() - - await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') - }) -}) - -async function expectRadBinaryNotFoundToBeVisible(workbench: Workbench) { - await browser.waitUntil( - async () => { - const welcomeText = await getFirstWelcomeViewText(workbench) - - console.log({ welcomeText }) - - return isEqual(welcomeText, [ - /* eslint-disable max-len */ - 'Failed resolving the Radicle CLI binary.', - "Please ensure it is installed on your machine and either that it is globally accessible in the shell as `rad` or that its path is correctly defined in the extension's settings.", - "Please expect the extention's capabilities to remain severely limited until this issue is resolved.", - /* eslint-enable max-len */ - ]) - }, - { - timeoutMsg: 'expected the rad binary not found message to be visible', - // TODO: zac fine tune these (globally?) - timeout: 20000, - interval: 500, - }, - ) -} - -/** - * Workaround to get the value of a `TextSetting`. - * The `getValue` method of a `TextSetting` seems to be wrongly implemented and returns null. - */ -async function getTextSettingValue(setting: Setting) { - return await setting.textSetting$.getValue() -} - -async function setTextSettingValue(setting: Setting, value: string) { - await clearTextSetting(setting) - await setting.setValue(value) -} - -async function clearTextSetting(setting: Setting) { - /** - * `.setValue('')` updates the value of the input but does not trigger an - * update in the extension. Not sure if this is a bug in the extension, vscode, or - * webdriverio. - * - * The following is a workaround that does trigger an update in the extension. - */ - if ((await getTextSettingValue(setting)) === '') { - return - } - - await setting.textSetting$.click() - await browser.keys([Key.Ctrl, 'a']) - await browser.keys(Key.Backspace) -} - -async function getSettingsSearchBox(settings: SettingsEditor) { - return await settings.elem.$(settings.locatorMap.Editor['inputArea'] as string) -} - -async function clearInput(input: WebdriverIO.Element) { - await input.setValue('') - await browser.keys([Key.Ctrl, 'a']) - await browser.keys(Key.Backspace) -} - -async function expectOutputToContain(outputView: OutputView, expected: string) { - await browser.waitUntil( - async () => { - /** - * The text in the output console is split by newlines, which can be affected by the size - * of the window. To avoid this, we join the text into a single string. - */ - const joinedText = (await outputView.getText()).join('') - console.log({ joinedText }) - - return joinedText.includes(expected) - }, - { - timeoutMsg: `expected the output text to contain "${expected}"`, - }, - ) -} From 57bf3f0ac8cdc26b7b349ae86310bf4dd982b693 Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Sun, 26 Jan 2025 12:20:46 +0200 Subject: [PATCH 58/58] test(debug): cleanup Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/httpd.spec.ts | 14 +-- test/e2e/specs/onboarding.spec.ts | 162 ------------------------------ 2 files changed, 2 insertions(+), 174 deletions(-) delete mode 100644 test/e2e/specs/onboarding.spec.ts diff --git a/test/e2e/specs/httpd.spec.ts b/test/e2e/specs/httpd.spec.ts index 36591933..57ee169b 100644 --- a/test/e2e/specs/httpd.spec.ts +++ b/test/e2e/specs/httpd.spec.ts @@ -1,11 +1,11 @@ import { browser } from '@wdio/globals' -import type { OutputView, Setting, SettingsEditor } from 'wdio-vscode-service' +import type { OutputView, Setting } from 'wdio-vscode-service' import { Key } from 'webdriverio' import { $ } from 'zx' import { nodeHomePath } from '../constants/config' describe('Httpd', () => { - it('receives success responses from httpd', async () => { + it('finds and uses radicle identity', async () => { const workbench = await browser.getWorkbench() await workbench.executeCommand('Show Everything Logged in the Output Panel') const outputView = await workbench.getBottomBar().openOutputView() @@ -77,13 +77,3 @@ async function clearTextSetting(setting: Setting) { await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } - -async function getSettingsSearchBox(settings: SettingsEditor) { - return await settings.elem.$(settings.locatorMap.Editor['inputArea'] as string) -} - -async function clearInput(input: WebdriverIO.Element) { - await input.setValue('') - await browser.keys([Key.Ctrl, 'a']) - await browser.keys(Key.Backspace) -} diff --git a/test/e2e/specs/onboarding.spec.ts b/test/e2e/specs/onboarding.spec.ts deleted file mode 100644 index 92cba08a..00000000 --- a/test/e2e/specs/onboarding.spec.ts +++ /dev/null @@ -1,162 +0,0 @@ -import path from 'node:path' -import { browser, expect } from '@wdio/globals' -import type { Workbench } from 'wdio-vscode-service' -import { $, cd } from 'zx' -import type * as VsCode from 'vscode' -import isEqual from 'lodash/isEqual' -import { expectStandardSidebarViewsToBeVisible } from '../helpers/assertions' -import { closeRadicleViewContainer, openRadicleViewContainer } from '../helpers/actions' -import { getFirstWelcomeViewText } from '../helpers/queries' -import { backupNodeHomePath, e2eTestDirPath, nodeHomePath } from '../constants/config' - -describe('Onboarding Flow', () => { - let workbench: Workbench - - before(async () => { - workbench = await browser.getWorkbench() - }) - - after(async () => { - await closeRadicleViewContainer(workbench) - }) - - describe('VS Code, *before* Radicle is installed,', () => { - after(async () => { - await $`mv ${backupNodeHomePath} ${nodeHomePath}` - await workbench.executeCommand('Developer: Reload Window') - }) - - it('has our Radicle extension installed and available', async () => { - const extensions = await browser.executeWorkbench( - (vscode: typeof VsCode) => vscode.extensions.all, - ) - - expect( - extensions.some((extension) => extension.id === 'radicle-ide-plugins-team.radicle'), - ).toBe(true) - }) - - it('shows the Radicle button in the Activity Bar', async () => { - const radicleViewControl = await workbench.getActivityBar().getViewControl('Radicle') - const title = await radicleViewControl?.getTitle() - - expect(title).toBe('Radicle') - }) - - it('instructs the user to install radicle', async () => { - await openRadicleViewContainer(workbench) - - const welcomeText = await getFirstWelcomeViewText(workbench) - const buttonTitles = await getFirstWelcomeViewButtonTitles(workbench) - - expect(welcomeText).toEqual([ - /* eslint-disable max-len */ - 'Failed resolving the Radicle CLI binary.', - "Please ensure it is installed on your machine and either that it is globally accessible in the shell as `rad` or that its path is correctly defined in the extension's settings.", - "Please expect the extention's capabilities to remain severely limited until this issue is resolved.", - /* eslint-enable max-len */ - ]) - - expect(buttonTitles).toEqual(['Troubleshoot']) - }) - }) - - describe('VS Code, *before* the workspace is git-initialized,', () => { - it('guides the user on how to git-initialize their workspace', async () => { - await openRadicleViewContainer(workbench) - - await browser.waitUntil(async () => { - const welcomeText = await getFirstWelcomeViewText(workbench) - const welcomeButtonTitles = await getFirstWelcomeViewButtonTitles(workbench) - - return ( - isEqual(welcomeText, [ - /* eslint-disable max-len */ - 'The folder currently opened in your workspace is not a Git code repository.', - 'In order to use Radicle with it, this folder must first be initialized as a Git code repository.', - 'To learn more about how to use Git and source control in VS Code read the docs.', - /* eslint-enable max-len */ - ]) && - isEqual(welcomeButtonTitles, [ - 'Initialize Repository With Git', - 'Choose a Different Folder', - ]) - ) - }) - }) - }) - - describe('VS Code, *before* the workspace is rad-initialized,', () => { - before(async () => { - await initGitRepo() - }) - - it('guides the user on how to rad-initialize their git repo', async () => { - await openRadicleViewContainer(workbench) - - await browser.waitUntil(async () => { - const welcomeText = await getFirstWelcomeViewText(workbench) - - return isEqual(welcomeText, [ - /* eslint-disable max-len */ - 'The Git repository currently opened in your workspace is not yet initialized with Radicle.', - 'To use Radicle with it, please run `rad init` in your terminal.', - 'Once rad-initialized, this repo will have access to advanced source control, collaboration and project management capabilities powered by both Git and Radicle.', - 'During this reversible rad-initializing process you also get to choose whether your repo will be private or public, among other options.', - 'To learn more read the Radicle User Guide.', - /* eslint-enable max-len */ - ]) - }) - }) - }) - - describe('VS Code, *after* the workspace is rad-initialized,', () => { - before(async () => { - await $`rad init --private --default-branch main --name "A_test_blog" --description "Some repo" --no-confirm --verbose` - await workbench.executeCommand('Developer: Reload Window') - }) - - it('hides the non rad-initialized guide', async () => { - await browser.waitUntil(async () => { - const welcomeText = await getFirstWelcomeViewText(workbench) - - return welcomeText.some((text) => text.includes('rad init')) === false - }) - }) - - it('shows the standard sidebar views', async () => { - const sidebarView = workbench.getSideBar().getContent() - await sidebarView.wait() - - await expectStandardSidebarViewsToBeVisible(workbench) - }) - }) -}) - -async function initGitRepo() { - const repoDirPath = path.join(e2eTestDirPath, 'fixtures/workspaces/basic') - - await $`mkdir -p ${repoDirPath}` - cd(repoDirPath) - await $`git config --global init.defaultBranch main` - await $`git init .` - await $`git config --global user.email "test@radicle.xyz"` - await $`git config --global user.name "Radicle Test"` - await $`echo "# Basic Repo" > README.md` - await $`git add README.md` - await $`git commit -m 'adds readme' --no-gpg-sign` -} - -async function getFirstWelcomeViewButtonTitles(workbench: Workbench) { - const sidebarView = workbench.getSideBar().getContent() - await sidebarView.wait() - - const buttons = - (await (await (await sidebarView.getSections())[0]?.findWelcomeContent())?.getButtons()) ?? - [] - const buttonTitles = await Promise.all( - buttons.map(async (button) => await button.getTitle()), - ) - - return buttonTitles -}