Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,25 @@ jobs:

echo "🚀 TON Connect Bridge service is now running and accessible at http://localhost:8081/bridge"
# uses: ton-connect/bridge/actions/local@master
- name: Run extension e2e specs

- name: Run web e2e specs
run: xvfb-run pnpm --filter demo-wallet e2e
env:
WALLET_MNEMONIC: ${{ secrets.WALLET_MNEMONIC }}
E2E_WALLET_SOURCE_EXTENSION: "${{ github.workspace }}/apps/demo-wallet/dist-extension"
E2E_JS_BRIDGE: true
VITE_BRIDGE_URL: 'http://localhost:8081/bridge'
ALLURE_BASE_URL: ${{ secrets.ALLURE_BASE_URL }}
ALLURE_API_TOKEN: ${{ secrets.ALLURE_API_TOKEN }}
ALLURE_PROJECT_ID: ${{ secrets.ALLURE_PROJECT_ID }}

- name: Run web e2e specs
- name: Run extension e2e specs
run: xvfb-run pnpm --filter demo-wallet e2e
env:
WALLET_MNEMONIC: ${{ secrets.WALLET_MNEMONIC }}
VITE_BRIDGE_URL: 'http://localhost:8081/bridge'
E2E_WALLET_SOURCE_EXTENSION: "${{ github.workspace }}/apps/demo-wallet/dist-extension"
E2E_JS_BRIDGE: true
ALLURE_BASE_URL: ${{ secrets.ALLURE_BASE_URL }}
ALLURE_API_TOKEN: ${{ secrets.ALLURE_API_TOKEN }}
ALLURE_PROJECT_ID: ${{ secrets.ALLURE_PROJECT_ID }}

- name: Send report
if: always()
Expand All @@ -97,4 +103,4 @@ jobs:
env:
ALLURE_BASE_URL: ${{ secrets.ALLURE_BASE_URL }}
ALLURE_API_TOKEN: ${{ secrets.ALLURE_API_TOKEN }}
ALLURE_PROJECT_ID: ${{ secrets.ALLURE_PROJECT_ID }}
ALLURE_PROJECT_ID: ${{ secrets.ALLURE_PROJECT_ID }}
17 changes: 16 additions & 1 deletion apps/demo-wallet/e2e.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'dotenv/config';
import { config } from 'dotenv';
import { defineConfig, devices } from '@playwright/test';

// Загружаем переменные окружения из .env файла
config();

