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) +}