Skip to content

Commit

Permalink
test(debug): simplify settings.spec.ts
Browse files Browse the repository at this point in the history
Signed-off-by: Zacharias Fragkiadakis <zacfragkiadakis@gmail.com>
  • Loading branch information
QZera committed Dec 27, 2024
1 parent 64c89e8 commit 5744073
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 80 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/e2e-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
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',
},
)
}
101 changes: 34 additions & 67 deletions test/e2e/specs/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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']],
maxInstances: 10,
capabilities: [
{
Expand Down

0 comments on commit 5744073

Please sign in to comment.