Skip to content

Commit

Permalink
--wip--
Browse files Browse the repository at this point in the history
  • Loading branch information
QZera committed Dec 27, 2024
1 parent 64c89e8 commit 46b1f43
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 34 deletions.
4 changes: 4 additions & 0 deletions test/e2e/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export async function openRadicleViewContainer(workbench: Workbench) {

await radicleViewControl?.openView()
}

export async function reloadWindow(workbench: Workbench) {
await workbench.executeCommand('Developer: Reload Window')
}
25 changes: 15 additions & 10 deletions test/e2e/helpers/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ export async function expectCliCommandsAndPatchesToBeVisible(workbench: Workbenc
const sidebarView = workbench.getSideBar().getContent()
await sidebarView.wait()

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 { }
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
})
return sectionsFound
},
{
timeoutMsg: 'expected CLI Commands and Patches sections to be visible',
},
)
}
6 changes: 3 additions & 3 deletions test/e2e/specs/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { $, cd } from 'zx'
import type * as VsCode from 'vscode'
import isEqual from 'lodash/isEqual'
import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions'
import { openRadicleViewContainer } from '../helpers/actions'
import { openRadicleViewContainer, reloadWindow } from '../helpers/actions'
import { getFirstWelcomeViewText } from '../helpers/queries'

describe('Onboarding Flow', () => {
Expand All @@ -26,7 +26,7 @@ describe('Onboarding Flow', () => {

after(async () => {
await $`mv ${tempPathToNodeHome} ${pathToNodeHome}`
await workbench.executeCommand('Developer: Reload Window')
await reloadWindow(workbench)
})

it('has our Radicle extension installed and available', async () => {
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('Onboarding Flow', () => {
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')
await reloadWindow(workbench)
})

it('hides the non rad-initialized guide', async () => {
Expand Down
83 changes: 63 additions & 20 deletions test/e2e/specs/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Key } from 'webdriverio'
import { $ } from 'zx'
import { extTempDir } from 'src/constants'
import { getFirstWelcomeViewText } from '../helpers/queries'
import { openRadicleViewContainer } from '../helpers/actions'
import { openRadicleViewContainer, reloadWindow } from '../helpers/actions'
import { pathToNodeHome } from '../constants/config'
import { expectCliCommandsAndPatchesToBeVisible } from '../helpers/assertions'

Expand All @@ -29,11 +29,7 @@ describe('Settings', () => {
let pathToRadBinarySetting: Setting

before(async () => {
pathToRadBinarySetting = await settings.findSetting(
'Path To Rad Binary',
'Radicle',
'Advanced',
)
pathToRadBinarySetting = await findPathToBinarySetting(settings)
})

afterEach(async () => {
Expand All @@ -42,16 +38,55 @@ describe('Settings', () => {
await expectCliCommandsAndPatchesToBeVisible(workbench)
})

it('warns the user if the rad binary is not found', async () => {
it.skip('warns the user if the rad binary is not found', async () => {
await pathToRadBinarySetting.setValue('/tmp')
await openRadicleViewContainer(workbench)

await expectRadBinaryNotFoundToBeVisible(workbench)
})

it('recognizes the rad binary when a valid path is specified', async () => {
const tempNodeHomePath = `${pathToNodeHome}.temp`
await $`mv ${pathToNodeHome} ${tempNodeHomePath}`

await browser.keys([Key.Ctrl, 'w'])
await browser.waitUntil(async () => {
return !(await settings.elem.isExisting())
})

await reloadWindow(workbench)

await browser.pause(3000)

settings = await workbench.openSettings()
await settings.wait()

pathToRadBinarySetting = await findPathToBinarySetting(settings)
await pathToRadBinarySetting.wait()

await expectRadBinaryNotFoundToBeVisible(workbench)

await browser.waitUntil(
async () => {
await browser.pause(1500)
await clearSettingInput(pathToRadBinarySetting)
await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`)

return (await pathToRadBinarySetting.getValue()) === `${tempNodeHomePath}/bin/rad`
},
{
timeoutMsg: 'expected the path to rad binary setting to be updated',
},
)

await expectCliCommandsAndPatchesToBeVisible(workbench)

await $`mv ${tempNodeHomePath} ${pathToNodeHome}`
})

// 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 () => {
it.skip('recognizes the rad binary if the directory is created *after* the setting is updated', async () => {
const tempNodeHomePath = `${extTempDir}/.radicle/installation-backup`
await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`)

Expand All @@ -61,7 +96,6 @@ describe('Settings', () => {

await expectCliCommandsAndPatchesToBeVisible(workbench)

await clearSettingInput(pathToRadBinarySetting)
await $`rm -rf ${tempNodeHomePath}`
})
})
Expand All @@ -70,17 +104,22 @@ describe('Settings', () => {
})

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 */
])
})
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 */
])
},
{
timeoutMsg: 'expected the rad binary not found message to be visible',
},
)
}

async function clearSettingInput(setting: Setting) {
Expand All @@ -96,3 +135,7 @@ async function clearSettingInput(setting: Setting) {
await browser.keys([Key.Ctrl, 'a'])
await browser.keys(Key.Backspace)
}

async function findPathToBinarySetting(settings: SettingsEditor) {
return await settings.findSetting('Path To Rad Binary', 'Radicle', 'Advanced')
}
3 changes: 2 additions & 1 deletion test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const config: WebdriverIO.Config = {
runner: 'local',
tsConfigPath: './tsconfig.wdio.json',
// Order matters, onboarding.spec.ts should run first as it sets up the workspace
specs: ['./specs/onboarding.spec.ts', './specs/**/*.spec.ts'],
specs: [['./specs/onboarding.spec.ts', './specs/settings.spec.ts']],
// specs: ['./specs/temp.spec.ts'],
maxInstances: 10,
capabilities: [
{
Expand Down

0 comments on commit 46b1f43

Please sign in to comment.