Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion e2e/authorize.mock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ test.describe('DWEB 授权 - 截图测试', () => {
await page.waitForLoadState('networkidle')

// 点击确认按钮(使用多语言正则)
await page.locator(`button:has-text("${UI_TEXT.drawPattern.source}")`).click()
await page.getByRole('button', { name: UI_TEXT.drawPattern }).click()
await page.waitForTimeout(500)

await expect(page).toHaveScreenshot('authorize-wallet-lock-confirm.png')
Expand Down
2 changes: 1 addition & 1 deletion e2e/chain-config-subscription.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SUBSCRIPTION_CONFIGS = [
{
id: 'bf-sub',
version: '1.0',
type: 'bioforest',
chainKind: 'bioforest',
name: 'BF Sub',
symbol: 'BFS',
decimals: 8,
Expand Down
38 changes: 19 additions & 19 deletions e2e/contact-scanner.mock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ async function createTestWallet(page: Page) {
await page.waitForSelector('[data-testid="pattern-step"]')

await drawPattern(page, 'pattern-lock-set-grid', DEFAULT_PATTERN)
const nextButton = page.locator('[data-testid="pattern-lock-next-button"]')
if (await nextButton.isVisible().catch(() => false)) {
await nextButton.click()
}
await page.waitForSelector('[data-testid="pattern-lock-confirm-grid"]')
await drawPattern(page, 'pattern-lock-confirm-grid', DEFAULT_PATTERN)

Expand All @@ -74,7 +78,11 @@ async function createTestWallet(page: Page) {
await page.click('[data-testid="verify-next-button"]')
await page.waitForSelector('[data-testid="chain-selector-step"]')
await page.click('[data-testid="chain-selector-complete-button"]')
await page.waitForURL('/#/')

await page.waitForSelector('[data-testid="theme-step"]')
await page.click('[data-testid="theme-complete-button"]')

await page.waitForURL(/.*#\/$/)
await page.waitForSelector('[data-testid="chain-selector"]', { timeout: 10000 })
}

Expand Down Expand Up @@ -106,27 +114,19 @@ test.describe('联系人分享流程', () => {
})

test('通讯录页面可访问', async ({ page }) => {
await page.goto('/#/address-book')
await page.waitForTimeout(500)
// 应该显示通讯录页面
await expect(page.locator('text=通讯录').or(page.locator('text=Address Book'))).toBeVisible()
await page.getByTestId('tab-settings').click()
await page.getByTestId('address-book-button').click()

const title = page.locator('[data-testid="page-title"]').filter({ hasText: /通讯录|Address Book/i }).first()
await expect(title).toBeVisible()
})

test('可以添加联系人', async ({ page }) => {
await page.goto('/#/address-book')
await page.waitForTimeout(500)

// 点击添加按钮
const addButton = page.locator('[aria-label*="add" i], [aria-label*="添加" i], button:has(svg)').first()
if (await addButton.isVisible()) {
await addButton.click()
await page.waitForTimeout(300)

// 应该打开添加联系人表单
const nameInput = page.locator('input[placeholder*="name" i], input[placeholder*="名称" i]').first()
await expect(nameInput).toBeVisible({ timeout: 2000 })
}
await page.getByTestId('tab-settings').click()
await page.getByTestId('address-book-button').click()

await page.getByTestId('address-book-add-button').click()
await expect(page.getByRole('heading', { name: /添加联系人|Add Contact/i })).toBeVisible()
})
})

Expand Down
4 changes: 2 additions & 2 deletions e2e/helpers/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ export function getAriaLabel(key: keyof typeof UI_TEXT): RegExp {
* await btn.click()
*/
export function i18nLocator(page: Page, selector: string, text: RegExp): Locator {
return page.locator(`${selector}:has-text("${text.source}")`)
return page.locator(selector).filter({ hasText: text })
}

/**
* 等待多语言文本出现
*/
export async function waitForI18nText(page: Page, text: RegExp, options?: { timeout?: number }) {
await page.waitForSelector(`text=${text.source}`, options)
await page.getByText(text).first().waitFor({ state: 'visible', timeout: options?.timeout })
}

/**
Expand Down
15 changes: 7 additions & 8 deletions e2e/pages.mock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,13 @@ test.describe('通知页面', () => {

// 测试地址簿数据(多地址联系人)
const TEST_CONTACTS_DATA = {
version: 3,
contacts: [
{
id: 'contact-1',
name: 'Alice',
addresses: [
{ id: 'addr-1', address: '0x1234567890abcdef1234567890abcdef12345678', chainType: 'ethereum', isDefault: true },
{ id: 'addr-1', address: '0x1234567890abcdef1234567890abcdef12345678', isDefault: true },
],
memo: '同事',
createdAt: Date.now() - 86400000,
Expand All @@ -271,8 +272,8 @@ const TEST_CONTACTS_DATA = {
id: 'contact-2',
name: 'Bob',
addresses: [
{ id: 'addr-2', address: '0xabcdef1234567890abcdef1234567890abcdef12', chainType: 'ethereum', isDefault: true },
{ id: 'addr-3', address: 'c7R6wVdPvHqvRxe5Q9ZvWr7CpPn5Mk5Xz3', chainType: 'bfmeta' },
{ id: 'addr-2', address: '0xabcdef1234567890abcdef1234567890abcdef12', isDefault: true },
{ id: 'addr-3', address: 'c7R6wVdPvHqvRxe5Q9ZvWr7CpPn5Mk5Xz3' },
],
createdAt: Date.now() - 172800000,
updatedAt: Date.now() - 172800000,
Expand All @@ -281,17 +282,15 @@ const TEST_CONTACTS_DATA = {
id: 'contact-3',
name: '多链用户',
addresses: [
{ id: 'addr-4', address: '0x9876543210fedcba9876543210fedcba98765432', chainType: 'ethereum', isDefault: true },
{ id: 'addr-5', address: 'c7R6wVdPvHqvRxe5Q9ZvWr7CpPn5Mk5Xz3', chainType: 'bfmeta' },
{ id: 'addr-6', address: 'TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW', chainType: 'tron' },
{ id: 'addr-4', address: '0x9876543210fedcba9876543210fedcba98765432', isDefault: true },
{ id: 'addr-5', address: 'c7R6wVdPvHqvRxe5Q9ZvWr7CpPn5Mk5Xz3' },
{ id: 'addr-6', address: 'TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW' },
],
memo: '支持多链转账',
createdAt: Date.now() - 259200000,
updatedAt: Date.now() - 259200000,
},
],
isInitialized: true,
version: 2,
}

// 辅助函数:设置测试联系人
Expand Down
Binary file modified e2e/screenshots/contact-01-address-book.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/screenshots/contact-02-send-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/screenshots/contact-03-address-input-focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/screenshots/debug-01-address-book.png
Binary file modified e2e/screenshots/debug-02-send-page.png
31 changes: 24 additions & 7 deletions e2e/wallet-create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getWalletDataFromIndexedDB } from './utils/indexeddb-helper'
*/

const DEFAULT_PATTERN = [0, 1, 2, 5]
const E2E_MNEMONIC = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'

async function drawPattern(page: Page, gridTestId: string, nodes: number[]): Promise<void> {
const grid = page.locator(`[data-testid="${gridTestId}"]`)
Expand Down Expand Up @@ -53,6 +54,9 @@ async function fillVerifyInputs(page: Page, words: string[]): Promise<void> {
test.describe('钱包创建流程 - 截图测试', () => {
test.beforeEach(async ({ page }) => {
// 清除本地存储,确保干净状态
await page.addInitScript((mnemonic) => {
;(window as any).__E2E_MNEMONIC__ = mnemonic
}, E2E_MNEMONIC)
await page.addInitScript(() => localStorage.clear())
})

Expand Down Expand Up @@ -132,6 +136,9 @@ test.describe('钱包创建流程 - 截图测试', () => {

test.describe('钱包创建流程 - 功能测试', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript((mnemonic) => {
;(window as any).__E2E_MNEMONIC__ = mnemonic
}, E2E_MNEMONIC)
await page.addInitScript(() => localStorage.clear())
})

Expand Down Expand Up @@ -190,14 +197,20 @@ test.describe('钱包创建流程 - 功能测试', () => {

// 7. 验证跳转到首页且钱包已创建
await page.waitForURL(/.*#\/$/)
// 等待钱包名称显示,确认首页加载完成
await expect(page.locator('[data-testid="wallet-name"]:visible').first()).toBeVisible({ timeout: 10000 })

await expect
.poll(async () => {
const wallets = await getWalletDataFromIndexedDB(page)
return wallets.length
}, {
timeout: 10_000,
})
.toBe(1)

const wallets = await getWalletDataFromIndexedDB(page)
expect(wallets).toHaveLength(1)
expect(wallets[0].name).toBe('主钱包')
expect(wallets[0]?.name).toBe('主钱包')

const bioforestChains = ['bfmeta', 'pmchain', 'ccchain', 'bfchainv2', 'btgmeta', 'biwmeta', 'ethmeta', 'malibu']
const bioforestChains = ['bfmeta', 'pmchain', 'ccchain', 'bfchainv2', 'btgmeta', 'biwmeta', 'ethmeta']
for (const chain of bioforestChains) {
const chainAddr = wallets[0].chainAddresses.find((ca: { chain: string }) => ca.chain === chain)
expect(chainAddr, `应该有 ${chain} 地址`).toBeDefined()
Expand All @@ -211,7 +224,7 @@ test.describe('钱包创建流程 - 功能测试', () => {
const manualConfig = JSON.stringify({
id: 'bf-demo',
version: '1.0',
type: 'bioforest',
chainKind: 'bioforest',
name: 'BF Demo',
symbol: 'BFD',
decimals: 8,
Expand Down Expand Up @@ -253,8 +266,9 @@ test.describe('钱包创建流程 - 功能测试', () => {
await page.waitForSelector('[data-testid="chain-selector-step"]')
await page.locator('[data-testid="chain-selector-group-toggle-evm"]').click()
await page.locator('[data-testid="chain-selector-chain-ethereum"]').click()
await page.locator('[data-testid="chain-selector-group-toggle-bip39"]').click()
await page.locator('[data-testid="chain-selector-group-toggle-bitcoin"]').click()
await page.locator('[data-testid="chain-selector-chain-bitcoin"]').click()
await page.locator('[data-testid="chain-selector-group-toggle-tron"]').click()
await page.locator('[data-testid="chain-selector-chain-tron"]').click()

await page.click('[data-testid="chain-selector-complete-button"]')
Expand Down Expand Up @@ -324,6 +338,9 @@ test.describe('钱包创建流程 - 功能测试', () => {

test.describe('钱包导入流程 - 截图测试', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript((mnemonic) => {
;(window as any).__E2E_MNEMONIC__ = mnemonic
}, E2E_MNEMONIC)
await page.addInitScript(() => localStorage.clear())
})

Expand Down
Loading