Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
devchenyan committed Apr 12, 2024
1 parent 7d45cc1 commit bd248f0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 55 deletions.
91 changes: 72 additions & 19 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,78 @@
name: Playwright Tests

on:
- pull_request
- push

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest

build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node:
- 18.12.0
os:
- macos-latest
- ubuntu-20.04
- windows-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: "yarn"

- name: Restore
uses: actions/cache@v3
with:
path: |
node_modules
*/*/node_modules
key: 2022-10-11-${{ runner.os }}-${{ hashFiles('**/yarn.lock')}}

- name: Install libudev
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Install Lerna
run: yarn global add lerna

- name: Bootstrap
run: yarn
env:
CI: false

- name: Package for E2E
run: yarn package:e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true

- name: E2E Test
run: |
cd packages/e2e
yarn test:e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: screenshots
path: tests/screenshots/**

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"package:e2e": "yarn build && ./scripts/copy-ui-files.sh && npx ncp ./packages/neuron-wallet/dist/ ./packages/e2e/dist",
"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:ci": "yarn build:main && yarn test",
"lint": "lerna run --stream lint",
"postinstall": "husky install",
Expand Down
36 changes: 1 addition & 35 deletions packages/e2e/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { test, expect } from "@playwright/test";
let electronApp: ElectronApplication;

test.beforeAll(async () => {
electronApp = await electron.launch({ args: ["./dist/main.js"] });
electronApp = await electron.launch({ args: ["../neuron-wallet/dist/main.js"] });
electronApp.on("window", async (page) => {
const filename = page.url()?.split("/").pop();
console.log(`Window opened: ${filename}`);
Expand Down Expand Up @@ -39,37 +39,3 @@ test("Launch Neuron", async () => {
const title = await page.title();
expect(title).toBe("Neuron");
});

test("Create Wallet", async () => {
await page.getByLabel("导入助记词").click();
await page.locator("div").filter({ hasText: /^1$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^1$/ }).getByRole("textbox").fill("verb");
await page.locator("div").filter({ hasText: /^2$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^2$/ }).getByRole("textbox").fill("prize");
await page.locator("div").filter({ hasText: /^3$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^3$/ }).getByRole("textbox").fill("broken");
await page.locator("div").filter({ hasText: /^4$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^4$/ }).getByRole("textbox").fill("tobacco");
await page.locator("div").filter({ hasText: /^5$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^5$/ }).getByRole("textbox").fill("plate");
await page.locator("div").filter({ hasText: /^6$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^6$/ }).getByRole("textbox").fill("suspect");
await page.locator("div").filter({ hasText: /^7$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^7$/ }).getByRole("textbox").fill("flip");
await page.locator("div").filter({ hasText: /^8$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^8$/ }).getByRole("textbox").fill("surface");
await page.locator("div").filter({ hasText: /^9$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^9$/ }).getByRole("textbox").fill("circle");
await page.locator("div").filter({ hasText: /^10$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^10$/ }).getByRole("textbox").fill("light");
await page.locator("div").filter({ hasText: /^11$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^11$/ }).getByRole("textbox").fill("portion");
await page.locator("div").filter({ hasText: /^12$/ }).getByRole("textbox").click();
await page.locator("div").filter({ hasText: /^12$/ }).getByRole("textbox").fill("hero");
await page.getByLabel("下一步").click();
await page.getByPlaceholder("请设置一个强密码用于保护您的钱包").fill("Aa111111");
await page.getByPlaceholder("重复密码").click();
await page.getByPlaceholder("重复密码").fill("Aa111111");
await page.getByLabel("完成创建").click();
await page.screenshot({ path: "./test-results/createWallet.png" });
});

1 comment on commit bd248f0

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 8661286495

Please sign in to comment.