Skip to content
Closed
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
5 changes: 2 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Start TON Connect Bridge
run: |
echo "Starting TON Connect Bridge service with docker-compose.memory.yml..."
echo "Starting TON Connect Bridge service with docker-compose.bridge.yml..."
docker compose -f docker-compose.bridge.yml up -d
echo "Waiting for services to be ready..."
sleep 2
Expand Down Expand Up @@ -69,7 +69,6 @@ jobs:
fi

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

- name: Run e2e specs
run: xvfb-run pnpm --filter demo-wallet e2e
Expand All @@ -89,4 +88,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 }}
91 changes: 91 additions & 0 deletions apps/demo-wallet/e2e/connect.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { expect } from '@playwright/test';
import { allure } from 'allure-playwright';

import { testWith } from './qa';
import { demoWalletFixture } from './demo-wallet';
import { AllureApiClient, createAllureConfig, getTestCaseData, extractAllureId } from './utils';

const test = testWith(
demoWalletFixture({

Check failure on line 9 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Insert `⏎········`
extensionPath: 'dist-extension',

Check failure on line 10 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Insert `····`
mnemonic:

Check failure on line 11 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Insert `····`
process.env.WALLET_MNEMONIC ||

Check failure on line 12 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Insert `····`
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',

Check failure on line 13 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Insert `····`
appUrl: process.env.DAPP_URL || 'https://allure-test-runner.vercel.app/e2e '

Check failure on line 14 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Missing trailing comma

Check failure on line 14 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Replace `········appUrl:·process.env.DAPP_URL·||·'https://allure-test-runner.vercel.app/e2e·'` with `············appUrl:·process.env.DAPP_URL·||·'https://allure-test-runner.vercel.app/e2e·',`
}, 0),

Check failure on line 15 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Replace `····},·0` with `········},⏎········0,⏎····`
);

let allureClient: AllureApiClient;

test.beforeAll(async () => {
try {
// Создаем конфигурацию Allure
const config = createAllureConfig();

// Создаем клиент Allure
allureClient = new AllureApiClient(config);
} catch (error) {
console.error('Error creating allure client:', error);

Check warning on line 28 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected console statement
throw error;
}
});

async function runConnectTest({ wallet, app, widget }: { wallet: any; app: any; widget: any }, testInfo: any) {

Check failure on line 33 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected any. Specify a different type

Check failure on line 33 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected any. Specify a different type
// Извлекаем allureId из названия теста
const allureId = extractAllureId(testInfo.title);

// Устанавливаем Allure аннотации
if (allureId) {
await allure.allureId(allureId);
await allure.owner('e.kurilenko');
}

// Инициализируем переменные для данных тест-кейса
let precondition: string = '';
let expectedResult: string = '';
let isPositiveCase: boolean = true;

if (allureId && allureClient) {
try {
const testCaseData = await getTestCaseData(allureClient, allureId);
precondition = testCaseData.precondition;
expectedResult = testCaseData.expectedResult;
isPositiveCase = testCaseData.isPositiveCase;

Check warning on line 53 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

'isPositiveCase' is assigned a value but never used. Allowed unused vars must match /^_/u
} catch (error) {
console.error('Error getting test case data:', error);

Check warning on line 55 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected console statement
}
} else {
console.warn('AllureId not found in test title or client not available');

Check warning on line 58 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected console statement
}

await app.getByTestId('connectPrecondition').fill(precondition||'');
await app.getByTestId('connectExpectedResult').fill(expectedResult);

await expect(app.getByTestId('connect-button')).toHaveText('Connect Wallet');
//await app.locator('#connect-button').click();
await app.getByTestId('connect-button').click();

await widget.connectUrlButton.waitFor({ state: 'visible' });
await widget.connectUrlButton.click();
const handle = await widget.page.evaluateHandle(() => navigator.clipboard.readText());
console.log(handle);

Check warning on line 71 in apps/demo-wallet/e2e/connect.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected console statement
//return await handle.jsonValue();

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

//await wallet.connect();

await expect(app.getByTestId('connectValidation')).toHaveText('Validation Passed');
}

