Skip to content

Commit

Permalink
Intialize Github actions with playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
ccxzhang committed Jul 11, 2024
1 parent 1257b91 commit b26f3ff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 11 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Playwright Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: npm install

- name: Build application
run: npm run build

- 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 }}
35 changes: 24 additions & 11 deletions tests/example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { test, expect } from '@playwright/test'
import path from 'path'
import { execSync } from 'child_process'
import dotenv from 'dotenv'
import os from 'os'

dotenv.config()

Expand All @@ -13,17 +14,29 @@ test.describe('Electron app', () => {
// Build the application before running the tests
execSync('npm run build', { stdio: 'inherit' })

// Path to the built Electron app
const appPath = path.join(
__dirname,
'..',
'dist',
'mac-arm64',
'DHIS2 Downloader.app',
'Contents',
'MacOS',
'DHIS2 Downloader'
)
const platform = os.platform()
let appPath
if (platform == 'darwin') {
appPath = path.join(
__dirname,
'..',
'dist',
'mac-arm64',
'DHIS2 Downloader.app',
'Contents',
'MacOS',
'DHIS2 Downloader'
)
} else if (platform === 'win32') {
// Windows
appPath = path.join(__dirname, '..', 'dist', 'win-unpacked', 'DHIS2 Downloader.exe')
} else if (platform === 'linux') {
// Linux
appPath = path.join(__dirname, '..', 'dist', 'linux-unpacked', 'dhis2-downloader')
}
console.log(`Running on platform: ${platform}`)
console.log(`App path: ${appPath}`)

electronApp = await electron.launch({
executablePath: appPath
})
Expand Down

0 comments on commit b26f3ff

Please sign in to comment.