Skip to content

Commit

Permalink
Migrate tests that assumed not creating an account would be default flow
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed May 20, 2024
1 parent 6808c2a commit f44d8f2
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/create-wallet.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Create wallet', () => {
cy.findByPlaceholderText('Enter your keyphrase here').type(generatedMnemonic, { delay: 0 })
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.contains('mnemonic does not match').should('not.exist')
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByRole('button', { name: /Open/ }).click()
cy.findByRole('button', { name: /Send/ }).should('exist')
})
Expand Down
5 changes: 5 additions & 0 deletions cypress/e2e/open-wallet.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ describe('Open wallet', () => {
cy.findByPlaceholderText('Enter your keyphrase here').type(mnemonic, { delay: 1 })
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.findByText(/Invalid keyphrase/).should('not.exist')
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByRole('button', { name: /Open/ }).click()
cy.url().should('include', 'oasis1qqca0gplrfn63ljg9c833te7em36lkz0cv8djffh')
})

it('Should open multiple accounts from mnemonic', () => {
cy.findByPlaceholderText('Enter your keyphrase here').type(mnemonic, { delay: 1 })
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findAllByTestId('account-choice').should('have.length', 4)
cy.findAllByRole('checkbox', { name: /oasis1/, checked: false })
.should('have.length', 3)
Expand All @@ -58,6 +60,7 @@ describe('Open wallet', () => {

cy.findByPlaceholderText('Enter your keyphrase here').type(mnemonic, { delay: 1 })
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findAllByTestId('account-choice').should('have.length', 4)
cy.findAllByRole('checkbox', { name: /oasis1/, checked: false })
.should('have.length', 3)
Expand All @@ -72,6 +75,7 @@ describe('Open wallet', () => {
const privateKey = 'X0jlpvskP1q8E6rHxWRJr7yTvpCuOPEKBGW8gtuVTxfnViTI0s2fBizgMxNzo75Q7w7MxdJXtOLeqDoFUGxxMg=='
beforeEach(() => {
cy.visit('/open-wallet/private-key')
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
})

it('Should reject invalid keys', () => {
Expand Down Expand Up @@ -100,6 +104,7 @@ describe('Open wallet', () => {
cy.findByRole('link', { name: /Open wallet/ }).click()
cy.findByRole('link', { name: /Private key/ }).click()
cy.url().should('include', '/open-wallet/private-key')
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByPlaceholderText('Enter your private key here').type(privateKey, { delay: 1 })
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.url().should('include', '/account/oasis1qz0k5q8vjqvu4s4nwxyj406ylnflkc4vrcjghuwk')
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/scenario-account-switcher.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('Scenario : multiple accounts', () => {
{ delay: 0 },
)
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByRole('button', { name: /Open/ }).click()
cy.url().should('include', '/account/oasis1qq5t7f2gecsjsdxmp5zxtwgck6pzpjmkvc657z6l')

Expand All @@ -18,6 +19,7 @@ describe('Scenario : multiple accounts', () => {
// Open account 2 through private
cy.findByRole('link', { name: /Open wallet/ }).click()
cy.findByRole('link', { name: /Private key/ }).click()
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByPlaceholderText('Enter your private key here').type(
'X0jlpvskP1q8E6rHxWRJr7yTvpCuOPEKBGW8gtuVTxfnViTI0s2fBizgMxNzo75Q7w7MxdJXtOLeqDoFUGxxMg==',
{ delay: 0 },
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/scenario-transaction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Scenario : from mnemonic', () => {
{ delay: 1 },
)
cy.findByRole('button', { name: /Import my wallet/ }).click()
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByRole('button', { name: /Open/ }).click()
cy.url().should('include', '/account/oasis1qq5t7f2gecsjsdxmp5zxtwgck6pzpjmkvc657z6l')
})
Expand Down Expand Up @@ -86,6 +87,7 @@ describe('Scenario : from private key', () => {
cy.visit('/')
cy.findByRole('link', { name: /Open wallet/ }).click()
cy.findByRole('link', { name: /Private key/ }).click()
cy.findByRole('checkbox', { name: /Create a profile/ }).uncheck({ force: true })
cy.findByPlaceholderText('Enter your private key here').type(
'X0jlpvskP1q8E6rHxWRJr7yTvpCuOPEKBGW8gtuVTxfnViTI0s2fBizgMxNzo75Q7w7MxdJXtOLeqDoFUGxxMg==',
{ delay: 1 },
Expand Down
2 changes: 2 additions & 0 deletions playwright/tests/persist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test.describe('Persist', () => {
await page.goto('/open-wallet/mnemonic')
await page.getByPlaceholder('Enter your keyphrase here').fill(mnemonic)
await page.getByRole('button', { name: /Import my wallet/ }).click()
await page.getByText('Create a profile').uncheck()
await expect(page.getByText('One account selected')).toBeVisible({ timeout: 10_000 })
const uncheckedAccounts = page.getByRole('checkbox', { name: /oasis1/, checked: false })
await expect(uncheckedAccounts).toHaveCount(3)
Expand Down Expand Up @@ -161,6 +162,7 @@ test.describe('Persist', () => {

await page.getByPlaceholder('Enter your keyphrase here').fill(mnemonic)
await page.getByRole('button', { name: /Import my wallet/ }).click()
await page.getByText('Create a profile').uncheck()
await expect(page.getByText('One account selected')).toBeVisible({ timeout: 10_000 })

await page.getByText('Create a profile').check()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test('Chromium expect mnemonic, privateKey, and password to NOT leak with preven
await page.getByPlaceholder('Enter your keyphrase here').fill(mnemonic)
await page.getByRole('button', { name: /Import my wallet/ }).click()
await expect(page.getByText('One account selected')).toBeVisible({ timeout: 10_000 })
await page.getByText('Create a profile').uncheck()
await page.getByRole('button', { name: /Open/ }).click()
await expect(page.getByText('Loading account')).toBeHidden()

Expand Down
1 change: 1 addition & 0 deletions playwright/tests/syncTabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ test.describe('syncTabs', () => {

await page.getByPlaceholder('Enter your keyphrase here').fill(mnemonic)
await page.getByRole('button', { name: /Import my wallet/ }).click()
await page.getByText('Create a profile').uncheck()
await expect(page.getByText('One account selected')).toBeVisible({ timeout: 10_000 })
await page.getByRole('checkbox', { name: /oasis1/, checked: true }).uncheck()
for (let i = 0; i < 11; i++) {
Expand Down
1 change: 1 addition & 0 deletions playwright/tests/toolbar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ test.describe('My Accounts tab', () => {
await page.goto('/open-wallet/mnemonic')
await page.getByPlaceholder('Enter your keyphrase here').fill(mnemonic)
await page.getByRole('button', { name: /Import my wallet/ }).click()
await page.getByText('Create a profile').uncheck()
const uncheckedAccounts = page.getByRole('checkbox', { name: /oasis1/, checked: false })
await expect(uncheckedAccounts).toHaveCount(3)
for (const account of await uncheckedAccounts.elementHandles()) await account.click()
Expand Down
1 change: 1 addition & 0 deletions playwright/utils/fillPrivateKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export async function fillPrivateKeyWithoutPassword(
await expect(persistence).not.toBeChecked()
} else {
await expect(persistence).toBeEnabled()
await persistence.uncheck()
}

await page.getByPlaceholder('Enter your private key here').fill(params.privateKey ?? privateKey)
Expand Down

0 comments on commit f44d8f2

Please sign in to comment.