Skip to content

Commit

Permalink
with docker and playright
Browse files Browse the repository at this point in the history
  • Loading branch information
silkroadnomad committed Dec 2, 2024
1 parent b3c915a commit 44b595b
Show file tree
Hide file tree
Showing 8 changed files with 11,186 additions and 72 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ jobs:
run: docker-compose -f "docker/doichain/docker-compose-regtest.yml" up -d
- uses: actions/setup-node@v4
with:
node-version: lts/*
node-version: '20'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Start the development server
run: npm run dev & npx wait-on http://localhost:5173
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
Expand Down
20 changes: 0 additions & 20 deletions e2e/example.spec.js

This file was deleted.

80 changes: 50 additions & 30 deletions e2e/playground.spec.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
import { expect, test } from '@playwright/test';

test.describe('Wallet Generation Tests', () => {
test('should generate a new mnemonic and test all wallet types', async ({ page }) => {
// Navigate to the page
await page.goto('https://doichain-playground-svelte.vercel.app/');

// Generate a new mnemonic
await page.click('button:has-text("Generate Mnemonic")');
const mnemonic = await page.inputValue('textarea[labelText="Mnemonic"]');
test('test', async ({ page }) => {
await page.goto('http://localhost:5173/');
await page.waitForSelector('text=You are connected to an', { state: 'visible' });
await page.getByLabel('Select Wallet').first().selectOption('electrum-legacy');
//await page.getByRole('button', { name: 'Decrypt' }).click();
await page.getByRole('button', { name: 'Generate Mnemonic' }).click();
//await expect(page.getByLabel('Mnemonic')).toBeVisible();
const mnemonic = await page.inputValue('#mnemonicTextarea');
await page.getByLabel('Mnemonic').click();
expect(mnemonic).not.toBe('');

// Test each derivation standard
const derivationStandards = [
'electrum-legacy',
'electrum-segwit',
'bip32',
'bip32-p2wpkh',
'bip84'
];

for (const standard of derivationStandards) {
// Select the derivation standard
await page.selectOption('select[labelText="Select Wallet"]', { value: standard });

// Generate addresses
await page.click('button:has-text("Save")');

// Verify that addresses are generated
const addresses = await page.$$eval('.datatable .address', nodes => nodes.map(n => n.textContent));
expect(addresses.length).toBeGreaterThan(0);

// Optionally, verify the first address format or other properties
console.log(`Addresses for ${standard}:`, addresses);
}
// await expect(page.getByLabel('Mnemonic')).toHaveValue('gentle model squirrel point soldier suit daring april ketchup soon lemon year');
});
// test('should generate a new mnemonic and test all wallet types', async ({ page }) => {
// // Navigate to the page
// await page.goto('/');
// await page.waitForSelector('text=You are connected to an', { state: 'visible' });


// // Ensure the button is visible
// await page.waitForSelector('button:has-text("Generate Mnemonic")', { state: 'visible' });

// // Generate a new mnemonic
// await page.click('button:has-text("Generate Mnemonic")');
// await page.waitForFunction(() => document.querySelector('#mnemonicTextarea').value !== '');
// const mnemonic = await page.inputValue('#mnemonicTextarea');
// console.log('mnemonic', mnemonic);
// expect(mnemonic).not.toBe('');

// // Test each derivation standard
// const derivationStandards = [
// 'electrum-legacy',
// 'electrum-segwit',
// 'bip32',
// 'bip32-p2wpkh',
// 'bip84'
// ];

// for (const standard of derivationStandards) {
// // Select the derivation standard
// await page.selectOption('select[labelText="Select Wallet"]', { value: standard });

// // Generate addresses
// await page.click('button:has-text("Save")');

// // Verify that addresses are generated
// const addresses = await page.$$eval('.datatable .address', nodes => nodes.map(n => n.textContent));
// expect(addresses.length).toBeGreaterThan(0);

// // Optionally, verify the first address format or other properties
// console.log(`Addresses for ${standard}:`, addresses);
// }
// });
});
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
"private": true,
"scripts": {
"dev": "vite dev",
"start": "vite preview",
"build": "vite build",
"ipfs-publish": "npm version patch && npm run build && ./ipfs-publish.sh",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"test": "npm run test:integration && npm run test:unit",
"playwright": "npx playwright test tests/playground.spec.js",
"test-local": "npm run test:integration && npm run test:unit",
"test": "concurrently \"npm run dev\" \"wait-on http://localhost:5173 && npx playwright test e2e/playground.spec.js\"",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
Expand All @@ -25,6 +28,7 @@
"@types/node": "^22.10.1",
"carbon-components-svelte": "^0.85.4",
"carbon-icons-svelte": "^12.13.0",
"concurrently": "^9.1.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
Expand All @@ -37,7 +41,8 @@
"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0",
"vitest": "^1.2.0"
"vitest": "^1.2.0",
"wait-on": "^8.0.1"
},
"type": "module",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default defineConfig({
reporter: 'html',
use: {
trace: 'on-first-retry',
baseURL: 'http://localhost:5173',
},
projects: [
{
Expand All @@ -24,7 +25,6 @@ export default defineConfig({
use: { ...devices['Desktop Safari'] },
},
],
// Uncomment and configure the web server if needed
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
Expand Down
Loading

0 comments on commit 44b595b

Please sign in to comment.