Skip to content

Commit

Permalink
--wip--
Browse files Browse the repository at this point in the history
  • Loading branch information
QZera committed Nov 11, 2024
1 parent eb407d9 commit 269a5cd
Showing 1 changed file with 68 additions and 14 deletions.
82 changes: 68 additions & 14 deletions test/specs/onboarding.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,47 @@ describe('onboarding flow', () => {
let workbench: Workbench

before(async () => {
// await setUpGitRepo()
workbench = await browser.getWorkbench()
})

describe('before the repo is initialized as a radicle repo', () => {
it('should load and install the extension', async () => {
const extensions = await browser.executeWorkbench(
(vscode: VsCodeType) => vscode.extensions.all,
)
expect(
extensions.some((extension) => extension.id === 'radicle-ide-plugins-team.radicle'),
).toBe(true)
})
it('should load and install the extension', async () => {
const extensions = await browser.executeWorkbench(
(vscode: VsCodeType) => vscode.extensions.all,
)
expect(
extensions.some((extension) => extension.id === 'radicle-ide-plugins-team.radicle'),
).toBe(true)
})

it('should show the "Radicle" sidebar tab', async () => {
const radicleViewControl = await workbench.getActivityBar().getViewControl('Radicle')
const title = await radicleViewControl?.getTitle()
expect(title).toBe('Radicle')
})

// eslint-disable-next-line max-len
it('should show the correct copy and buttons if the workspace is not a git repo', async () => {
await openRadicleSidebarTab(workbench)

const firstSection = await findFirstSection(workbench)
const welcomeText = firstSection ? await findWelcomeText(firstSection) : []
const welcomeButtonTitles = firstSection ? await findWelcomeButtonTitles(firstSection) : []
expectTextSectionsToContain(welcomeText, /not a git code repository/i)
expectTextSectionsToContain(
welcomeText,
/must first be initialized as a git code repository/i,
)
expect(welcomeButtonTitles).toEqual([
'Initialize Repository With Git',
'Choose a Different Folder',
])
})

it('should show the "Radicle" sidebar tab', async () => {
const radicleViewControl = await workbench.getActivityBar().getViewControl('Radicle')
const title = await radicleViewControl?.getTitle()
expect(title).toBe('Radicle')
describe('before the repo is initialized as a radicle repo', () => {
before(async () => {
await setUpGitRepo()
// Give extension time to detect the new git repo
await browser.pause(500)
})

it('should show the `rad init` copy', async () => {
Expand All @@ -42,7 +65,9 @@ describe('onboarding flow', () => {
let cliCommandsSection: ViewSection

before(async () => {
// await workbench.executeCommand('workbench.action.reloadWindow')
await $`rad init --private --default-branch main --name "A_test_blog" --description "Some repo" --no-confirm --verbose`
await browser.pause(2000)
await openRadicleSidebarTab(workbench)
const sidebarView = workbench.getSideBar().getContent()
await sidebarView.wait()
Expand Down Expand Up @@ -115,3 +140,32 @@ async function findFirstSectionWelcomeText(workbench: Workbench) {

return welcomeText
}

async function findFirstSection(workbench: Workbench) {
const sidebarView = workbench.getSideBar().getContent()
await sidebarView.wait()
const firstSection = (await sidebarView.getSections())[0]

return firstSection
}

async function findWelcomeText(section: ViewSection) {
const welcomeContent = await section.findWelcomeContent()
const welcomeText = (await welcomeContent?.getTextSections()) ?? []

return welcomeText
}

async function findWelcomeButtonTitles(section: ViewSection) {
const welcomeContent = await section.findWelcomeContent()
const buttons = (await welcomeContent?.getButtons()) ?? []
const buttonTitles = await Promise.all(
buttons.map(async (button) => await button.getTitle()),
)

return buttonTitles
}

function expectTextSectionsToContain(textSections: string[], text: string | RegExp) {
expect(textSections.some((section) => new RegExp(text).test(section))).toBe(true)
}

0 comments on commit 269a5cd

Please sign in to comment.