Skip to content

Commit

Permalink
test(debug): manually set node home path to RAD_HOMe
Browse files Browse the repository at this point in the history
Signed-off-by: Zacharias Fragkiadakis <zacfragkiadakis@gmail.com>
  • Loading branch information
QZera committed Jan 4, 2025
1 parent 99ba1c5 commit 692414d
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion test/e2e/specs/httpd.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
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 () => {
const workbench = await browser.getWorkbench()
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')
})
})
Expand All @@ -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)
}

0 comments on commit 692414d

Please sign in to comment.