From 2387d464866036a93248ccbfccca44573ba5691c Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 21 Nov 2024 19:22:17 +0100 Subject: [PATCH 1/5] Update locators --- .../tests/12WordMnemonic/trust value.spec.ts | 9 ++------- .../2 wallets & bulk delete.spec.ts | 9 ++------- .../Add existing general wallet.spec.ts | 18 ++++-------------- .../tests/Transactions/Send TON.spec.ts | 12 +++--------- .../Send usdt from token screen.spec.ts | 11 ++--------- .../playwright/tests/Transactions/Swap.spec.ts | 11 +++-------- 6 files changed, 16 insertions(+), 54 deletions(-) diff --git a/tests/playwright/tests/12WordMnemonic/trust value.spec.ts b/tests/playwright/tests/12WordMnemonic/trust value.spec.ts index e1f862b0f..0739b9084 100644 --- a/tests/playwright/tests/12WordMnemonic/trust value.spec.ts +++ b/tests/playwright/tests/12WordMnemonic/trust value.spec.ts @@ -12,13 +12,8 @@ test('trust + assert visibility and value', async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_12_2); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page .locator('#react-portal-modal-container') diff --git a/tests/playwright/tests/Add2WalletsAndDeleteInABulk/2 wallets & bulk delete.spec.ts b/tests/playwright/tests/Add2WalletsAndDeleteInABulk/2 wallets & bulk delete.spec.ts index e26d9c90a..216b59033 100644 --- a/tests/playwright/tests/Add2WalletsAndDeleteInABulk/2 wallets & bulk delete.spec.ts +++ b/tests/playwright/tests/Add2WalletsAndDeleteInABulk/2 wallets & bulk delete.spec.ts @@ -8,13 +8,8 @@ test('2 wallets & bulk delete', async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_24_5); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Save' }).click(); await page.getByText('Add Wallet').click(); diff --git a/tests/playwright/tests/AddExistingWallets/Add existing general wallet.spec.ts b/tests/playwright/tests/AddExistingWallets/Add existing general wallet.spec.ts index f77e83204..df40c8ecd 100644 --- a/tests/playwright/tests/AddExistingWallets/Add existing general wallet.spec.ts +++ b/tests/playwright/tests/AddExistingWallets/Add existing general wallet.spec.ts @@ -10,13 +10,8 @@ test('Add general wallet', async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_24); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Save' }).click(); await page.getByRole('link', { name: 'Settings' }).click(); @@ -39,13 +34,8 @@ test('Add my test wallet & hide version', async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_24_2); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.locator('#react-portal-modal-container').getByRole('textbox').fill('My test wallet'); await page.getByText('👽').click(); diff --git a/tests/playwright/tests/Transactions/Send TON.spec.ts b/tests/playwright/tests/Transactions/Send TON.spec.ts index d273bcc49..3d4be244d 100644 --- a/tests/playwright/tests/Transactions/Send TON.spec.ts +++ b/tests/playwright/tests/Transactions/Send TON.spec.ts @@ -1,6 +1,5 @@ import { test, expect } from '@playwright/test'; - test.beforeEach(async ({ page }) => { await page.goto('/'); await page.getByRole('button', { name: 'Get started' }).click(); @@ -9,13 +8,8 @@ test.beforeEach(async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_ANANAS); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.locator('#react-portal-modal-container').getByRole('textbox').fill('Ananas'); await page.getByRole('button', { name: 'Save' }).click(); @@ -47,4 +41,4 @@ test('Transfer TON', async ({ page }) => { await page.getByRole('button', { name: 'Confirm and Send' }).click(); await page.locator('#react-portal-modal-container').getByRole('textbox').fill('123456'); await page.getByRole('button', { name: 'Confirm' }).click(); -}); \ No newline at end of file +}); diff --git a/tests/playwright/tests/Transactions/Send usdt from token screen.spec.ts b/tests/playwright/tests/Transactions/Send usdt from token screen.spec.ts index 60c0e4d9f..b95ce94bd 100644 --- a/tests/playwright/tests/Transactions/Send usdt from token screen.spec.ts +++ b/tests/playwright/tests/Transactions/Send usdt from token screen.spec.ts @@ -10,13 +10,8 @@ test.beforeEach(async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_ANANAS); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.locator('#react-portal-modal-container').getByRole('textbox').fill('Ananas'); await page.getByRole('button', { name: 'Save' }).click(); @@ -33,9 +28,7 @@ test.afterEach(async ({ page }) => { await page.getByRole('button', { name: 'Delete wallet data' }).click(); }); - test('Transfer usdt', async ({ page }) => { - await page.getByText('USD₮').nth(1).click(); await page.getByRole('button', { name: 'Send' }).nth(2).click(); await page.getByRole('textbox').first().click(); diff --git a/tests/playwright/tests/Transactions/Swap.spec.ts b/tests/playwright/tests/Transactions/Swap.spec.ts index 799bbaaf6..bf152592c 100644 --- a/tests/playwright/tests/Transactions/Swap.spec.ts +++ b/tests/playwright/tests/Transactions/Swap.spec.ts @@ -12,13 +12,8 @@ test.beforeEach(async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_ANANAS); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Save' }).click(); }); @@ -63,7 +58,7 @@ test.describe('Swap Test', () => { await expect(page.getByText('Pending')).toBeVisible({ timeout: 40 * 1000 }); }); -//swap usdt => ton + //swap usdt => ton test('Should send swap usdt to ton and wait pending transaction', async ({ page }) => { await expect(page.getByRole('link', { name: 'Swap' })).toBeVisible(); From c3c2c4273d445d064314f8a4837d90798c5e8780 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 21 Nov 2024 20:16:42 +0100 Subject: [PATCH 2/5] Update ton connect tests --- tests/playwright/tests/Ton Connect.spec.ts | 108 ++++++++++++--------- 1 file changed, 64 insertions(+), 44 deletions(-) diff --git a/tests/playwright/tests/Ton Connect.spec.ts b/tests/playwright/tests/Ton Connect.spec.ts index e41ea3b32..06851687b 100644 --- a/tests/playwright/tests/Ton Connect.spec.ts +++ b/tests/playwright/tests/Ton Connect.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test'; +import { test, expect, Page } from '@playwright/test'; test.beforeEach(async ({ page }) => { await page.goto('/'); @@ -8,19 +8,14 @@ test.beforeEach(async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_24); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123456'); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Save' }).click(); }); test.afterEach(async ({ page }) => { - await page.goto('/wallet-settings'); + await page.getByRole('link', { name: 'Settings' }).click(); await page.getByText('Delete Account').click(); await page .locator('div') @@ -30,27 +25,40 @@ test.afterEach(async ({ page }) => { await page.getByRole('button', { name: 'Delete wallet data' }).click(); }); +const connectUrl = async (page: Page, clipboardContent: string) => { + if (process.env.BASE_APP_URL === 'https://wallet.tonkeeper.com') { + await page.goto(clipboardContent); + await page.getByRole('link', { name: 'Sign in with Tonkeeper Web' }).click(); + } else { + await page.goto(`/ton-connect${new URL(clipboardContent).search}`); + } +}; + //TON Connect + go to the settings => Connected Apps + check asserts and elements test.describe('ton connect', () => { - test('elements', async ({ page }) => { + test('elements', async ({ page, context }) => { + await context.grantPermissions(['clipboard-read', 'clipboard-write']); + await page.getByText('Discover').click(); + const page1Promise = page.waitForEvent('popup'); - await page.locator('div:nth-child(4) > .sc-dxeFTI > div > .sc-bcKLde').first().click(); + + await page.getByText('STON.fi').nth(0).click(); + + // wait new page const page1 = await page1Promise; - await page.getByText('STON.fi').nth(2).click(); + await page1.getByRole('button', { name: 'Connect wallet' }).click(); await page1.getByRole('button', { name: 'Tonkeeper Popular' }).click(); await page1.locator('.go1369062826').first().click(); - // await page.goto( - // 'https://app.tonkeeper.com/ton-connect?v=2&id=9c251162746584e1160d0c827e5ca9b182e3db0c901ae980e1cda70f18666a3b&r=%7B%22manifestUrl%22%3A%22https%3A%2F%2Fapp.ston.fi%2Ftonconnect-manifest.json%22%2C%22items%22%3A%5B%7B%22name%22%3A%22ton_addr%22%7D%5D%7D&ret=none' - // ); - // // TODO: this test is not working as soon as follow link will navigate to production wallet.tonkeeper.com, instead of testing version - // await page.getByRole('link', { name: 'Sign in with Tonkeeper Web' }).click(); - await page.goto( - `/ton-connect?v=2&id=9c251162746584e1160d0c827e5ca9b182e3db0c901ae980e1cda70f18666a3b&r=%7B%22manifestUrl%22%3A%22https%3A%2F%2Fapp.ston.fi%2Ftonconnect-manifest.json%22%2C%22items%22%3A%5B%7B%22name%22%3A%22ton_addr%22%7D%5D%7D&ret=none` - ); + // get copied link + const handle = await page1.evaluateHandle(() => navigator.clipboard.readText()); + const clipboardContent = await handle.jsonValue(); + + // navigate back to wallet + await connectUrl(page, clipboardContent); await expect( page.locator('#react-portal-modal-container').getByText('UQAG…gyIO') @@ -69,47 +77,54 @@ test.describe('ton connect', () => { .click(); }); - test('STON fi', async ({ page }) => { + test('STON fi', async ({ page, context }) => { + await context.grantPermissions(['clipboard-read', 'clipboard-write']); + await page.getByText('Discover').click(); const page1Promise = page.waitForEvent('popup'); - await page.locator('div:nth-child(4) > .sc-dxeFTI > div > .sc-bcKLde').first().click(); - const page1 = await page1Promise; + await page.getByText('STON.fi').nth(2).click(); + // wait new page + const page1 = await page1Promise; + await page1.getByRole('button', { name: 'Connect wallet' }).click(); await page1.getByRole('button', { name: 'Tonkeeper Popular' }).click(); await page1.locator('.go1369062826').first().click(); - // await page.goto( - // 'https://app.tonkeeper.com/ton-connect?v=2&id=9c251162746584e1160d0c827e5ca9b182e3db0c901ae980e1cda70f18666a3b&r=%7B%22manifestUrl%22%3A%22https%3A%2F%2Fapp.ston.fi%2Ftonconnect-manifest.json%22%2C%22items%22%3A%5B%7B%22name%22%3A%22ton_addr%22%7D%5D%7D&ret=none' - // ); - // // TODO: this test is not working as soon as follow link will navigate to production wallet.tonkeeper.com, instead of testing version - // await page.getByRole('link', { name: 'Sign in with Tonkeeper Web' }).click(); - await page.goto( - `/ton-connect?v=2&id=9c251162746584e1160d0c827e5ca9b182e3db0c901ae980e1cda70f18666a3b&r=%7B%22manifestUrl%22%3A%22https%3A%2F%2Fapp.ston.fi%2Ftonconnect-manifest.json%22%2C%22items%22%3A%5B%7B%22name%22%3A%22ton_addr%22%7D%5D%7D&ret=none` - ); + // get copied link + const handle = await page1.evaluateHandle(() => navigator.clipboard.readText()); + const clipboardContent = await handle.jsonValue(); + + // navigate back to wallet + await connectUrl(page, clipboardContent); await page.getByRole('button', { name: 'Connect wallet' }).click(); }); - test('Getgems', async ({ page }) => { + test('Getgems', async ({ page, context }) => { + await context.grantPermissions(['clipboard-read', 'clipboard-write']); + await page.getByText('Discover').click(); const page1Promise = page.waitForEvent('popup'); - await page.locator('div:nth-child(5) > .sc-dxeFTI > div > .sc-bcKLde').first().click(); + + const link = page.getByText('Getgems').nth(1); // second + await link.scrollIntoViewIfNeeded(); + await link.click(); + const page1 = await page1Promise; - await page.getByText('Getgems').nth(2).click(); - await page1.getByRole('button', { name: 'Connect Wallet' }).click(); + + await page1.getByRole('button', { name: 'Connect wallet' }).click(); await page1.getByRole('button', { name: 'Tonkeeper Popular' }).click(); - await page1.locator('.go1369062826').first().click(); - // await page.goto( - // 'https://app.tonkeeper.com/ton-connect?v=2&id=29f2d58c1c8f4069ae394c99f62ab4ae7affd04a9fa1f3676e3cd13cd1ffe011&r=%7B%22manifestUrl%22%3A%22https%3A%2F%2Fgetgems.io%2Ftcm.json%22%2C%22items%22%3A%5B%7B%22name%22%3A%22ton_addr%22%7D%2C%7B%22name%22%3A%22ton_proof%22%2C%22payload%22%3A%22gems%22%7D%5D%7D&ret=none' - // ); - // // TODO: this test is not working as soon as follow link will navigate to production wallet.tonkeeper.com, instead of testing version - // await page.getByRole('link', { name: 'Sign in with Tonkeeper Web' }).click(); + const buttonOnGetGems = page1.locator('.go1369062826').first(); + await buttonOnGetGems.click(); + + // get copied link + const handle = await page1.evaluateHandle(() => navigator.clipboard.readText()); + const clipboardContent = await handle.jsonValue(); - await page.goto( - `/ton-connect?v=2&id=29f2d58c1c8f4069ae394c99f62ab4ae7affd04a9fa1f3676e3cd13cd1ffe011&r=%7B%22manifestUrl%22%3A%22https%3A%2F%2Fgetgems.io%2Ftcm.json%22%2C%22items%22%3A%5B%7B%22name%22%3A%22ton_addr%22%7D%2C%7B%22name%22%3A%22ton_proof%22%2C%22payload%22%3A%22gems%22%7D%5D%7D&ret=none` - ); + // navigate back to wallet + await connectUrl(page, clipboardContent); await expect( page.locator('#react-portal-modal-container').getByText('UQAG…gyIO') @@ -117,9 +132,14 @@ test.describe('ton connect', () => { await page.getByRole('button', { name: 'Connect wallet' }).click(); await page.locator('#react-portal-modal-container').getByRole('textbox').fill('123456'); await page.getByRole('button', { name: 'Confirm' }).click(); + await page.getByRole('link', { name: 'Settings' }).click(); await page.getByRole('link', { name: 'Connected Apps' }).click(); await expect(page.getByText('getgems.io')).toBeVisible(); + + // Expect that ton connect dialog auto closed, when it get event from http bridge + await expect(buttonOnGetGems).not.toBeAttached(); + await expect(page.getByRole('button', { name: 'Disconnect' })).toBeVisible(); await expect(page.getByRole('listitem')).toContainText('Disconnect'); }); From db72d4c237ea0fda55b6b99618dc2361eda0483f Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 21 Nov 2024 20:24:38 +0100 Subject: [PATCH 3/5] Fix selectors --- tests/playwright/tests/NegativeCases/Negative.spec.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/playwright/tests/NegativeCases/Negative.spec.ts b/tests/playwright/tests/NegativeCases/Negative.spec.ts index 652cf5652..fcb7c8c8d 100644 --- a/tests/playwright/tests/NegativeCases/Negative.spec.ts +++ b/tests/playwright/tests/NegativeCases/Negative.spec.ts @@ -26,7 +26,7 @@ test('Incorrect seed phrase ', async ({ page }) => { await expect(page.getByRole('button', { name: 'Get started' })).toBeVisible(); }); -//incorrect password to enter 2 times, error Passwords do not match + +//incorrect password to enter 2 times, error Passwords do not match + //correct password to enter + delete wallet test('Incorrect password', async ({ page }) => { @@ -37,13 +37,8 @@ test('Incorrect password', async ({ page }) => { await page.getByLabel('1:', { exact: true }).fill(process.env.TON_MNEMONIC_12); await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Continue' }).click(); - await page - .locator('div') - .filter({ hasText: /^Password$/ }) - .getByRole('textbox') - .fill('123456'); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123457'); + await page.locator('#create-password').fill('123456'); + await page.locator('#create-password-confirm').fill('123457'); await page.getByRole('button', { name: 'Continue' }).click(); await expect(page.getByText('Passwords do not match.')).toBeVisible(); await expect(page.locator('form')).toContainText('Passwords do not match.'); From 4f78e366267afde2656c9245b8c6020728093610 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 21 Nov 2024 20:28:08 +0100 Subject: [PATCH 4/5] Fix selectors --- tests/playwright/tests/NegativeCases/Negative.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/playwright/tests/NegativeCases/Negative.spec.ts b/tests/playwright/tests/NegativeCases/Negative.spec.ts index fcb7c8c8d..705931768 100644 --- a/tests/playwright/tests/NegativeCases/Negative.spec.ts +++ b/tests/playwright/tests/NegativeCases/Negative.spec.ts @@ -47,12 +47,14 @@ test('Incorrect password', async ({ page }) => { .getByText('Create passwordPasswordPasswords do not match.Re-enter passwordContinue') .click(); await page.locator('div:nth-child(2) > .sc-gGmKOd').click(); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('1234'); + + await page.locator('#create-password-confirm').fill('1234'); + await page.getByRole('button', { name: 'Continue' }).click(); await expect(page.getByText('Passwords do not match.')).toBeVisible(); - await page.getByRole('textbox').nth(1).click(); - await page.getByRole('textbox').nth(1).fill('123456'); + + await page.locator('#create-password-confirm').fill('123456'); + await page.getByRole('button', { name: 'Continue' }).click(); await page.getByRole('button', { name: 'Save' }).click(); await page.getByRole('link', { name: 'Settings' }).click(); From 13e62d988baa7cb2a90278e5bace9a7c71bcbd74 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 21 Nov 2024 20:35:15 +0100 Subject: [PATCH 5/5] Update target --- tests/playwright/tests/Ton Connect.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/playwright/tests/Ton Connect.spec.ts b/tests/playwright/tests/Ton Connect.spec.ts index 06851687b..d08f91b10 100644 --- a/tests/playwright/tests/Ton Connect.spec.ts +++ b/tests/playwright/tests/Ton Connect.spec.ts @@ -44,7 +44,7 @@ test.describe('ton connect', () => { const page1Promise = page.waitForEvent('popup'); - await page.getByText('STON.fi').nth(0).click(); + await page.getByText('STON.fi').nth(2).click(); // wait new page const page1 = await page1Promise;