diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index bf4afef2e..e14679728 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -90,49 +90,18 @@ jobs: rm ${{ github.workspace }}/AuthKey.p8 web-build: - name: web-build - runs-on: macos-13 - timeout-minutes: 10 - - steps: - - name: Checkout to git repository - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node-version }} - - - name: Enable Corepack - run: | - corepack enable - - - name: Run install - uses: borales/actions-yarn@v5 - with: - cmd: install - - - name: Run build - uses: borales/actions-yarn@v5 - env: - VITE_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE_EXTENSION }} - VITE_APP_MEASUREMENT_ID: ${{ secrets.REACT_APP_MEASUREMENT_ID }} - VITE_APP_APTABASE: ${{ secrets.VITE_APP_APTABASE }} - VITE_APP_APTABASE_HOST: https://anonymous-analytics.tonkeeper.com - VITE_APP_LOCALES: en,zh_TW,zh_CN,id,ru,it,es,uk,tr,bg,uz,bn - VITE_APP_TONCONSOLE_HOST: https://pro.tonconsole.com - VITE_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }} - VITE_APP_STONFI_REFERRAL_ADDRESS: ${{ secrets.REACT_APP_STONFI_REFERRAL_ADDRESS }} - with: - cmd: build:web - - - name: Publish to Cloudflare Pages - id: deploy - uses: cloudflare/wrangler-action@v3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy apps/web/dist --project-name=tonkeeper-web --branch=main + uses: ./.github/workflows/web-build.yaml + with: + environment: 'main' + secrets: inherit + + web-tests: + needs: web-build + uses: ./.github/workflows/web-tests.yaml + with: + base-url: 'https://wallet.tonkeeper.com' + transaction: true + secrets: inherit extension-build: name: extension-build diff --git a/.github/workflows/deploy-web.yaml b/.github/workflows/deploy-web.yaml index eb8ecc001..c6e4261ee 100644 --- a/.github/workflows/deploy-web.yaml +++ b/.github/workflows/deploy-web.yaml @@ -12,49 +12,14 @@ on: jobs: web-deploy: - name: web-deploy - runs-on: ubuntu-latest - timeout-minutes: 10 + uses: ./.github/workflows/web-build.yaml + with: + environment: ${{ inputs.environment }} + secrets: inherit - steps: - - name: Checkout to git repository - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: 20.11.1 - - - name: Enable Corepack - run: | - corepack enable - - - name: Run install - uses: borales/actions-yarn@v5 - with: - cmd: install - - - name: Run build - uses: borales/actions-yarn@v5 - env: - VITE_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE_EXTENSION }} - VITE_APP_MEASUREMENT_ID: ${{ secrets.REACT_APP_MEASUREMENT_ID }} - VITE_APP_APTABASE: ${{ secrets.VITE_APP_APTABASE }} - VITE_APP_APTABASE_HOST: https://anonymous-analytics.tonkeeper.com - VITE_APP_LOCALES: en,zh_TW,zh_CN,id,ru,it,es,uk,tr,bg,uz,bn - VITE_APP_TONCONSOLE_HOST: https://pro.tonconsole.com - VITE_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }} - VITE_APP_STONFI_REFERRAL_ADDRESS: ${{ secrets.REACT_APP_STONFI_REFERRAL_ADDRESS }} - with: - cmd: build:web - - - name: Publish to Cloudflare Pages - id: deploy - if: contains(github.ref, 'main') || inputs.environment == 'dev' - uses: cloudflare/wrangler-action@v3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: - pages deploy apps/web/dist --project-name=tonkeeper-web --branch=${{ - inputs.environment }} + web-tests: + needs: web-deploy + uses: ./.github/workflows/web-tests.yaml + with: + base-url: ${{ needs.web-deploy.outputs.deployment-url }} + secrets: inherit diff --git a/.github/workflows/playwright.yaml b/.github/workflows/playwright.yaml index fef95fd5b..b1a181760 100644 --- a/.github/workflows/playwright.yaml +++ b/.github/workflows/playwright.yaml @@ -1,45 +1,15 @@ -name: Tonkeeper Playwright +name: Tonkeeper Web Playwright on: workflow_dispatch: + inputs: + base-url: + type: string + description: App Url + default: https://wallet.tonkeeper.com jobs: - playwright-tests: - name: playwright-tests - timeout-minutes: 60 - runs-on: ubuntu-latest - - steps: - - name: Checkout to git repository - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: lts/* - - - name: Enable Corepack - run: | - corepack enable - - - name: Run install - uses: borales/actions-yarn@v5 - with: - cmd: install - - - name: Install Playwright Browsers - working-directory: ./tests/playwright - run: npx playwright install --with-deps chromium - - - name: Run Playwright tests - working-directory: ./tests/playwright - env: - BASE_APP_URL: https://wallet.tonkeeper.com - TON_MNEMONIC_24: ${{ secrets.TON_MNEMONIC_24 }} - TON_MNEMONIC_24_2: ${{ secrets.TON_MNEMONIC_24_2 }} - TON_MNEMONIC_24_3: ${{ secrets.TON_MNEMONIC_24_3 }} - TON_MNEMONIC_24_4: ${{ secrets.TON_MNEMONIC_24_4 }} - TON_MNEMONIC_24_5: ${{ secrets.TON_MNEMONIC_24_5 }} - TON_MNEMONIC_ANANAS: ${{ secrets.TON_MNEMONIC_ANANAS }} - TON_MNEMONIC_12: ${{ secrets.TON_MNEMONIC_12 }} - TON_MNEMONIC_12_2: ${{ secrets.TON_MNEMONIC_12_2 }} - FAKE_MNEMONIC: ${{ secrets.FAKE_MNEMONIC }} - run: npx playwright test --project='chromium' + web-tests: + uses: ./.github/workflows/web-tests.yaml + with: + base-url: ${{ inputs.base-url }} + transaction: true + secrets: inherit diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index b9a413853..9bfff0516 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -121,68 +121,10 @@ jobs: rm ${{ github.workspace }}/AuthKey.p8 web-build: - name: web-build - runs-on: ubuntu-latest - timeout-minutes: 10 - - outputs: - deployment-url: ${{ steps.deploy.outputs.deployment-url }} - steps: - - name: Checkout to git repository - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node-version }} - - - name: Enable Corepack - run: | - corepack enable - - - name: Run install - uses: borales/actions-yarn@v5 - with: - cmd: install - - - name: Run build - uses: borales/actions-yarn@v5 - env: - VITE_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE_EXTENSION }} - VITE_APP_MEASUREMENT_ID: ${{ secrets.REACT_APP_MEASUREMENT_ID }} - VITE_APP_APTABASE: ${{ secrets.VITE_APP_APTABASE }} - VITE_APP_APTABASE_HOST: https://anonymous-analytics.tonkeeper.com - VITE_APP_LOCALES: en,zh_TW,zh_CN,id,ru,it,es,uk,tr,bg,uz,bn - VITE_APP_TONCONSOLE_HOST: https://pro.tonconsole.com - VITE_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }} - VITE_APP_STONFI_REFERRAL_ADDRESS: ${{ secrets.REACT_APP_STONFI_REFERRAL_ADDRESS }} - with: - cmd: build:web - - - name: Publish to Cloudflare Pages - id: deploy - uses: cloudflare/wrangler-action@v3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy apps/web/dist --project-name=tonkeeper-web - - - name: Summary - run: | - echo '### Successful WEB deployment 🚀🚀🚀' >> $GITHUB_STEP_SUMMARY - echo 'Well done!' >> $GITHUB_STEP_SUMMARY - echo 'Link to test environment:' >> $GITHUB_STEP_SUMMARY - echo '${{ steps.deploy.outputs.deployment-url }}' >> $GITHUB_STEP_SUMMARY - - - name: Comment PR - uses: thollander/actions-comment-pull-request@v3 - with: - message: | - ### Successful WEB deployment 🚀🚀🚀 - Well done! - Link to test environment: - ${{ steps.deploy.outputs.deployment-url }} - comment-tag: web_deploy + uses: ./.github/workflows/web-build.yaml + with: + environment: ${{ github.head_ref }} + secrets: inherit twa-build: name: twa-build @@ -293,51 +235,9 @@ jobs: path: | ${{ github.workspace }}/apps/extension/dist/firefox - playwright-tests: - name: playwright-tests - runs-on: ubuntu-latest - timeout-minutes: 20 + web-tests: needs: web-build - - steps: - - name: Checkout to git repository - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: lts/* - - - name: Enable Corepack - run: | - corepack enable - - - name: Run install - uses: borales/actions-yarn@v5 - with: - cmd: install - - - name: Install Playwright Browsers - working-directory: ./tests/playwright - run: npx playwright install --with-deps chromium - - - name: Run Playwright tests - working-directory: ./tests/playwright - env: - BASE_APP_URL: ${{ needs.web-build.outputs.deployment-url }} - TON_MNEMONIC_24: ${{ secrets.TON_MNEMONIC_24 }} - TON_MNEMONIC_24_2: ${{ secrets.TON_MNEMONIC_24_2 }} - TON_MNEMONIC_24_3: ${{ secrets.TON_MNEMONIC_24_3 }} - TON_MNEMONIC_24_4: ${{ secrets.TON_MNEMONIC_24_4 }} - TON_MNEMONIC_24_5: ${{ secrets.TON_MNEMONIC_24_5 }} - TON_MNEMONIC_ANANAS: ${{ secrets.TON_MNEMONIC_ANANAS }} - TON_MNEMONIC_12: ${{ secrets.TON_MNEMONIC_12 }} - TON_MNEMONIC_12_2: ${{ secrets.TON_MNEMONIC_12_2 }} - FAKE_MNEMONIC: ${{ secrets.FAKE_MNEMONIC }} - run: npx playwright test --project='chromium' - - - name: Comment Playwright report - uses: daun/playwright-report-summary@v3 - if: always() - with: - report-file: ./tests/playwright/results.json + uses: ./.github/workflows/web-tests.yaml + with: + base-url: ${{ needs.web-build.outputs.deployment-url }} + secrets: inherit diff --git a/.github/workflows/web-build.yaml b/.github/workflows/web-build.yaml new file mode 100644 index 000000000..f9943cbcf --- /dev/null +++ b/.github/workflows/web-build.yaml @@ -0,0 +1,96 @@ +name: Tonkeeper Web Build +on: + workflow_call: + inputs: + environment: + required: true + type: string + secrets: + REACT_APP_AMPLITUDE_EXTENSION: + required: true + REACT_APP_MEASUREMENT_ID: + required: true + VITE_APP_APTABASE: + required: true + REACT_APP_TG_BOT_ID: + required: true + REACT_APP_STONFI_REFERRAL_ADDRESS: + required: true + CLOUDFLARE_API_TOKEN: + required: true + CLOUDFLARE_ACCOUNT_ID: + required: true + outputs: + deployment-url: + description: 'The app deployment url' + value: ${{ jobs.web-build.outputs.deployment-url }} +env: + node-version: 20.11.1 + +jobs: + web-build: + name: web-build + runs-on: ubuntu-latest + timeout-minutes: 10 + + outputs: + deployment-url: ${{ steps.deploy.outputs.deployment-url }} + steps: + - name: Checkout to git repository + uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.node-version }} + + - name: Enable Corepack + run: | + corepack enable + + - name: Run install + uses: borales/actions-yarn@v5 + with: + cmd: install + + - name: Run build + uses: borales/actions-yarn@v5 + env: + VITE_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE_EXTENSION }} + VITE_APP_MEASUREMENT_ID: ${{ secrets.REACT_APP_MEASUREMENT_ID }} + VITE_APP_APTABASE: ${{ secrets.VITE_APP_APTABASE }} + VITE_APP_APTABASE_HOST: https://anonymous-analytics.tonkeeper.com + VITE_APP_LOCALES: en,zh_TW,zh_CN,id,ru,it,es,uk,tr,bg,uz,bn + VITE_APP_TONCONSOLE_HOST: https://pro.tonconsole.com + VITE_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }} + VITE_APP_STONFI_REFERRAL_ADDRESS: ${{ secrets.REACT_APP_STONFI_REFERRAL_ADDRESS }} + with: + cmd: build:web + + - name: Publish to Cloudflare Pages + id: deploy + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: + pages deploy apps/web/dist --project-name=tonkeeper-web --branch=${{ + inputs.environment }} + + - name: Summary + run: | + echo '### Successful WEB deployment 🚀🚀🚀' >> $GITHUB_STEP_SUMMARY + echo 'Well done!' >> $GITHUB_STEP_SUMMARY + echo 'Link to test environment:' >> $GITHUB_STEP_SUMMARY + echo '${{ steps.deploy.outputs.deployment-url }}' >> $GITHUB_STEP_SUMMARY + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v3 + if: github.event_name == 'pull_request' + with: + message: | + ### Successful WEB deployment 🚀🚀🚀 + Well done! + Link to test environment: + ${{ steps.deploy.outputs.deployment-url }} + comment-tag: web_deploy diff --git a/.github/workflows/web-tests.yaml b/.github/workflows/web-tests.yaml new file mode 100644 index 000000000..f92918390 --- /dev/null +++ b/.github/workflows/web-tests.yaml @@ -0,0 +1,81 @@ +name: Tonkeeper Web Tests +on: + workflow_call: + inputs: + base-url: + required: true + type: string + transaction: + type: boolean + default: false + secrets: + TON_MNEMONIC_24: + required: true + TON_MNEMONIC_24_2: + required: true + TON_MNEMONIC_24_3: + required: true + TON_MNEMONIC_24_4: + required: true + TON_MNEMONIC_24_5: + required: true + TON_MNEMONIC_ANANAS: + required: true + TON_MNEMONIC_12: + required: true + TON_MNEMONIC_12_2: + required: true + FAKE_MNEMONIC: + required: true + +env: + node-version: lts/* +jobs: + playwright-tests: + name: playwright-tests + timeout-minutes: 20 + runs-on: ubuntu-latest + + steps: + - name: Checkout to git repository + uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.node-version }} + + - name: Enable Corepack + run: | + corepack enable + + - name: Run install + uses: borales/actions-yarn@v5 + with: + cmd: install + + - name: Install Playwright Browsers + working-directory: ./tests/playwright + run: npx playwright install --with-deps chromium + + - name: Run Playwright tests + working-directory: ./tests/playwright + env: + BASE_APP_URL: ${{ inputs.base-url }} + TRANSACTION_TESTS: ${{ inputs.transaction }} + TON_MNEMONIC_24: ${{ secrets.TON_MNEMONIC_24 }} + TON_MNEMONIC_24_2: ${{ secrets.TON_MNEMONIC_24_2 }} + TON_MNEMONIC_24_3: ${{ secrets.TON_MNEMONIC_24_3 }} + TON_MNEMONIC_24_4: ${{ secrets.TON_MNEMONIC_24_4 }} + TON_MNEMONIC_24_5: ${{ secrets.TON_MNEMONIC_24_5 }} + TON_MNEMONIC_ANANAS: ${{ secrets.TON_MNEMONIC_ANANAS }} + TON_MNEMONIC_12: ${{ secrets.TON_MNEMONIC_12 }} + TON_MNEMONIC_12_2: ${{ secrets.TON_MNEMONIC_12_2 }} + FAKE_MNEMONIC: ${{ secrets.FAKE_MNEMONIC }} + run: npx playwright test --project='chromium' + + - name: Comment Playwright report + uses: daun/playwright-report-summary@v3 + if: always() && github.event_name == 'pull_request' + with: + report-file: ./tests/playwright/results.json diff --git a/tests/playwright/.env.example b/tests/playwright/.env.example index 77060da48..8a6c433d0 100644 --- a/tests/playwright/.env.example +++ b/tests/playwright/.env.example @@ -1,4 +1,5 @@ BASE_APP_URL='https://wallet.tonkeeper.com' +TRANSACTION_TESTS=true TON_MNEMONIC_24='' TON_MNEMONIC_24_2='' TON_MNEMONIC_24_3='' diff --git a/tests/playwright/playwright.config.ts b/tests/playwright/playwright.config.ts index 1b1add72d..105d7b604 100644 --- a/tests/playwright/playwright.config.ts +++ b/tests/playwright/playwright.config.ts @@ -13,6 +13,8 @@ dotenv.config({ path: path.resolve(__dirname, '.env') }); */ export default defineConfig({ testDir: './tests', + testIgnore: process.env.TRANSACTION_TESTS != 'true' ? '**/Transactions/**' : undefined, + /* Run tests in files in parallel */ fullyParallel: !process.env.CI, /* Fail the build on CI if you accidentally left test.only in the source code. */ 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/NegativeCases/Negative.spec.ts b/tests/playwright/tests/NegativeCases/Negative.spec.ts index 652cf5652..705931768 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.'); @@ -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(); diff --git a/tests/playwright/tests/Ton Connect.spec.ts b/tests/playwright/tests/Ton Connect.spec.ts index e41ea3b32..d08f91b10 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(); - 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') @@ -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'); }); 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();