Skip to content

Commit

Permalink
test(e2e): extract backup node home path into constants
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 7, 2025
1 parent 4747d92 commit 9142baf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 7 additions & 0 deletions test/e2e/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ export const rootDirPath = join(__dirname, '../../..')
* configuration and data.
*/
export const nodeHomePath = process.env['RAD_HOME']

/**
* The path to a backup node home directory. This is used to store the original
* node home directory for tests that require the original path to be moved or
* modified.
*/
export const backupNodeHomePath = `${nodeHomePath}.backup`
6 changes: 2 additions & 4 deletions test/e2e/specs/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import isEqual from 'lodash/isEqual'
import { expectStandardSidebarViewsToBeVisible } from '../helpers/assertions'
import { openRadicleViewContainer } from '../helpers/actions'
import { getFirstWelcomeViewText } from '../helpers/queries'
import { e2eTestDirPath, nodeHomePath } from '../constants/config'
import { backupNodeHomePath, e2eTestDirPath, nodeHomePath } from '../constants/config'

describe('Onboarding Flow', () => {
let workbench: Workbench
Expand All @@ -17,10 +17,8 @@ describe('Onboarding Flow', () => {
})

describe('VS Code, *before* Radicle is installed,', () => {
const tempPathToNodeHome = `${nodeHomePath}.temp`

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

Expand Down
9 changes: 7 additions & 2 deletions test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import path from 'node:path'
import { $ } from 'zx'
import type { Options } from '@wdio/types'
import { e2eTestDirPath, nodeHomePath, rootDirPath } from './constants/config'
import {
backupNodeHomePath,
e2eTestDirPath,
nodeHomePath,
rootDirPath,
} from './constants/config'

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
const packageJson = require('../../package.json')
Expand Down Expand Up @@ -58,7 +63,7 @@ export const config: Options.Testrunner = {
},
onWorkerStart: async (_cid, _caps, specs) => {
if (specs.some((spec) => spec.includes('onboarding.spec.ts'))) {
await $`mv ${nodeHomePath} ${`${nodeHomePath}.temp`}`
await $`mv ${nodeHomePath} ${backupNodeHomePath}`
}
},
}

0 comments on commit 9142baf

Please sign in to comment.