Skip to content

Commit ce235af

Browse files
committed
feat: add tonkeeper
1 parent e17b5ad commit ce235af

24 files changed

+6060
-2774
lines changed

.github/workflows/test.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: test
22

33
on:
44
push:
5+
pull_request:
6+
branches:
7+
- main
58

69
jobs:
710
test:
@@ -11,10 +14,12 @@ jobs:
1114
- uses: actions/setup-node@v4
1215
with:
1316
node-version: 22
14-
- run: npm ci
15-
- run: npm run lint
17+
cache: 'pnpm'
18+
cache-dependency-path: '**/pnpm-lock.yaml'
19+
- run: pnpm install
20+
- run: pnpm lint
1621
- run: npx playwright install --with-deps
17-
- run: npm test
22+
- run: pnpm test
1823
- uses: actions/upload-artifact@v4
1924
if: always()
2025
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
.vscode
33
.idea
4+
.cache*
45

56
# npm
67
node_modules
@@ -10,6 +11,7 @@ npm-debug.log
1011
.env
1112

1213
# tests
14+
extension
1315
test-results
1416
playwright-report
1517
qa-report

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22

README.md

Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,113 @@
1-
# ton-connect-qa
1+
# TON-Connect QA
2+
3+
This guide provides a quick setup process for Playwright to automate tests for TON Dapps, note that this is a basic configuration
4+
5+
## Prerequisites
6+
7+
- Node.js v18+
8+
- Playwright and TypeScript knowledge
9+
10+
## Installation
11+
12+
1. Install Playwright and its dependencies:
13+
14+
```bash
15+
npm init playwright@latest
16+
```
17+
18+
Follow the prompts to complete the installation
19+
20+
21+
2. Install dev dependency:
22+
23+
```bash
24+
npm install --save-dev @tonconnect/qa
25+
```
26+
27+
## Setup
28+
29+
1. Create or update your Playwright configuration file (e.g., `playwright.config.ts`):
30+
31+
```typescript
32+
import 'dotenv/config'
33+
import { defineConfig, devices } from '@playwright/test'
34+
35+
// Define Playwright configuration
36+
export default defineConfig({
37+
testDir: './test',
38+
fullyParallel: true,
39+
forbidOnly: !!process.env.CI,
40+
retries: process.env.CI ? 2 : 0,
41+
workers: process.env.CI ? 1 : undefined,
42+
reporter: 'html',
43+
use: {
44+
// Set base URL for tests
45+
baseURL: 'http://localhost:3000',
46+
trace: 'on-first-retry',
47+
},
48+
projects: [
49+
{
50+
name: 'chromium',
51+
use: { ...devices['Desktop Chrome'] },
52+
},
53+
],
54+
})
55+
```
56+
57+
2. Create a test file (e.g., `tests/example.spec.ts`):
58+
59+
```typescript
60+
// Import necessary modules and setup
61+
import { TonConnectWidget, testWith, tonkeeperFixture } from '../qa'
62+
63+
// Create a test instance Tonkeeper fixtures
64+
const test = testWith(tonkeeperFixture(process.env.WALLET_MNEMONIC!))
65+
66+
// Extract expect function from test
67+
const { expect } = test
68+
69+
// Define a basic test case
70+
test('lab', async ({ context, wallet }) => {
71+
// Navigate to the homepage
72+
const app = await context.newPage()
73+
await app.goto('https://ton-connect.github.io/demo-dapp-with-react-ui/')
74+
75+
// Click the connect button
76+
const connectButton = app.getByRole('button', { name: 'Connect wallet to send the transaction' })
77+
78+
// Connect Tonkeeper to the dapp
79+
const tonConnect = new TonConnectWidget(app, connectButton)
80+
await tonConnect.connectWallet('Tonkeeper')
81+
await wallet.connect()
82+
83+
// Verify the connected account address
84+
const accountSelector = app.locator('div[data-tc-text]')
85+
await expect(accountSelector).toHaveText('0QAy…WfyR')
86+
87+
// Sending transactions
88+
await app.getByRole('button', { name: 'Send transaction' }).click()
89+
await wallet.accept()
90+
})
91+
```
92+
93+
## Running Tests
94+
95+
To run your Playwright tests with Tonkeeper:
96+
97+
1. Start your local development server (if testing against a local app).
98+
99+
2. Run the tests:
100+
101+
```bash
102+
npx playwright test --config playwright-test.config.ts
103+
```
104+
105+
This will execute your tests using Playwright with Tonkeeper integration
106+
2107

3108
## QA
4109

5-
Write scenarios in folder [features](features) see [Gherkin Reference](https://cucumber.io/docs/gherkin/reference/)
110+
Write scenarios in folder [features](features) see [Gherkin Reference](https://cucumber.io/docs/gherkin/reference/) and [Cucumber Anti-Patterns](https://www.thinkcode.se/blog/2016/06/22/cucumber-antipatterns)
6111

7112
## SE
8113

@@ -15,7 +120,27 @@ npm install
15120
npm run lint
16121
npm run format
17122
npx playwright install
123+
pnpm exec playwright install
18124
npm test
19125
# or
20126
npm run watch
21127
```
128+
129+
# Techstack
130+
131+
- [Gherkin](https://cucumber.io/docs/gherkin/) — language used for describe acceptance scenarios
132+
- [Cucumber Anti-Patterns](https://www.thinkcode.se/blog/2016/06/22/cucumber-antipatterns)
133+
- [Node.js](https://nodejs.org/) — main platform for automation implementation
134+
- [Playwright](https://playwright.dev/) + [BDD](https://vitalets.github.io/playwright-bdd/) — framework browser automation used for implementation steps uses in scenarios
135+
136+
## TODO research
137+
138+
- https://www.browserstack.com/
139+
- https://vitalets.github.io/playwright-bdd/#/guides/usage-with-browserstack
140+
- https://saucelabs.com/
141+
- https://vitalets.github.io/playwright-bdd/#/guides/usage-with-saucelabs
142+
- https://nx.dev/
143+
- https://vitalets.github.io/playwright-bdd/#/guides/usage-with-nx
144+
- IDE integration
145+
- Intellij IDE / Aqua https://vitalets.github.io/playwright-bdd/#/guides/ide-integration?id=intellij-ide-aqua
146+
- VS Code https://vitalets.github.io/playwright-bdd/#/guides/ide-integration?id=vs-code

environment.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare global {
2+
namespace NodeJS {
3+
interface ProcessEnv {
4+
WALLET_MNEMONIC: string
5+
}
6+
}
7+
}
8+
9+
export {}

0 commit comments

Comments
 (0)