Skip to content

Commit

Permalink
refactor(e2e): use new functions in onboarding tests
Browse files Browse the repository at this point in the history
Signed-off-by: Zacharias Fragkiadakis <zacfragkiadakis@gmail.com>
  • Loading branch information
QZera committed Nov 11, 2024
1 parent e5d9858 commit aa7d5f2
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions test/specs/onboarding.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ describe('onboarding flow', () => {
it('should show the `rad init` copy', async () => {
await openRadicleSidebarTab(workbench)

const welcomeText = await findFirstSectionWelcomeText(workbench)
expect(welcomeText.some((text) => text.includes('rad init'))).toBe(true)
const firstSection = await findFirstSection(workbench)
const welcomeText = firstSection ? await findWelcomeText(firstSection) : []
expectTextSectionsToContain(welcomeText, /rad init/i)
})
})

Expand All @@ -79,7 +80,8 @@ describe('onboarding flow', () => {
})

it('should not show the `rad init` copy', async () => {
const welcomeText = await findFirstSectionWelcomeText(workbench)
const firstSection = await findFirstSection(workbench)
const welcomeText = firstSection ? await findWelcomeText(firstSection) : []
expect(welcomeText.some((text) => text.includes('rad init'))).not.toBe(true)
})

Expand All @@ -88,20 +90,14 @@ describe('onboarding flow', () => {
// Fixes flakiness on macOS CI
await browser.pause(100)

const welcomeContent = await cliCommandsSection?.findWelcomeContent()
const welcomeText = (await welcomeContent?.getTextSections()) ?? []
const buttons = (await welcomeContent?.getButtons()) ?? []
const buttonTitles = await Promise.all(
buttons.map(async (button) => await button.getTitle()),
const welcomeText = await findWelcomeText(cliCommandsSection)
const welcomeButtonTitles = await findWelcomeButtonTitles(cliCommandsSection)
expectTextSectionsToContain(
welcomeText,
/use the buttons below to perform common interactions with the radicle network./i,
)
expect(
welcomeText.some((text) =>
/Use the buttons below to perform common interactions with the Radicle network./i.test(
text,
),
),
).toBe(true)
expect(buttonTitles).toEqual(['Sync', 'Fetch', 'Announce'])

expect(welcomeButtonTitles).toEqual(['Sync', 'Fetch', 'Announce'])
})
})
})
Expand Down Expand Up @@ -130,16 +126,6 @@ async function openRadicleSidebarTab(workbench: Workbench) {
await radicleViewControl?.openView()
}

async function findFirstSectionWelcomeText(workbench: Workbench) {
const sidebarView = workbench.getSideBar().getContent()
await sidebarView.wait()
const firstSection = (await sidebarView.getSections())[0]
const welcomeContent = await firstSection?.findWelcomeContent()
const welcomeText = (await welcomeContent?.getTextSections()) ?? []

return welcomeText
}

async function findFirstSection(workbench: Workbench) {
const sidebarView = workbench.getSideBar().getContent()
await sidebarView.wait()
Expand Down

0 comments on commit aa7d5f2

Please sign in to comment.