Skip to content

Commit

Permalink
frontend: new device onboarding test
Browse files Browse the repository at this point in the history
  • Loading branch information
horacioh committed Sep 13, 2023
1 parent 22100d6 commit 5a98d4e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
59 changes: 59 additions & 0 deletions frontend/apps/desktop/test/onboarding.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import {Page, test, expect} from '@playwright/test'
import {alias, bio, electronApp} from './test-setup'
import fs from 'fs'
import path from 'path'
import os from 'os'

let page: Page

test.beforeEach(() => {
// remove the app data:
fs.rm(
path.join(os.homedir(), 'Library', 'Application Support', 'Mintter.test'),
{recursive: true},
(...args) => {
console.log('== DELETE??', args)
},
)
})

test('Onboarding: New Account', async () => {
page = await electronApp.firstWindow()

Expand Down Expand Up @@ -106,3 +120,48 @@ test('Onboarding: New Account', async () => {

// await page.getByRole('button', {name: 'Open Mintter App'}).click()
})

test.skip('Onboarding: Add new Device', async () => {
page = await electronApp.firstWindow()

await page.waitForSelector('#welcome-title-section')

// const text = await page.$eval(
// '[data-testid="step-title"]',
// (el) => el.textContent,
// )
const welcomeTitles = await page
.locator('#welcome-title-section')
.allTextContents()

console.log(`== ~ test ~ welcomeTitles:`, welcomeTitles)
expect(welcomeTitles).toEqual(['Welcome toMintter'])

await page.click('#btn-new-device')

await page.waitForSelector('#new-device-title-section')

// Mnemonics Step
const newDeviceTitles = await page
.locator('#new-device-title-section')
.allTextContents()
console.log(`== ~ test ~ newDeviceTitles:`, newDeviceTitles)
expect(newDeviceTitles).toEqual(['SetupNew device.'])
const mnemonics = await page.locator('#mnemonic-input')
expect(mnemonics).toBeVisible()

mnemonics.fill(
'banana, ridge, galaxy, melt, tobacco, bid, rhythm, spread, tiny, loop, kite, emerge',
)

// continue to next step
await page.click('#btn-next')

// check finish step
await page.waitForSelector('#complete-title-section')
// check Analytics step title
const finishTitles = await page
.locator('#complete-title-section')
.allTextContents()
expect(finishTitles).toEqual(['You are Ready!'])
})
12 changes: 0 additions & 12 deletions frontend/apps/desktop/test/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,11 @@ import {
_electron as electron,
test,
} from '@playwright/test'
import os from 'os'

import fs from 'fs'
import path from 'path'
import {findLatestBuild, parseElectronApp} from 'electron-playwright-helpers'

let electronApp: ElectronApplication

test.beforeAll(async () => {
// remove the app data:
fs.rm(
path.join(os.homedir(), 'Library', 'Application Support', 'Mintter.test'),
{recursive: true},
(...args) => {
console.log('== DELETE??', args)
},
)
// find the latest build in the out directory
const latestBuild = findLatestBuild()

Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/app/src/pages/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function NewDevice(props: OnboardingStepProps) {
<XStack flex={1} gap="$10">
<StepTitleSection step="new-device">
<H2>Setup</H2>
<H1>New device</H1>
<H1>New device.</H1>
</StepTitleSection>
<YStack flex={2}>
<YStack gap="$5" maxWidth={500}>
Expand Down

0 comments on commit 5a98d4e

Please sign in to comment.