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 c2f6e83
Showing 7 changed files with 98 additions and 39 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/e2e-testing.yaml
Original file line number Diff line number Diff line change
@@ -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:

2 changes: 1 addition & 1 deletion test/e2e/constants/config.ts
Original file line number Diff line number Diff line change
@@ -16,4 +16,4 @@ export const rootDirPath = join(__dirname, '../../..')
* The path to the node home directory. This is where the Radicle node stores its
* configuration and data.
*/
export const pathToNodeHome = process.env['RAD_HOME']
export const pathToNodeHome = process.env['RAD_HOME'] ?? ''
4 changes: 4 additions & 0 deletions test/e2e/helpers/actions.ts
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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', () => {
@@ -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 () => {
@@ -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 () => {
92 changes: 70 additions & 22 deletions test/e2e/specs/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -21,37 +21,70 @@ describe('Settings', () => {
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'])
await closeTab()
}
})

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',
)
pathToRadBinarySetting = await findPathToBinarySetting(settings)
})

afterEach(async () => {
// afterEach(async () => {
// await clearSettingInput(pathToRadBinarySetting)

// await expectCliCommandsAndPatchesToBeVisible(workbench)
// })

it('warns the user if the rad binary is not found', async () => {
await openRadicleViewContainer(workbench)
await expectCliCommandsAndPatchesToBeVisible(workbench)

await browser.pause(1000)
await pathToRadBinarySetting.setValue('/tmp')

await expectRadBinaryNotFoundToBeVisible(workbench)

await clearSettingInput(pathToRadBinarySetting)

await expectCliCommandsAndPatchesToBeVisible(workbench)
})

it('warns the user if the rad binary is not found', async () => {
await pathToRadBinarySetting.setValue('/tmp')
it.skip('recognizes the rad binary when a valid path is specified', async () => {
const tempNodeHomePath = `${pathToNodeHome}.temp`
await $`cp -r ${pathToNodeHome} ${tempNodeHomePath}`
await openRadicleViewContainer(workbench)

// await closeTab()
// await reloadWindow(workbench)

// await browser.pause(3000)

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

// await browser.pause(3000)

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

await pathToRadBinarySetting.setValue(`/tmp`)

await expectRadBinaryNotFoundToBeVisible(workbench)

await pathToRadBinarySetting.setValue(`${tempNodeHomePath}/bin/rad`)

await expectCliCommandsAndPatchesToBeVisible(workbench)

await $`rm -rf ${tempNodeHomePath}`
// 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`)

@@ -61,7 +94,6 @@ describe('Settings', () => {

await expectCliCommandsAndPatchesToBeVisible(workbench)

await clearSettingInput(pathToRadBinarySetting)
await $`rm -rf ${tempNodeHomePath}`
})
})
@@ -70,17 +102,24 @@ 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 */
])
})
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) {
@@ -96,3 +135,12 @@ 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')
}

async function closeTab() {
const CMD_KEY = process.platform === 'win32' ? 'Control' : 'Meta'
await browser.keys([CMD_KEY, 'w'])
}
3 changes: 2 additions & 1 deletion test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
@@ -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: [
{

0 comments on commit c2f6e83

Please sign in to comment.