Skip to content

Commit

Permalink
Stop testing initial state of persistence checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed May 16, 2024
1 parent cbad969 commit 19e70de
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 30 deletions.
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
1 change: 0 additions & 1 deletion playwright/tests/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ test.describe('The extension popup should load', () => {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey,
privateKeyAddress: privateKeyAddress,
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
await expect(page.getByTestId('account-selector')).toBeVisible()
Expand Down
1 change: 0 additions & 1 deletion playwright/tests/fiat.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ async function setup(page: Page) {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey,
privateKeyAddress: privateKeyAddress,
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
await expect(page.getByTestId('account-selector')).toBeVisible()
Expand Down
1 change: 0 additions & 1 deletion playwright/tests/paraTimes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ test.describe('ParaTimes', () => {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey,
privateKeyAddress: privateKeyAddress,
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
await page.getByTestId('nav-paratime').click()
Expand Down
11 changes: 4 additions & 7 deletions playwright/tests/persist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ 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)
for (const account of await uncheckedAccounts.elementHandles()) await account.click()

const persistence = await page.getByText('Create a profile')
await expect(persistence).toBeEnabled()
await expect(persistence).not.toBeChecked()
await persistence.check()
await page.getByRole('button', { name: /Open/ }).click()
})
Expand Down Expand Up @@ -82,7 +82,6 @@ test.describe('Persist', () => {

const persistence = await page.getByText('Create a profile')
await expect(persistence).toBeEnabled()
await expect(persistence).not.toBeChecked()
await persistence.check()

await page.getByPlaceholder('Enter your private key here').fill(privateKey)
Expand Down Expand Up @@ -126,8 +125,7 @@ test.describe('Persist', () => {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey2,
privateKeyAddress: privateKey2Address,
persistenceCheckboxChecked: true,
persistenceCheckboxDisabled: true,
persistenceCheckboxDisabled: 'disabled-checked',
})
await page.goto('/')
await page.getByPlaceholder('Enter your password', { exact: true }).fill(password)
Expand Down Expand Up @@ -164,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 Expand Up @@ -195,8 +194,7 @@ test.describe('Persist', () => {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey2,
privateKeyAddress: privateKey2Address,
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: true,
persistenceCheckboxDisabled: 'disabled-unchecked',
})
await page.goto('/')
await page.getByPlaceholder('Enter your password', { exact: true }).fill(password)
Expand Down Expand Up @@ -237,7 +235,6 @@ test.describe('Persist', () => {
await page.getByRole('button', { name: /Open wallet/ }).click()
await page.getByRole('button', { name: /Private key/ }).click()
await fillPrivateKeyWithoutPassword(page, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
}
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: 0 additions & 1 deletion playwright/tests/refreshing-balance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ test.beforeEach(async ({ page }) => {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey,
privateKeyAddress: privateKeyAddress,
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
await expect(page.getByTestId('account-selector')).toBeVisible()
Expand Down
13 changes: 4 additions & 9 deletions playwright/tests/syncTabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ test.describe('syncTabs', () => {
test('unpersisted', async ({ page, context }) => {
await page.goto('/open-wallet/private-key')
await fillPrivateKeyWithoutPassword(page, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
await expect(page.getByTestId('account-selector')).toBeVisible()
Expand Down Expand Up @@ -62,8 +61,7 @@ test.describe('syncTabs', () => {
await expect(tab2.getByRole('button', { name: /^Unlock$/ })).toBeHidden()
await tab2.goto('/open-wallet/private-key')
await fillPrivateKeyWithoutPassword(tab2, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: true,
persistenceCheckboxDisabled: 'disabled-unchecked',
})
await expect(tab2.getByTestId('account-selector')).toBeVisible()
await expect(page.getByTestId('account-selector')).toBeVisible()
Expand Down Expand Up @@ -96,7 +94,6 @@ test.describe('syncTabs', () => {
test('unpersisted', async ({ page, context }) => {
await page.goto('/open-wallet/private-key')
await fillPrivateKeyWithoutPassword(page, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
const tab2 = await context.newPage()
Expand All @@ -120,8 +117,7 @@ test.describe('syncTabs', () => {
const tab2 = await context.newPage()
await tab2.goto('/open-wallet/private-key')
await fillPrivateKeyWithoutPassword(tab2, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: true,
persistenceCheckboxDisabled: 'disabled-unchecked',
})
await testSyncingNetwork(page, tab2)
})
Expand Down Expand Up @@ -202,7 +198,6 @@ test.describe('syncTabs', () => {
test('unpersisted', async ({ page, context }) => {
await page.goto('/open-wallet/private-key')
await fillPrivateKeyWithoutPassword(page, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
const tab2 = await context.newPage()
Expand All @@ -226,8 +221,7 @@ test.describe('syncTabs', () => {
const tab2 = await context.newPage()
await tab2.goto('/open-wallet/private-key')
await fillPrivateKeyWithoutPassword(tab2, {
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: true,
persistenceCheckboxDisabled: 'disabled-unchecked',
})
await testSelectedAccountNotSync(page, tab2)
})
Expand Down Expand Up @@ -270,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: 0 additions & 1 deletion playwright/tests/validators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ test.beforeEach(async ({ page }) => {
await fillPrivateKeyWithoutPassword(page, {
privateKey: privateKey,
privateKeyAddress: privateKeyAddress,
persistenceCheckboxChecked: false,
persistenceCheckboxDisabled: false,
})
await expect(page.getByTestId('account-selector')).toBeVisible()
Expand Down
16 changes: 7 additions & 9 deletions playwright/utils/fillPrivateKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@ export async function fillPrivateKeyWithoutPassword(
params: {
privateKey?: string
privateKeyAddress?: string
persistenceCheckboxDisabled: boolean
persistenceCheckboxChecked: boolean
persistenceCheckboxDisabled: false | 'disabled-checked' | 'disabled-unchecked'
ticker?: string
},
) {
await test.step('fillPrivateKeyWithoutPassword', async () => {
await expect(page).toHaveURL(new RegExp('/open-wallet/private-key'))

const persistence = await page.getByText('Create a profile')
if (params.persistenceCheckboxDisabled) {
if (params.persistenceCheckboxDisabled === 'disabled-checked') {
await expect(persistence).toBeDisabled()
} else {
await expect(persistence).toBeEnabled()
}
if (params.persistenceCheckboxChecked) {
await expect(persistence).toBeChecked()
} else {
} else if (params.persistenceCheckboxDisabled === 'disabled-unchecked') {
await expect(persistence).toBeDisabled()
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 All @@ -44,7 +43,6 @@ export async function fillPrivateKeyAndPassword(

const persistence = await page.getByText('Create a profile')
await expect(persistence).toBeEnabled()
await expect(persistence).not.toBeChecked()
await persistence.check()

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

0 comments on commit 19e70de

Please sign in to comment.