-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ae66f3
commit 4e6d0df
Showing
13 changed files
with
230 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import { Page } from '@playwright/test' | ||
import { Wallet } from '@siafoundation/walletd-types' | ||
import { Page, expect } from '@playwright/test' | ||
import { openWallet } from './wallet' | ||
|
||
export async function navigateToWallet({ | ||
page, | ||
wallet, | ||
}: { | ||
page: Page | ||
wallet: Wallet | ||
}) { | ||
export async function navigateToWallet(page: Page, name: string) { | ||
await page.getByLabel('Dashboard').click() | ||
await page.getByText(wallet.name).click() | ||
await openWallet(page, name) | ||
await expect(page.getByTestId('navbar').getByText(name)).toBeVisible() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Page, expect } from '@playwright/test' | ||
|
||
export async function clickTextareaByName(page: Page, name: string) { | ||
await page.locator(`textarea[name="${name}"]`).click() | ||
} | ||
|
||
export async function fillTextareaByName( | ||
page: Page, | ||
name: string, | ||
value: string, | ||
tabAfterFill = false | ||
) { | ||
await page.locator(`textarea[name="${name}"]`).click() | ||
await page.locator(`textarea[name="${name}"]`).fill(value) | ||
if (tabAfterFill) { | ||
await page.locator(`textarea[name="${name}"]`).press('Tab') | ||
} | ||
} | ||
|
||
export async function expectTextareaByName( | ||
page: Page, | ||
name: string, | ||
value: string | ||
) { | ||
await expect(page.locator(`textarea[name="${name}"]`)).toHaveValue(value) | ||
} | ||
|
||
export async function expectTextareaNotVisible(page: Page, name: string) { | ||
await expect(page.locator(`textarea[name="${name}"]`)).toBeHidden() | ||
} | ||
|
||
export async function expectTextareaByNameAttribute( | ||
page: Page, | ||
name: string, | ||
value: string | ||
) { | ||
await expect(page.locator(`textarea[name="${name}"]`)).toHaveAttribute(value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { BrowserContext, expect, Page } from '@playwright/test' | ||
import { fillTextInputByName } from './textInput' | ||
import { clickTextareaByName, fillTextareaByName } from './textarea' | ||
|
||
export async function createNewWallet( | ||
page: Page, | ||
context: BrowserContext, | ||
name: string | ||
) { | ||
await context.grantPermissions(['clipboard-read', 'clipboard-write']) | ||
await expect(page.getByRole('button', { name: 'Add wallet' })).toBeVisible() | ||
await page.getByRole('button', { name: 'Add wallet' }).click() | ||
await page.getByRole('button', { name: 'Create a wallet' }).click() | ||
await fillTextInputByName(page, 'name', name, true) | ||
await fillTextareaByName(page, 'description', name, true) | ||
await clickTextareaByName(page, 'mnemonic') | ||
const cb = await page.evaluateHandle(() => navigator.clipboard.readText()) | ||
const mnemonic = await cb.jsonValue() | ||
await page.getByRole('button', { name: 'Add wallet' }).click() | ||
await expect(page.getByText(`Wallet ${name.slice(0, 5)}`)).toBeVisible() | ||
await fillTextInputByName(page, 'mnemonic', mnemonic) | ||
await page.getByRole('button', { name: 'Generate addresses' }).click() | ||
} | ||
|
||
export async function recoverWallet( | ||
page: Page, | ||
context: BrowserContext, | ||
name: string, | ||
mnemonic: string | ||
) { | ||
await context.grantPermissions(['clipboard-read', 'clipboard-write']) | ||
await expect(page.getByRole('button', { name: 'Add wallet' })).toBeVisible() | ||
await page.getByRole('button', { name: 'Add wallet' }).click() | ||
await page.getByRole('button', { name: 'Recover a wallet' }).click() | ||
await fillTextInputByName(page, 'name', name, true) | ||
await fillTextareaByName(page, 'description', name, true) | ||
await fillTextareaByName(page, 'mnemonic', mnemonic, true) | ||
await page.getByRole('button', { name: 'Add wallet' }).click() | ||
await expect(page.getByText(`Wallet ${name.slice(0, 5)}`)).toBeVisible() | ||
await fillTextInputByName(page, 'mnemonic', mnemonic) | ||
await page.getByRole('button', { name: 'Generate addresses' }).click() | ||
} | ||
|
||
export async function deleteWallet(page: Page, name: string) { | ||
await openWalletContextMenu(page, name) | ||
await page.getByRole('menuitem', { name: 'Delete wallet' }).click() | ||
await fillTextInputByName(page, 'name', name) | ||
await page.locator('input[name=name]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
await walletNotInList(page, name) | ||
} | ||
|
||
export async function unlockWallet(page: Page, name: string, mnemonic: string) { | ||
await openWalletContextMenu(page, name) | ||
await page.getByRole('menuitem', { name: 'Unlock wallet' }).click() | ||
await fillTextInputByName(page, 'mnemonic', mnemonic) | ||
await page.locator('input[name=mnemonic]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
} | ||
|
||
export async function deleteWalletIfExists(page: Page, name: string) { | ||
const doesWalletExist = await page | ||
.getByRole('table') | ||
.getByText(name) | ||
.first() | ||
.isVisible() | ||
if (doesWalletExist) { | ||
await deleteWallet(page, name) | ||
} | ||
} | ||
|
||
export async function openWallet(page: Page, name: string) { | ||
await page.getByRole('table').getByText(name).first().click() | ||
} | ||
|
||
export async function openWalletContextMenu(page: Page, name: string) { | ||
await page.getByRole('row', { name }).getByRole('button').first().click() | ||
} | ||
|
||
export async function walletInList(page: Page, name: string) { | ||
await expect(page.getByRole('table').getByText(name).first()).toBeVisible() | ||
} | ||
|
||
export async function walletNotInList(page: Page, name: string) { | ||
await expect(page.getByRole('table').getByText(name).first()).toBeHidden() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { mockApiDefaults } from '@siafoundation/walletd-mock' | ||
import { login } from '../fixtures/login' | ||
|
||
test('login', async ({ page }) => { | ||
await mockApiDefaults({ page }) | ||
await login({ page }) | ||
await expect(page.getByRole('button', { name: 'Add wallet' })).toBeVisible() | ||
await expect(page.getByTestId('navbar').getByText('Wallets')).toBeVisible() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.