test('Connect @allureId(1933)', async ({ wallet, app, widget }) => {
await runConnectTest({ wallet, app, widget }, test.info());
});

test('Connect @allureId(1900)', async ({ wallet, app, widget }) => {
await runConnectTest({ wallet, app, widget }, test.info());
});

test('Connect @allureId(1902)', async ({ wallet, app, widget }) => {
await runConnectTest({ wallet, app, widget }, test.info());
});
20 changes: 13 additions & 7 deletions apps/demo-wallet/e2e/demo-wallet/DemoWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,19 @@ export class DemoWallet extends WalletExtension {
await app.locator(testSelector('tonconnect-url')).fill(url);
await app.locator(testSelector('tonconnect-process')).click();
await app.locator(testSelector('request'), { hasText: 'Connect Request' }).waitFor({ state: 'visible' });
await app.locator(testSelector('connect')).waitFor({ state: 'attached', timeout: 10_000 });
await app.locator(testSelector('connect')).click();
await app.locator(testSelector('connect-approve')).waitFor({ state: 'attached', timeout: 10_000 });
await app.locator(testSelector('connect-approve')).click();
await app.locator(testSelector('request')).waitFor({ state: 'detached', timeout: 10_000 });
await app.close();
}

async connect(confirm: boolean = true, url: string = ''): Promise<void> {
const app = await this.open();
await app.locator(testSelector('tonconnect-url')).fill(url);
await app.locator(testSelector('tonconnect-process')).click();
await app.locator(testSelector('request'), { hasText: 'Connect Request' }).waitFor({ state: 'visible' });
await app.locator(testSelector('connect-approve')).waitFor({ state: 'attached', timeout: 10_000 });
await app.locator(testSelector(confirm? 'connect-approve':'connect-reject')).click();
await app.locator(testSelector('request')).waitFor({ state: 'detached', timeout: 10_000 });
await app.close();
}
Expand All @@ -62,11 +73,6 @@ export class DemoWallet extends WalletExtension {
await app.close();
}

async connect(_confirm?: boolean): Promise<void> {
// TODO implement DemoWallet connect
throw new Error('DemoWallet connect not implemented');
}

async accept(_confirm: boolean = true): Promise<void> {
// TODO implement DemoWallet accept
throw new Error('DemoWallet accept not implemented');
Expand Down
234 changes: 234 additions & 0 deletions apps/demo-wallet/e2e/sendTransaction.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
import { expect } from '@playwright/test';
import { AllureApiClient, createAllureConfig, getTestCaseData, extractAllureId } from './utils';
import { config } from 'dotenv';

Check warning on line 3 in apps/demo-wallet/e2e/sendTransaction.spec.ts

View workflow job for this annotation

GitHub Actions / unit

'config' is defined but never used. Allowed unused vars must match /^_/u
import { resolve, dirname } from 'path';

Check warning on line 4 in apps/demo-wallet/e2e/sendTransaction.spec.ts

View workflow job for this annotation

GitHub Actions / unit

'dirname' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 4 in apps/demo-wallet/e2e/sendTransaction.spec.ts

View workflow job for this annotation

GitHub Actions / unit

'resolve' is defined but never used. Allowed unused vars must match /^_/u
import { fileURLToPath } from 'url';

Check warning on line 5 in apps/demo-wallet/e2e/sendTransaction.spec.ts

View workflow job for this annotation

GitHub Actions / unit

'fileURLToPath' is defined but never used. Allowed unused vars must match /^_/u
import { allure } from 'allure-playwright';
import { testWith } from './qa';
import { demoWalletFixture } from './demo-wallet';

// Создаем тест с использованием demoWalletFixture
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'
}),
);
// Global variable for storing the Allure client
let allureClient: AllureApiClient;

// Function for extracting allureId from the test title

