Skip to content

Commit 347c295

Browse files
committed
feat: add tonkeeper
1 parent e17b5ad commit 347c295

24 files changed

+6069
-2777
lines changed

.github/workflows/test.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,29 @@ name: test
22

33
on:
44
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
510

611
jobs:
712
test:
813
runs-on: ubuntu-22.04
914
steps:
1015
- uses: actions/checkout@v4
16+
- uses: pnpm/action-setup@v4
17+
with:
18+
version: 9
1119
- uses: actions/setup-node@v4
1220
with:
1321
node-version: 22
14-
- run: npm ci
15-
- run: npm run lint
22+
cache: 'pnpm'
23+
cache-dependency-path: '**/pnpm-lock.yaml'
24+
- run: pnpm install
25+
- run: pnpm lint
1626
- run: npx playwright install --with-deps
17-
- run: npm test
27+
- run: pnpm test
1828
- uses: actions/upload-artifact@v4
1929
if: always()
2030
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: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,147 @@
1-
# ton-connect-qa
1+
# TON-Connect QA
22

3-
## QA
3+
This guide provides a quick setup process for Playwright to automate tests for TON Dapps, note that this is a basic configuration
44

5-
Write scenarios in folder [features](features) see [Gherkin Reference](https://cucumber.io/docs/gherkin/reference/)
5+
## Prerequisites
66

7-
## SE
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+
107+
108+
## BDD
109+
### QA
110+
111+
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)
112+
113+
### SE
8114

9115
Describe step in folder [steps](steps)
10116

11-
## Run
117+
## Develop
12118

13119
```shell
14120
npm install
15121
npm run lint
16122
npm run format
17123
npx playwright install
124+
pnpm exec playwright install
18125
npm test
19126
# or
20127
npm run watch
21128
```
129+
130+
## Techstack
131+
132+
- [Gherkin](https://cucumber.io/docs/gherkin/) — language used for describe acceptance scenarios
133+
- [Cucumber Anti-Patterns](https://www.thinkcode.se/blog/2016/06/22/cucumber-antipatterns)
134+
- [Node.js](https://nodejs.org/) — main platform for automation implementation
135+
- [Playwright](https://playwright.dev/) + [BDD](https://vitalets.github.io/playwright-bdd/) — framework browser automation used for implementation steps uses in scenarios
136+
137+
## TODO research
138+
139+
- https://www.browserstack.com/
140+
- https://vitalets.github.io/playwright-bdd/#/guides/usage-with-browserstack
141+
- https://saucelabs.com/
142+
- https://vitalets.github.io/playwright-bdd/#/guides/usage-with-saucelabs
143+
- https://nx.dev/
144+
- https://vitalets.github.io/playwright-bdd/#/guides/usage-with-nx
145+
- IDE integration
146+
- Intellij IDE / Aqua https://vitalets.github.io/playwright-bdd/#/guides/ide-integration?id=intellij-ide-aqua
147+
- 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)