Skip to content

Commit

Permalink
Add playwright tests to account remove feature
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Nov 10, 2023
1 parent 0fca829 commit 0ce6d66
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions playwright/tests/toolbar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'
import { password, privateKey, privateKeyAddress } from '../utils/test-inputs'
import { test, expect, Page } from '@playwright/test'
import { mnemonic, mnemonicAddress0, password, privateKey, privateKeyAddress } from '../utils/test-inputs'
import { fillPrivateKeyAndPassword } from '../utils/fillPrivateKey'
import { warnSlowApi } from '../utils/warnSlowApi'
import { mockApi } from '../utils/mockApi'
Expand Down Expand Up @@ -75,4 +75,49 @@ test.describe('My Accounts tab', () => {
await page.getByText('I understand, reveal my private key').click()
await expect(page.getByText(privateKey)).toBeVisible()
})

test('should not be able to remove an account', async ({ page }) => {
await page.goto('/open-wallet/private-key')
await fillPrivateKeyAndPassword(page)
await page.getByTestId('account-selector').click()
await page.getByText('Manage').click()
await expect(page.getByText('Delete Account')).toBeDisabled()
})

async function openAccountSelectorWithMultipleItems(page: Page) {
await page.goto('/open-wallet/mnemonic')
await page.getByPlaceholder('Enter your keyphrase here').fill(mnemonic)
await page.getByRole('button', { name: /Import my wallet/ }).click()
const uncheckedAccounts = page.getByRole('checkbox', { name: /oasis1/, checked: false })
await expect(uncheckedAccounts).toHaveCount(3)
for (const account of await uncheckedAccounts.elementHandles()) await account.click()
await page.getByRole('button', { name: /Open/ }).click()
await page.getByTestId('account-selector').click()
await expect(page.getByTestId('account-choice')).toHaveCount(4)
}

test('should remove currently selected account and switch the first one available in account list', async ({
page,
}) => {
await openAccountSelectorWithMultipleItems(page)
await page.getByText('Manage').nth(0).click()
await page.getByText('Delete Account').click()
await page.getByRole('textbox').fill('foo')
await page.getByRole('button', { name: 'Yes, delete' }).click()
expect(page.getByText("Type 'delete'")).toBeVisible()
await page.getByRole('textbox').fill('delete')
await page.getByRole('button', { name: 'Yes, delete' }).click()
await expect(page).not.toHaveURL(new RegExp(`/account/${mnemonicAddress0}`))
await expect(page.getByTestId('account-choice')).toHaveCount(3)
})

test('should remove not currently selected account', async ({ page }) => {
await openAccountSelectorWithMultipleItems(page)
await page.getByText('Manage').nth(1).click()
await page.getByText('Delete Account').click()
await page.getByRole('textbox').fill('delete')
await page.getByRole('button', { name: 'Yes, delete' }).click()
await expect(page).toHaveURL(new RegExp(`/account/${mnemonicAddress0}`))
await expect(page.getByTestId('account-choice')).toHaveCount(3)
})
})

0 comments on commit 0ce6d66

Please sign in to comment.