Skip to content

Commit

Permalink
Merge pull request #314 from tonkeeper/feature/tests
Browse files Browse the repository at this point in the history
Update locators
  • Loading branch information
KuznetsovNikita authored Nov 21, 2024
2 parents 2dc391c + 13e62d9 commit 99cdf18
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 110 deletions.
9 changes: 2 additions & 7 deletions tests/playwright/tests/12WordMnemonic/trust value.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
21 changes: 9 additions & 12 deletions tests/playwright/tests/NegativeCases/Negative.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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.');
Expand All @@ -52,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();
Expand Down
108 changes: 64 additions & 44 deletions tests/playwright/tests/Ton Connect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { test, expect, Page } from '@playwright/test';

test.beforeEach(async ({ page }) => {
await page.goto('/');
Expand All @@ -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')
Expand All @@ -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();
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 expect(
page.locator('#react-portal-modal-container').getByText('UQAG…gyIO')
Expand All @@ -69,57 +77,69 @@ 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')
).toBeVisible();
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');
});
Expand Down
12 changes: 3 additions & 9 deletions tests/playwright/tests/Transactions/Send TON.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
11 changes: 3 additions & 8 deletions tests/playwright/tests/Transactions/Swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 99cdf18

Please sign in to comment.