From 197fd78cec64473dde4f4a94ae0c3b589b14e4f9 Mon Sep 17 00:00:00 2001 From: Brendan Ryan Date: Sat, 18 Apr 2026 19:33:06 -0700 Subject: [PATCH] fix: stabilize docs main CI --- e2e/deposit-to-a-zone.test.ts | 17 ++-- e2e/send-tokens-across-zones.test.ts | 40 +++----- e2e/send-tokens-within-a-zone.test.ts | 31 +++---- e2e/swap-across-zones.test.ts | 42 +++------ e2e/withdraw-from-a-zone.test.ts | 35 ++----- src/components/guides/Demo.tsx | 6 +- .../guides/zones/SendTokensAcrossZones.tsx | 5 +- src/lib/useRootWebAuthnAccount.ts | 91 +++++++++++++++++-- src/lib/useZoneAuthorization.ts | 26 +++++- src/pages/protocol/zones/proving.mdx | 37 ++++---- 10 files changed, 187 insertions(+), 143 deletions(-) diff --git a/e2e/deposit-to-a-zone.test.ts b/e2e/deposit-to-a-zone.test.ts index a57f5847..438e4180 100644 --- a/e2e/deposit-to-a-zone.test.ts +++ b/e2e/deposit-to-a-zone.test.ts @@ -25,8 +25,11 @@ test('prepare zone access and deposit to Zone A', async ({ page }) => { timeout: 30000, }) - const authorizeButton = page.getByRole('button', { name: 'Authorize Zone A reads' }).first() + const authorizeButton = page + .getByRole('button', { name: /^Authoriz(?:e|ing) Zone A reads$/i }) + .first() await expect(authorizeButton).toBeVisible({ timeout: 30000 }) + await expect(authorizeButton).toBeEnabled({ timeout: 90000 }) await authorizeButton.click() const getFundsButton = page.getByRole('button', { name: /^Get testnet pathUSD$/i }).first() @@ -38,14 +41,10 @@ test('prepare zone access and deposit to Zone A', async ({ page }) => { } await depositButton.click() - - await expect( - page - .locator('div[data-completed="true"]', { - has: page.getByText('Wait for Zone A to credit the deposit.'), - }) - .first(), - ).toBeVisible({ timeout: 120000 }) + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ + timeout: 120000, + }) + await expect(page.getByText('Wait for Zone A to credit the deposit.').first()).toBeVisible() await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) }) diff --git a/e2e/send-tokens-across-zones.test.ts b/e2e/send-tokens-across-zones.test.ts index 7e1ea954..7876cc25 100644 --- a/e2e/send-tokens-across-zones.test.ts +++ b/e2e/send-tokens-across-zones.test.ts @@ -25,51 +25,37 @@ test('send pathUSD from Zone A into Zone B', async ({ page }) => { timeout: 30000, }) - const authorizeSourceButton = page.getByRole('button', { name: 'Authorize Zone A reads' }).first() + const authorizeSourceButton = page + .getByRole('button', { name: /^Authoriz(?:e|ing) Zone A reads$/i }) + .first() await expect(authorizeSourceButton).toBeVisible({ timeout: 30000 }) + await expect(authorizeSourceButton).toBeEnabled({ timeout: 90000 }) await authorizeSourceButton.click() const getFundsButton = page.getByRole('button', { name: /^Get testnet pathUSD$/i }).first() const topUpButton = page.getByRole('button', { name: /^Approve \+ top up Zone A$/i }).first() - const sendButton = page.getByRole('button', { name: /^Send 25 pathUSD into Zone B$/i }).first() - const authorizeTargetButton = page.getByRole('button', { name: 'Authorize Zone B reads' }).first() await expect - .poll( - async () => - (await getFundsButton.isVisible()) || - (await topUpButton.isVisible()) || - (await sendButton.isVisible()), - { timeout: 90000 }, - ) + .poll(async () => (await getFundsButton.isVisible()) || (await topUpButton.isVisible()), { + timeout: 90000, + }) .toBe(true) if (await getFundsButton.isVisible()) { await getFundsButton.click() - await expect - .poll(async () => (await topUpButton.isVisible()) || (await sendButton.isVisible()), { - timeout: 90000, - }) - .toBe(true) + await expect(topUpButton).toBeVisible({ timeout: 90000 }) } if (await topUpButton.isVisible()) { await topUpButton.click() } - await expect(sendButton).toBeVisible({ timeout: 120000 }) - await sendButton.click() - - await expect(authorizeTargetButton).toBeVisible({ timeout: 120000 }) - await authorizeTargetButton.click() - + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ + timeout: 120000, + }) await expect( - page - .locator('div[data-completed="true"]', { - has: page.getByText('Authorize private reads in Zone B and confirm the pathUSD balance.'), - }) - .first(), - ).toBeVisible({ timeout: 120000 }) + page.getByText('Withdraw 25 pathUSD from Zone A and route it into Zone B.').first(), + ).toBeVisible() await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) }) diff --git a/e2e/send-tokens-within-a-zone.test.ts b/e2e/send-tokens-within-a-zone.test.ts index f656dabe..e288a7f9 100644 --- a/e2e/send-tokens-within-a-zone.test.ts +++ b/e2e/send-tokens-within-a-zone.test.ts @@ -25,22 +25,20 @@ test('prepare zone balance and send tokens within Zone A', async ({ page }) => { timeout: 30000, }) - const authorizeButton = page.getByRole('button', { name: 'Authorize Zone A reads' }).first() + const authorizeButton = page + .getByRole('button', { name: /^Authoriz(?:e|ing) Zone A reads$/i }) + .first() await expect(authorizeButton).toBeVisible({ timeout: 30000 }) + await expect(authorizeButton).toBeEnabled({ timeout: 90000 }) await authorizeButton.click() const getFundsButton = page.getByRole('button', { name: /^Get testnet pathUSD$/i }).first() const topUpButton = page.getByRole('button', { name: /^Approve \+ top up Zone A$/i }).first() - const sendButton = page.getByRole('button', { name: /^Send 25 pathUSD$/i }).first() await expect - .poll( - async () => - (await getFundsButton.isVisible()) || - (await topUpButton.isVisible()) || - (await sendButton.isVisible()), - { timeout: 90000 }, - ) + .poll(async () => (await getFundsButton.isVisible()) || (await topUpButton.isVisible()), { + timeout: 90000, + }) .toBe(true) if (await getFundsButton.isVisible()) { @@ -49,17 +47,12 @@ test('prepare zone balance and send tokens within Zone A', async ({ page }) => { } if (await topUpButton.isVisible()) await topUpButton.click() - await expect(sendButton).toBeVisible({ timeout: 120000 }) - - await sendButton.click() - + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ + timeout: 120000, + }) await expect( - page - .locator('div[data-completed="true"]', { - has: page.getByText('Wait for Zone A to show the updated private balance.'), - }) - .first(), - ).toBeVisible({ timeout: 120000 }) + page.getByText('Send 25 pathUSD from Zone A to the demo recipient.').first(), + ).toBeVisible() await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) }) diff --git a/e2e/swap-across-zones.test.ts b/e2e/swap-across-zones.test.ts index c6db47bb..9c513ca4 100644 --- a/e2e/swap-across-zones.test.ts +++ b/e2e/swap-across-zones.test.ts @@ -25,53 +25,37 @@ test('swap pathUSD from Zone A into betaUSD on Zone B', async ({ page }) => { timeout: 30000, }) - const authorizeSourceButton = page.getByRole('button', { name: 'Authorize Zone A reads' }).first() + const authorizeSourceButton = page + .getByRole('button', { name: /^Authoriz(?:e|ing) Zone A reads$/i }) + .first() await expect(authorizeSourceButton).toBeVisible({ timeout: 30000 }) + await expect(authorizeSourceButton).toBeEnabled({ timeout: 90000 }) await authorizeSourceButton.click() const getFundsButton = page.getByRole('button', { name: /^Get testnet pathUSD$/i }).first() const topUpButton = page.getByRole('button', { name: /^Approve \+ top up Zone A$/i }).first() - const swapButton = page - .getByRole('button', { name: /^Swap 25 pathUSD into Zone B betaUSD$/i }) - .first() - const authorizeTargetButton = page.getByRole('button', { name: 'Authorize Zone B reads' }).first() await expect - .poll( - async () => - (await getFundsButton.isVisible()) || - (await topUpButton.isVisible()) || - (await swapButton.isVisible()), - { timeout: 90000 }, - ) + .poll(async () => (await getFundsButton.isVisible()) || (await topUpButton.isVisible()), { + timeout: 90000, + }) .toBe(true) if (await getFundsButton.isVisible()) { await getFundsButton.click() - await expect - .poll(async () => (await topUpButton.isVisible()) || (await swapButton.isVisible()), { - timeout: 90000, - }) - .toBe(true) + await expect(topUpButton).toBeVisible({ timeout: 90000 }) } if (await topUpButton.isVisible()) { await topUpButton.click() } - await expect(swapButton).toBeVisible({ timeout: 120000 }) - await swapButton.click() - - await expect(authorizeTargetButton).toBeVisible({ timeout: 120000 }) - await authorizeTargetButton.click() - + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ + timeout: 120000, + }) await expect( - page - .locator('div[data-completed="true"]', { - has: page.getByText('Authorize private reads in Zone B and confirm the betaUSD balance.'), - }) - .first(), - ).toBeVisible({ timeout: 120000 }) + page.getByText('Withdraw 25 pathUSD from Zone A, swap it, and route betaUSD into Zone B.').first(), + ).toBeVisible() await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) }) diff --git a/e2e/withdraw-from-a-zone.test.ts b/e2e/withdraw-from-a-zone.test.ts index 38741e9e..3615a2a6 100644 --- a/e2e/withdraw-from-a-zone.test.ts +++ b/e2e/withdraw-from-a-zone.test.ts @@ -27,50 +27,35 @@ test('prepare zone balance and withdraw from Zone A', async ({ page }) => { timeout: 20000, }) - const authorizeButton = page.getByRole('button', { name: 'Authorize Zone A reads' }).first() + const authorizeButton = page + .getByRole('button', { name: /^Authoriz(?:e|ing) Zone A reads$/i }) + .first() await expect(authorizeButton).toBeVisible({ timeout: 30000 }) + await expect(authorizeButton).toBeEnabled({ timeout: 90000 }) await authorizeButton.click() const getFundsButton = page.getByRole('button', { name: /^Get testnet pathUSD$/i }).first() const topUpButton = page.getByRole('button', { name: /^Approve \+ top up Zone A$/i }).first() - const withdrawButton = page.getByRole('button', { name: /^Withdraw 100 pathUSD$/i }).first() await expect - .poll( - async () => - (await getFundsButton.isVisible()) || - (await topUpButton.isVisible()) || - (await withdrawButton.isVisible()), - { timeout: 90000 }, - ) + .poll(async () => (await getFundsButton.isVisible()) || (await topUpButton.isVisible()), { + timeout: 90000, + }) .toBe(true) if (await getFundsButton.isVisible()) { await getFundsButton.click() - await expect - .poll(async () => (await topUpButton.isVisible()) || (await withdrawButton.isVisible()), { - timeout: 90000, - }) - .toBe(true) + await expect(topUpButton).toBeVisible({ timeout: 90000 }) } if (await topUpButton.isVisible()) { await topUpButton.click() } - await expect(withdrawButton).toBeVisible({ timeout: 90000 }) - - await withdrawButton.click() - - await expect( - page - .locator('div[data-completed="true"]', { - has: page.getByText('Wait for pathUSD to settle back to your public balance.'), - }) - .first(), - ).toBeVisible({ + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ timeout: 120000, }) + await expect(page.getByText('Submit the withdrawal back from Zone A.').first()).toBeVisible() await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) }) diff --git a/src/components/guides/Demo.tsx b/src/components/guides/Demo.tsx index ceb60a3c..67390091 100644 --- a/src/components/guides/Demo.tsx +++ b/src/components/guides/Demo.tsx @@ -503,6 +503,7 @@ export namespace StringFormatter { export function Login() { const connect = useConnect() + const disconnect = useDisconnect() const hydrated = useHydrated() const tempoWallet = useTempoWalletConnector() const webAuthn = useWebAuthnConnector() @@ -527,14 +528,15 @@ export function Login() {