export default defineConfig({
testDir: './e2e',
timeout: 120_000,
Expand All @@ -12,6 +15,18 @@ export default defineConfig({
screenshot: 'on',
trace: 'on',
permissions: ['clipboard-read', 'clipboard-write'],
launchOptions: {
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--no-first-run',
'--disable-infobars',
'--disable-blink-features=AutomationControlled',
'--use-fake-ui-for-media-stream',
'--disable-permissions-api',
],
},
},
projects: process.env.E2E_WALLET_SOURCE_EXTENSION
? [
Expand Down
76 changes: 22 additions & 54 deletions apps/demo-wallet/e2e/connect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,51 @@
//import * as allure from 'allure-js-commons';

import { expect } from '@playwright/test';
import { allure } from 'allure-playwright';
import { config } from 'dotenv';
import type { TestInfo } from '@playwright/test';
import { expect } from '@playwright/test';
import { allureId, owner } from 'allure-js-commons';

import { testWithDemoWalletFixture } from './demo-wallet';
import { AllureApiClient, createAllureConfig, getTestCaseData, extractAllureId } from './utils';
import type { TestFixture } from './qa';
import { AllureApiClient, createAllureConfig, getTestCaseData, extractAllureId } from './utils';
config();

// const feature = {
// jsBridge: Boolean(process.env.E2E_JS_BRIDGE),
// };
const test = testWithDemoWalletFixture({
appUrl: process.env.DAPP_URL ?? 'https://allure-test-runner.vercel.app/e2e',
});
//const { expect } = test;

// const test = testWith(
// demoWalletFixture({
// extensionPath: 'dist-extension',
// mnemonic:
// process.env.WALLET_MNEMONIC ||
// 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
// appUrl: process.env.DAPP_URL || 'https://allure-test-runner.vercel.app/e2e '
// }, 0),
// );

let allureClient: AllureApiClient;

test.beforeAll(async () => {
try {
const config = createAllureConfig();
allureClient = new AllureApiClient(config);
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error creating allure client:', error);
throw error;
}
const config = createAllureConfig();
allureClient = new AllureApiClient(config);
});

async function runConnectTest(
{ wallet, app, widget }: Pick<TestFixture, 'wallet' | 'app' | 'widget'>,
testInfo: TestInfo,
) {
const allureId = extractAllureId(testInfo.title);
if (allureId) {
await allure.allureId(allureId);
await allure.owner('e.kurilenko');
const testAllureId = extractAllureId(testInfo.title);
if (testAllureId) {
await allureId(testAllureId);
await owner('e.kurilenko');
}

let precondition: string = '';
let expectedResult: string = '';

if (allureId && allureClient) {
try {
const testCaseData = await getTestCaseData(allureClient, allureId);
precondition = testCaseData.precondition;
expectedResult = testCaseData.expectedResult;
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error getting test case data:', error);
}
} else {
// eslint-disable-next-line no-console
console.warn('AllureId not found in test title or client not available');
if (testAllureId && allureClient) {
const testCaseData = await getTestCaseData(allureClient, testAllureId);
precondition = testCaseData.precondition;
expectedResult = testCaseData.expectedResult;
}

await app.getByTestId('connectPrecondition').fill(precondition || '');
await app.getByTestId('connectExpectedResult').fill(expectedResult);
await expect(app.getByTestId('connect-button')).toHaveText('Connect Wallet');

await app.getByTestId('connect-button').click();

await widget.connectUrlButton.waitFor({ state: 'visible' });
await widget.connectUrlButton.click();

await wallet.connectBy(await widget.connectUrl());

//await wallet.connect(true, await handle.jsonValue());

//await wallet.connect();

await expect(app.getByTestId('connectValidation')).toHaveText('Validation Passed');
await wallet.connectBy(await widget.connectUrl(await app.getByTestId('connect-button')));
await app.getByTestId('connectValidation').waitFor({ state: 'visible' });
await expect(app.getByTestId('connectValidation')).toHaveText('Validation Passed', { timeout: 1 });
}

test('Connect @allureId(1933)', async ({ wallet, app, widget }) => {
Expand Down
8 changes: 8 additions & 0 deletions apps/demo-wallet/e2e/demo-wallet/DemoWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class DemoWallet extends WalletApp {
await app.getByTestId('auto-lock').click();
await app.getByTestId('hold-to-sign').waitFor({ state: 'attached' });
await app.getByTestId('hold-to-sign').click();
await app.getByTestId('network-select').selectOption('mainnet');
await this.close();
}

Expand Down Expand Up @@ -65,6 +66,13 @@ export class DemoWallet extends WalletApp {
await this.close();
}

async sendTransaction(isPositiveCase: boolean, confirm: boolean): Promise<void> {
await this.open();
if (isPositiveCase) {
await this.accept(confirm);
}
}

async accept(confirm: boolean = true): Promise<void> {
const app = await this.open();
const modal = app.getByTestId('request').filter({ hasText: 'Transaction Request' });
Expand Down
1 change: 1 addition & 0 deletions apps/demo-wallet/e2e/demo-wallet/demoWalletFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function demoWalletFixture(config: ConfigFixture, slowMo = 0) {
const walletSource = config.walletSource ?? detectWalletSource();
const isExtension = isExtensionWalletSource(walletSource);
const mnemonic = config.mnemonic ?? process.env.WALLET_MNEMONIC;

return test.extend<TestFixture>({
context: async ({ context: _ }, use) => {
const extensionPath = isExtension ? walletSource : '';
Expand Down
29 changes: 24 additions & 5 deletions apps/demo-wallet/e2e/qa/TonConnectWidget.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page } from '@playwright/test';
import { type Page, type Locator } from '@playwright/test';

interface TonConnectSelector {
title: string;
Expand Down Expand Up @@ -57,15 +57,27 @@ export class TonConnectWidget {
return this.page.getByRole('button', { name }).click();
}

async copyConnectUrl() {
await this.connectUrlButton.waitFor({ state: 'visible' });
await this.connectUrlButton.click();
const handle = await this.page.evaluateHandle(() => navigator.clipboard.readText());
return await handle.jsonValue();
}

async connectWallet(name: string) {
await this.connect();
await this.clickButton(name);
await this.clickButton('Browser Extension');
}

async connect() {
await this.connectButton.waitFor({ state: 'visible' });
await this.connectButton.click();
async connect(buttonToClick?: Locator) {
if (buttonToClick) {
await buttonToClick.waitFor({ state: 'visible' });
await buttonToClick.click();
} else {
await this.connectButton.waitFor({ state: 'visible' });
await this.connectButton.click();
}
await this.title.waitFor({ state: 'visible' });
}

Expand All @@ -75,7 +87,14 @@ export class TonConnectWidget {
await this.connectDropdown.locator('li:nth-child(2) > button').click();
}

async connectUrl() {
async connectUrl(buttonToClick?: Locator) {
await this.connect(buttonToClick);
await this.connectUrlButton.waitFor({ state: 'visible' });
await this.connectUrlButton.click();
const handle = await this.page.evaluateHandle(() => navigator.clipboard.readText());
return await handle.jsonValue();
}
async connectUrlTest() {
await this.connect();
await this.connectUrlButton.waitFor({ state: 'visible' });
await this.connectUrlButton.click();
Expand Down
4 changes: 2 additions & 2 deletions apps/demo-wallet/e2e/qa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export interface ConfigFixture {
mnemonic?: string;
}

import { WalletApp } from './WalletApp';
import { TonConnectWidget } from './TonConnectWidget';
import { DemoWallet } from '../demo-wallet';

export type TestFixture = {
context: BrowserContext;
wallet: WalletApp;
wallet: DemoWallet;
widget: TonConnectWidget;
app: Page;
};
14 changes: 12 additions & 2 deletions apps/demo-wallet/e2e/qa/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ import { chromium, type Fixtures, type TestType } from '@playwright/test';
import { mergeTests, test as base } from '@playwright/test';

export function launchPersistentContext(extensionPath: string, slowMo = 0) {
const args = [];
const args = [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--no-first-run',
'--disable-infobars',
'--disable-blink-features=AutomationControlled',
'--use-fake-ui-for-media-stream',
'--disable-permissions-api',
];

if (extensionPath != '') {
args.push(`--disable-extensions-except=${extensionPath}`);
args.push(`--load-extension=${extensionPath}`);
}
if (process.env.CI) {
args.push('--headless=new');
}
slowMo = process.env.CI ? 0 : (parseInt(process.env.E2E_SLOW_MO) ?? slowMo);
slowMo = process.env.CI ? 0 : (parseInt(process.env.E2E_SLOW_MO || '0') ?? slowMo);
return chromium.launchPersistentContext('', {
args,
headless: false,
Expand Down
Loading
Loading