Skip to content

Commit

Permalink
Misc update (remove outdated functions) and improve playwright workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ccxzhang committed Jul 11, 2024
1 parent b26f3ff commit 50cdabf
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 34 deletions.
29 changes: 20 additions & 9 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,46 @@ on:
push:
branches:
- main
- 'release/*'
pull_request:
branches:
- main

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [16.x, 18.x]

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Build application
run: npm run build
- name: Build project
run: npm run build:linux

- name: Run Playwright tests
run: npm run test:playwright
env:
TEST_DHIS2_URL: ${{ secrets.TEST_DHIS2_URL }}
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}

- name: Upload Playwright test results
uses: actions/upload-artifact@v3
with:
name: playwright-test-results
path: test-results/



4 changes: 3 additions & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ directories:
buildResources: build
files:
- '!**/.vscode/*'
- out/
- '!src/*'
- '!electron.vite.config.{js,ts,mjs,cjs}'
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
asarUnpack:
- resources/**
win:
executableName: dhis2-downloader
executableName: DHIS2 Downloader
nsis:
artifactName: ${name}-${version}-setup.${ext}
shortcutName: ${productName}
Expand Down Expand Up @@ -42,3 +43,4 @@ publish:
url: https://example.com/auto-updates
electronDownload:
mirror: https://npmmirror.com/mirrors/electron/

18 changes: 0 additions & 18 deletions playwright.config.js

This file was deleted.

28 changes: 28 additions & 0 deletions playwright.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from '@playwright/test'

export default defineConfig({
testDir: './tests',
timeout: 60000,
expect: {
timeout: 5000
},
use: {
headless: true,
viewport: { width: 1280, height: 720 },
actionTimeout: 0,
ignoreHTTPSErrors: true
},
reporter: [['list'], ['json', { outputFile: 'test-results/results.json' }]],
projects: [
{
name: 'electron',
use: {
browserName: 'chromium',
channel: 'chrome',
launchOptions: {
args: ['--no-sandbox']
}
}
}
]
})
7 changes: 4 additions & 3 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { app, shell, BrowserWindow, ipcMain, protocol, net } = require('electron')
const { path, join } = require('path')
const { electronApp, optimizer, is } = require('@electron-toolkit/utils')
import { app, shell, BrowserWindow, ipcMain, protocol, net } from 'electron'
import { path, join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'

const iconPath = join(__dirname, '../../resources/icon.png')

function createWindow() {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/src/pages/DataDictionary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useLiveQuery } from 'dexie-react-hooks'
import { useRef, useState, useEffect, useCallback, useMemo } from 'react'
import LoadingModal from './Modal'
import { objectToCsv } from '../utils/helpers'
import { getJsonIdInfo } from '../service/useApi'
import { extractIds, updateFormulaNames } from '../utils/helpers'
import { updateFormulaNames } from '../utils/helpers'

const ExportLink = ({ onClick, text }) => (
<div className="flex items-center cursor-pointer text-blue-600" onClick={onClick}>
Expand Down
216 changes: 216 additions & 0 deletions test-results/results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"config": {
"configFile": "/Users/czhang/Desktop/GFF/dhis2-downloader/playwright.config.mjs",
"rootDir": "/Users/czhang/Desktop/GFF/dhis2-downloader/tests",
"forbidOnly": false,
"fullyParallel": false,
"globalSetup": null,
"globalTeardown": null,
"globalTimeout": 0,
"grep": {},
"grepInvert": null,
"maxFailures": 0,
"metadata": {
"actualWorkers": 1
},
"preserveOutput": "always",
"reporter": [
[
"list",
null
],
[
"json",
{
"outputFile": "test-results/results.json"
}
]
],
"reportSlowTests": {
"max": 5,
"threshold": 15000
},
"quiet": false,
"projects": [
{
"outputDir": "/Users/czhang/Desktop/GFF/dhis2-downloader/test-results",
"repeatEach": 1,
"retries": 0,
"metadata": {},
"id": "electron",
"name": "electron",
"testDir": "/Users/czhang/Desktop/GFF/dhis2-downloader/tests",
"testIgnore": [],
"testMatch": [
"**/*.@(spec|test).?(c|m)[jt]s?(x)"
],
"timeout": 60000
}
],
"shard": null,
"updateSnapshots": "missing",
"version": "1.45.1",
"workers": 5,
"webServer": null
},
"suites": [
{
"title": "example.spec.js",
"file": "example.spec.js",
"column": 0,
"line": 0,
"specs": [],
"suites": [
{
"title": "Electron app",
"file": "example.spec.js",
"line": 11,
"column": 6,
"specs": [
{
"title": "should have a navbar with clickable elements",
"ok": true,
"tags": [],
"tests": [
{
"timeout": 60000,
"annotations": [],
"expectedStatus": "passed",
"projectId": "electron",
"projectName": "electron",
"results": [
{
"workerIndex": 0,
"status": "passed",
"duration": 181,
"errors": [],
"stdout": [
{
"buffer": "Cj4gZGhpczItZG93bmxvYWRlckAwLjAuMSBidWlsZAo+IGVsZWN0cm9uLXZpdGUgYnVpbGQKCg=="
},
{
"buffer": "G1szNm12aXRlIHY1LjIuMTMgG1szMm1idWlsZGluZyBTU1IgYnVuZGxlIGZvciBwcm9kdWN0aW9uLi4uG1szNm0bWzM5bQo="
},
{
"buffer": "dHJhbnNmb3JtaW5nLi4uCg=="
},
{
"buffer": "G1szMm3inJMbWzM5bSAxIG1vZHVsZXMgdHJhbnNmb3JtZWQuCg=="
},
{
"buffer": "cmVuZGVyaW5nIGNodW5rcy4uLgo="
},
{
"buffer": "G1sybW91dC9tYWluLxtbMjJtG1szNm1pbmRleC5qcyAgG1szOW0bWzFtG1sybTEuOTMga0IbWzIybRtbMW0bWzIybQo="
},
{
"buffer": "G1szMm3inJMgYnVpbHQgaW4gMzRtcxtbMzltCg=="
},
{
"buffer": "G1szNm12aXRlIHY1LjIuMTMgG1szMm1idWlsZGluZyBTU1IgYnVuZGxlIGZvciBwcm9kdWN0aW9uLi4uG1szNm0bWzM5bQo="
},
{
"buffer": "dHJhbnNmb3JtaW5nLi4uCg=="
},
{
"buffer": "G1szMm3inJMbWzM5bSAxIG1vZHVsZXMgdHJhbnNmb3JtZWQuCg=="
},
{
"buffer": "cmVuZGVyaW5nIGNodW5rcy4uLgo="
},
{
"buffer": "G1sybW91dC9wcmVsb2FkLxtbMjJtG1szNm1pbmRleC5qcyAgG1szOW0bWzFtG1sybTAuNDIga0IbWzIybRtbMW0bWzIybQo="
},
{
"buffer": "G1szMm3inJMgYnVpbHQgaW4gNW1zG1szOW0K"
},
{
"buffer": "G1szNm12aXRlIHY1LjIuMTMgG1szMm1idWlsZGluZyBmb3IgcHJvZHVjdGlvbi4uLhtbMzZtG1szOW0K"
},
{
"buffer": "dHJhbnNmb3JtaW5nLi4uCg=="
},
{
"buffer": "G1szMm3inJMbWzM5bSA1NCBtb2R1bGVzIHRyYW5zZm9ybWVkLgo="
},
{
"buffer": "cmVuZGVyaW5nIGNodW5rcy4uLgo="
},
{
"buffer": "G1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMzJtaW5kZXguaHRtbCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtICAwLjU1IGtCG1syMm0bWzFtG1syMm0KG1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzMybUZBU1RSX0xvZ29fV2hpdGVfRW4tQlFSSGdEdVcucG5nICAbWzM5bRtbMW0bWzJtICA3LjY1IGtCG1syMm0bWzFtG1syMm0K"
},
{
"buffer": "G1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzM1bWluZGV4LUR0cTBUbkFaLmNzcyAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtIDE5LjgwIGtCG1syMm0bWzFtG1syMm0KG1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzM2bWluZGV4LURMaHF1V0NFLmpzICAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtNDc1LjAyIGtCG1syMm0bWzFtG1syMm0KG1szMm3inJMgYnVpbHQgaW4gNTMzbXMbWzM5bQo="
},
{
"text": "Running on platform: darwin\n"
},
{
"text": "App path: /Users/czhang/Desktop/GFF/dhis2-downloader/dist/mac-arm64/DHIS2 Downloader.app/Contents/MacOS/DHIS2 Downloader\n"
}
],
"stderr": [
{
"buffer": "InBhdGgiIGlzIGltcG9ydGVkIGZyb20gZXh0ZXJuYWwgbW9kdWxlICJwYXRoIiBidXQgbmV2ZXIgdXNlZCBpbiAic3JjL21haW4vaW5kZXguanMiLgo="
}
],
"retry": 0,
"startTime": "2024-07-11T19:25:12.890Z",
"attachments": []
}
],
"status": "expected"
}
],
"id": "dd9b2edffe9b7501040c-7c3a2968a83df7425d60",
"file": "example.spec.js",
"line": 57,
"column": 7
},
{
"title": "Could fill in Login Form",
"ok": true,
"tags": [],
"tests": [
{
"timeout": 60000,
"annotations": [],
"expectedStatus": "passed",
"projectId": "electron",
"projectName": "electron",
"results": [
{
"workerIndex": 0,
"status": "passed",
"duration": 284,
"errors": [],
"stdout": [],
"stderr": [],
"retry": 0,
"startTime": "2024-07-11T19:25:14.392Z",
"attachments": []
}
],
"status": "expected"
}
],
"id": "dd9b2edffe9b7501040c-4d9d3e94d2e94c9722e8",
"file": "example.spec.js",
"line": 68,
"column": 7
}
]
}
]
}
],
"errors": [],
"stats": {
"startTime": "2024-07-11T19:25:12.648Z",
"duration": 2226.217,
"expected": 2,
"skipped": 0,
"unexpected": 0,
"flaky": 0
}
}
3 changes: 2 additions & 1 deletion tests/example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { _electron as electron } from 'playwright'
import { test, expect } from '@playwright/test'
import path from 'path'
import { execSync } from 'child_process'
import dotenv from 'dotenv'
import os from 'os'
import dotenv from 'dotenv'

// Load environment variables from .env file
dotenv.config()

test.describe('Electron app', () => {
Expand Down

0 comments on commit 50cdabf

Please sign in to comment.