diff --git a/e2e/accept-a-payment.test.ts b/e2e/accept-a-payment.test.ts new file mode 100644 index 0000000..eac5e9c --- /dev/null +++ b/e2e/accept-a-payment.test.ts @@ -0,0 +1,43 @@ +import { expect, test } from '@playwright/test' + +test('accept a payment', async ({ page }) => { + test.setTimeout(120000) + + // Set up virtual authenticator via CDP + const client = await page.context().newCDPSession(page) + await client.send('WebAuthn.enable') + const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', { + options: { + protocol: 'ctap2', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, + }, + }) + + await page.goto('/guide/payments/accept-a-payment') + + // Step 1: Sign up with passkey + const signUpButton = page.getByRole('button', { name: 'Sign up' }).first() + await expect(signUpButton).toBeVisible({ timeout: 90000 }) + // Wait for page to fully initialize + await page.waitForTimeout(1000) + await signUpButton.click() + + await expect(page.getByRole('button', { name: 'Sign out' }).first()).toBeVisible({ + timeout: 60000, + }) + + // Step 2: Add funds (this is the last step - balance updates confirm receipt) + const addFundsButton = page.getByRole('button', { name: 'Add funds' }).first() + await expect(addFundsButton).toBeVisible() + await addFundsButton.click() + + await expect(page.getByRole('button', { name: 'Add more funds' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Clean up + await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) +}) diff --git a/e2e/managing-fee-liquidity.test.ts b/e2e/managing-fee-liquidity.test.ts new file mode 100644 index 0000000..a4ceb54 --- /dev/null +++ b/e2e/managing-fee-liquidity.test.ts @@ -0,0 +1,82 @@ +import { expect, test } from '@playwright/test' + +test('manage fee liquidity', async ({ page }) => { + test.setTimeout(240000) + + // Set up virtual authenticator via CDP + const client = await page.context().newCDPSession(page) + await client.send('WebAuthn.enable') + const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', { + options: { + protocol: 'ctap2', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, + }, + }) + + await page.goto('/guide/stablecoin-dex/managing-fee-liquidity') + + // Step 1: Sign up with passkey + const signUpButton = page.getByRole('button', { name: 'Sign up' }).first() + await expect(signUpButton).toBeVisible({ timeout: 90000 }) + // Wait for page to fully initialize + await page.waitForTimeout(1000) + await signUpButton.click() + + await expect(page.getByRole('button', { name: 'Sign out' }).first()).toBeVisible({ + timeout: 60000, + }) + + // Step 2: Add funds + const addFundsButton = page.getByRole('button', { name: 'Add funds' }).first() + await expect(addFundsButton).toBeVisible() + await addFundsButton.click() + + await expect(page.getByRole('button', { name: 'Add more funds' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Step 3: Create or load token + const nameInput = page.getByLabel('Token name').first() + await expect(nameInput).toBeVisible() + await nameInput.fill('FeeLiquidityUSD') + + const symbolInput = page.getByLabel('Token symbol').first() + await expect(symbolInput).toBeVisible() + await symbolInput.fill('FEELIQ') + + const deployButton = page.getByRole('button', { name: 'Deploy' }).first() + await expect(deployButton).toBeVisible() + await deployButton.click() + + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Step 4: Add liquidity (mint) + const addLiquidityButton = page.getByRole('button', { name: 'Add Liquidity' }).first() + await expect(addLiquidityButton).toBeVisible() + await addLiquidityButton.click() + + await expect(page.getByRole('link', { name: 'View receipt' }).nth(1)).toBeVisible({ + timeout: 90000, + }) + + // Step 5: Check pool (no action needed, pool info should be visible after adding liquidity) + // The pool data is displayed inline; just wait a moment for it to update + await page.waitForTimeout(2000) + + // Step 6: Burn liquidity + const burnLiquidityButton = page.getByRole('button', { name: 'Burn Liquidity' }).first() + await expect(burnLiquidityButton).toBeVisible({ timeout: 30000 }) + await burnLiquidityButton.click() + + await expect(page.getByRole('link', { name: 'View receipt' }).nth(2)).toBeVisible({ + timeout: 90000, + }) + + // Clean up + await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) +}) diff --git a/e2e/pay-fees-in-any-stablecoin.test.ts b/e2e/pay-fees-in-any-stablecoin.test.ts new file mode 100644 index 0000000..94b6dc8 --- /dev/null +++ b/e2e/pay-fees-in-any-stablecoin.test.ts @@ -0,0 +1,53 @@ +import { expect, test } from '@playwright/test' + +test('pay fees in any stablecoin', async ({ page }) => { + test.setTimeout(120000) + + // Set up virtual authenticator via CDP + const client = await page.context().newCDPSession(page) + await client.send('WebAuthn.enable') + const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', { + options: { + protocol: 'ctap2', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, + }, + }) + + await page.goto('/guide/payments/pay-fees-in-any-stablecoin') + + // Step 1: Sign up with passkey + const signUpButton = page.getByRole('button', { name: 'Sign up' }).first() + await expect(signUpButton).toBeVisible({ timeout: 90000 }) + // Wait for page to fully initialize + await page.waitForTimeout(1000) + await signUpButton.click() + + await expect(page.getByRole('button', { name: 'Sign out' }).first()).toBeVisible({ + timeout: 60000, + }) + + // Step 2: Add funds + const addFundsButton = page.getByRole('button', { name: 'Add funds' }).first() + await expect(addFundsButton).toBeVisible() + await addFundsButton.click() + + await expect(page.getByRole('button', { name: 'Add more funds' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Step 3: Pay with fee token + const enterDetailsButton = page.getByRole('button', { name: 'Enter details' }).first() + await expect(enterDetailsButton).toBeVisible() + await enterDetailsButton.click() + + const sendButton = page.getByRole('button', { name: 'Send' }).first() + await sendButton.click() + + await expect(page.getByRole('link', { name: 'View receipt' })).toBeVisible({ timeout: 90000 }) + + // Clean up + await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) +}) diff --git a/e2e/send-parallel-transactions.test.ts b/e2e/send-parallel-transactions.test.ts new file mode 100644 index 0000000..01c82bb --- /dev/null +++ b/e2e/send-parallel-transactions.test.ts @@ -0,0 +1,65 @@ +import { expect, test } from '@playwright/test' + +test('send parallel transactions', async ({ page }) => { + test.setTimeout(120000) + + // Set up virtual authenticator via CDP + const client = await page.context().newCDPSession(page) + await client.send('WebAuthn.enable') + const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', { + options: { + protocol: 'ctap2', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, + }, + }) + + await page.goto('/guide/payments/send-parallel-transactions') + + // Step 1: Sign up with passkey + const signUpButton = page.getByRole('button', { name: 'Sign up' }).first() + await expect(signUpButton).toBeVisible({ timeout: 90000 }) + + // Wait a moment for the page to fully initialize + await page.waitForTimeout(1000) + + await signUpButton.click() + + // Wait for sign out button (indicates successful sign up) + await expect(page.getByRole('button', { name: 'Sign out' }).first()).toBeVisible({ + timeout: 30000, + }) + + // Step 2: Add funds + const addFundsButton = page.getByRole('button', { name: 'Add funds' }).first() + await expect(addFundsButton).toBeVisible() + await addFundsButton.click() + + // Wait for "Add more funds" button (indicates funds were added) + await expect(page.getByRole('button', { name: 'Add more funds' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Step 3: Send parallel payments + const enterDetailsButton = page.getByRole('button', { name: 'Enter details' }).first() + await expect(enterDetailsButton).toBeVisible() + await enterDetailsButton.click() + + // Click send both payments + const sendBothButton = page.getByRole('button', { name: 'Send both payments' }) + await expect(sendBothButton).toBeVisible() + await sendBothButton.click() + + // Wait for both transaction receipt links + await expect(page.getByRole('link', { name: 'View receipt' }).first()).toBeVisible({ + timeout: 90000, + }) + await expect(page.getByRole('link', { name: 'View receipt' }).nth(1)).toBeVisible({ + timeout: 90000, + }) + + // Clean up + await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) +}) diff --git a/e2e/sponsor-user-fees.test.ts b/e2e/sponsor-user-fees.test.ts new file mode 100644 index 0000000..7f192e5 --- /dev/null +++ b/e2e/sponsor-user-fees.test.ts @@ -0,0 +1,53 @@ +import { expect, test } from '@playwright/test' + +test('sponsor user fees', async ({ page }) => { + test.setTimeout(120000) + + // Set up virtual authenticator via CDP + const client = await page.context().newCDPSession(page) + await client.send('WebAuthn.enable') + const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', { + options: { + protocol: 'ctap2', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, + }, + }) + + await page.goto('/guide/payments/sponsor-user-fees') + + // Step 1: Sign up with passkey + const signUpButton = page.getByRole('button', { name: 'Sign up' }).first() + await expect(signUpButton).toBeVisible({ timeout: 90000 }) + // Wait for page to fully initialize + await page.waitForTimeout(1000) + await signUpButton.click() + + await expect(page.getByRole('button', { name: 'Sign out' }).first()).toBeVisible({ + timeout: 60000, + }) + + // Step 2: Add funds + const addFundsButton = page.getByRole('button', { name: 'Add funds' }).first() + await expect(addFundsButton).toBeVisible() + await addFundsButton.click() + + await expect(page.getByRole('button', { name: 'Add more funds' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Step 3: Send sponsored payment + const enterDetailsButton = page.getByRole('button', { name: 'Enter details' }).first() + await expect(enterDetailsButton).toBeVisible() + await enterDetailsButton.click() + + const sendButton = page.getByRole('button', { name: 'Send' }).first() + await sendButton.click() + + await expect(page.getByRole('link', { name: 'View receipt' })).toBeVisible({ timeout: 90000 }) + + // Clean up + await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) +}) diff --git a/e2e/transfer-memos.test.ts b/e2e/transfer-memos.test.ts new file mode 100644 index 0000000..24d81c9 --- /dev/null +++ b/e2e/transfer-memos.test.ts @@ -0,0 +1,53 @@ +import { expect, test } from '@playwright/test' + +test('transfer with memo', async ({ page }) => { + test.setTimeout(120000) + + // Set up virtual authenticator via CDP + const client = await page.context().newCDPSession(page) + await client.send('WebAuthn.enable') + const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', { + options: { + protocol: 'ctap2', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, + }, + }) + + await page.goto('/guide/payments/transfer-memos') + + // Step 1: Sign up with passkey + const signUpButton = page.getByRole('button', { name: 'Sign up' }).first() + await expect(signUpButton).toBeVisible({ timeout: 90000 }) + // Wait for page to fully initialize + await page.waitForTimeout(1000) + await signUpButton.click() + + await expect(page.getByRole('button', { name: 'Sign out' }).first()).toBeVisible({ + timeout: 60000, + }) + + // Step 2: Add funds + const addFundsButton = page.getByRole('button', { name: 'Add funds' }).first() + await expect(addFundsButton).toBeVisible() + await addFundsButton.click() + + await expect(page.getByRole('button', { name: 'Add more funds' }).first()).toBeVisible({ + timeout: 90000, + }) + + // Step 3: Send payment with memo + const enterDetailsButton = page.getByRole('button', { name: 'Enter details' }).first() + await expect(enterDetailsButton).toBeVisible() + await enterDetailsButton.click() + + const sendButton = page.getByRole('button', { name: 'Send' }).first() + await sendButton.click() + + await expect(page.getByRole('link', { name: 'View receipt' })).toBeVisible({ timeout: 90000 }) + + // Clean up + await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }) +})