Skip to content

Commit

Permalink
basic working test
Browse files Browse the repository at this point in the history
  • Loading branch information
QZera committed Dec 1, 2024
1 parent 7c2b5e1 commit 57d792c
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test/e2e/helpers/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Workbench } from 'wdio-vscode-service'

/**
* Opens the Radicle view container in the sidebar, by clicking the radicle button in the
* activity bar.
*/
export async function openRadicleViewContainer(workbench: Workbench) {
const activityBar = workbench.getActivityBar()
await activityBar.wait()

const radicleViewControl = await activityBar.getViewControl('Radicle')
await radicleViewControl?.wait()

await radicleViewControl?.openView()
}
13 changes: 13 additions & 0 deletions test/e2e/helpers/queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Workbench } from 'wdio-vscode-service'

export async function getFirstWelcomeViewText(workbench: Workbench) {
const sidebarView = workbench.getSideBar().getContent()
await sidebarView.wait()

const welcomeText =
(await (
await (await sidebarView.getSections())[0]?.findWelcomeContent()
)?.getTextSections()) ?? []

return welcomeText
}
84 changes: 84 additions & 0 deletions test/e2e/specs/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -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('Setting: 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
})
}
2 changes: 1 addition & 1 deletion test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const vscodeVersion = (packageJson.engines.vscode as string).replace(/^\^/, '')
export const config: WebdriverIO.Config = {
runner: 'local',
tsConfigPath: './tsconfig.wdio.json',
specs: ['./specs/**/*.ts'],
specs: [['./specs/onboarding.spec.ts', './specs/settings.spec.ts']],
maxInstances: 10,
capabilities: [
{
Expand Down

0 comments on commit 57d792c

Please sign in to comment.