// universal function for executing SendTransaction test
async function runSendTransactionTest(
{ wallet, app, widget }: { wallet: any; app: any; widget: any },
testInfo: any
) {
const allureId = extractAllureId(testInfo.title);

if (allureId) {
await allure.allureId(allureId);
await allure.owner('e.kurilenko');
}

// Инициализируем переменные для данных тест-кейса
let precondition: string = "";
let expectedResult: string = "";
let isPositiveCase: boolean = true;

if (allureId && allureClient) {
try {
const testCaseData = await getTestCaseData(allureClient, allureId);
precondition = testCaseData.precondition;
expectedResult = testCaseData.expectedResult;
isPositiveCase = testCaseData.isPositiveCase;
} catch (error) {
console.error('Error getting test case data:', error);

Check warning on line 47 in apps/demo-wallet/e2e/sendTransaction.spec.ts

View workflow job for this annotation

GitHub Actions / unit

Unexpected console statement
}
} else {
console.warn('AllureId not found in test title or client not available');
}

await expect(widget.connectButtonText).toHaveText('Connect Wallet');
await wallet.connectBy(await widget.connectUrl());
await expect(widget.connectButtonText).toHaveText('UQC8…t2Iv');

await app.locator('#sendTxPrecondition').fill(precondition);
await app.locator('#sendTxExpectedResult').fill(expectedResult);
await app.locator('#send-transaction-button').click();
//await app.getByRole('button', {name: 'Send Transaction'}).click();

await wallet.sendTransaction(true, isPositiveCase);

await expect(app.getByTestId('sendTransactionValidation')).toHaveText('Validation Passed');
}

test.beforeAll(async () => {
try {
// Создаем конфигурацию Allure
const config = createAllureConfig();

// Создаем клиент Allure
allureClient = new AllureApiClient(config);

} catch (error) {
console.error('Error creating allure client:', error);
throw error;
}
});

// SendTransaction validation tests
test('[address] Error if absent @allureId(1847)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[address] Error if in HEX format @allureId(1870)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[address] Error if invalid value @allureId(1856)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[address] Success if in bounceable format @allureId(1852)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[address] Success if in non-bounceable format @allureId(1853)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[amount] Error if absent @allureId(1873)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[amount] Error if as a number @allureId(1857)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[amount] Error if insufficient balance @allureId(1871)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[amount] Success if \'0\' @allureId(1980)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[amount] Success if as a string @allureId(1849)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[from] Error if address doesn\'t match the user\'s wallet address @allureId(1877)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[from] Error if invalid value @allureId(1848)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[from] Success if in bounceable format @allureId(1878)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[from] Success if in HEX format @allureId(1855)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[from] Success if in non-bounceable format @allureId(1862)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[messages] Error if array is empty @allureId(1864)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[messages] Error if contains invalid message @allureId(1869)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[messages] Success if contains maximum messages @allureId(1959)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[network] Error if \'-3\' (testnet) @allureId(1876)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[network] Error if as a number @allureId(1860)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[network] Success if \'-239\' (mainnet) @allureId(1875)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[payload] Error if invalid value @allureId(1872)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[payload] Success if absent @allureId(1854)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[payload] Success if valid value @allureId(1879)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[stateInit] Error if invalid value @allureId(1874)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[stateInit] Success if absent @allureId(1859)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[stateInit] Success if valid value @allureId(1850)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Success if absent @allureId(1866)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Error if as a string @allureId(1865)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Error if expired @allureId(1861)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Error if has expired during confirmation @allureId(1863)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Error if NaN @allureId(1867)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Error if NULL @allureId(1868)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Success if less then in 5 minutes @allureId(1851)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('[validUntil] Success if more then in 5 minutes @allureId(1858)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

// Merkle proof/update tests
test('Send merkle proof @allureId(1916)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

test('Send merkle update @allureId(1917)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});

// Jetton minting tests
test('Minting Jetton with Deployed Contract @allureId(1899)', async ({ wallet, app, widget }) => {
await runSendTransactionTest({ wallet, app, widget }, test.info());
});
Loading