Skip to content

Commit

Permalink
fix: Let test case run same as the action
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Aug 13, 2024
1 parent 43d2013 commit 8122bbf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
run: ./scripts/download-ckb.sh mac
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Build main
run: yarn build:main
- name: Run Playwright tests
run: yarn test:e2e
- uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"package:e2e": "yarn build && ./scripts/copy-ui-files.sh",
"package:test": "yarn build && ./scripts/copy-ui-files.sh && ./scripts/package-for-test.sh",
"test": "cross-env NODE_OPTIONS=--openssl-legacy-provider lerna run --parallel --load-env-files=false test",
"test:e2e": "cd packages/e2e && yarn test:e2e",
"test:e2e": "./scripts/reset-e2e-data.sh && yarn build:main && cd packages/e2e && yarn test:e2e",
"test:ci": "yarn build:main && yarn test",
"lint": "lerna run --stream lint",
"postinstall": "husky install",
Expand Down
10 changes: 6 additions & 4 deletions packages/e2e/__tests__/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {_electron as electron, ElectronApplication, Page} from "playwright";
import {test, expect} from "@playwright/test";
import { scheduler } from "node:timers/promises";
// import { scheduler } from "timers/promises";
// import ClickSystemMenu from '../common/utils';

Expand Down Expand Up @@ -92,7 +93,7 @@ test("Create Wallet", async () => {
await page.getByPlaceholder("Repeat Password").click();
await page.getByPlaceholder("Repeat Password").fill("Aa111111");
await page.getByLabel("Finish Creating").click();
await page.getByRole('button', {name: 'Start Sync'}).click();
await page.getByRole('button', {name: 'Start Sync'}).click({ delay: 1_000 });
console.log('主网环境已进入!');

// await page.waitForTimeout(20000);
Expand Down Expand Up @@ -135,9 +136,10 @@ test.describe('overview page tests', () => {
console.log('点击设置成功');
// await page.locator('dialog').filter({ hasText: /^Confirm$/ }).getByLabel('Confirm')
// .click();
await page.getByText('Light Client (http://127.0.0.1:9000)').click();
await page.getByText('Light Client (http://127.0.0.1:9000)').click({ delay: 2_000 });
console.log('点击轻节点成功');
//CI 环境轻节点需要从主网到测试网
await page.getByText('Light Client (http://127.0.0.1:9000)').hover({ timeout: 2_000 });
await page.locator('//*[@id="root"]/div/div/div[2]/div/div[3]/div[2]/div/div/div[2]/div/div/div/div/button/*[name()="svg"]').click();
console.log('轻节点主网切换到测试网成功');
// await scheduler.wait(20_000)
Expand Down Expand Up @@ -167,8 +169,8 @@ test.describe('overview page tests', () => {
console.log('输入金额成功');
await page.screenshot({path: "./test-results/send_transaction_4.png"});
test.setTimeout(480000);
await page.waitForTimeout(420000);
await page.screenshot({path: "./test-results/after-timeout.png"});
await page.waitForTimeout(20_000);
await page.locator("id=amount").fill("103.4");
await page.screenshot({path: "./test-results/7min-sync.png"});
await page.getByTitle('History').click();
await page.screenshot({path: "./test-results/history.png"});
Expand Down
12 changes: 12 additions & 0 deletions scripts/reset-e2e-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

{
cd ${HOME}
rm -rf './Library/Application Support/Electron/dev/wallets'
rm -rf './Library/Application Support/Electron/dev/cells'
rm -rf './Library/Application Support/Electron/dev/networks'
rm -rf './Library/Application Support/Electron/dev/datastore'
rm './Library/Application Support/Electron/dev/settings.json'
} || {
echo "dir is not exist"
}

0 comments on commit 8122bbf

Please sign in to comment.