Skip to content

Commit

Permalink
Github actions -- allow tracing errors and screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ccxzhang committed Jul 11, 2024
1 parent 9cd17ce commit 6d958e9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@ jobs:
name: playwright-test-results
path: test-results/

- name: Upload error screenshots
uses: actions/upload-artifact@v2
if: failure()
with:
name: error-screenshots
path: test-results/error-screenshot.png



24 changes: 14 additions & 10 deletions test-results/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{
"workerIndex": 0,
"status": "passed",
"duration": 181,
"duration": 208,
"errors": [],
"stdout": [
{
Expand All @@ -104,7 +104,7 @@
"buffer": "G1sybW91dC9tYWluLxtbMjJtG1szNm1pbmRleC5qcyAgG1szOW0bWzFtG1sybTEuOTMga0IbWzIybRtbMW0bWzIybQo="
},
{
"buffer": "G1szMm3inJMgYnVpbHQgaW4gMzRtcxtbMzltCg=="
"buffer": "G1szMm3inJMgYnVpbHQgaW4gNjNtcxtbMzltCg=="
},
{
"buffer": "G1szNm12aXRlIHY1LjIuMTMgG1szMm1idWlsZGluZyBTU1IgYnVuZGxlIGZvciBwcm9kdWN0aW9uLi4uG1szNm0bWzM5bQo="
Expand All @@ -122,7 +122,7 @@
"buffer": "G1sybW91dC9wcmVsb2FkLxtbMjJtG1szNm1pbmRleC5qcyAgG1szOW0bWzFtG1sybTAuNDIga0IbWzIybRtbMW0bWzIybQo="
},
{
"buffer": "G1szMm3inJMgYnVpbHQgaW4gNW1zG1szOW0K"
"buffer": "G1szMm3inJMgYnVpbHQgaW4gN21zG1szOW0K"
},
{
"buffer": "G1szNm12aXRlIHY1LjIuMTMgG1szMm1idWlsZGluZyBmb3IgcHJvZHVjdGlvbi4uLhtbMzZtG1szOW0K"
Expand All @@ -140,7 +140,7 @@
"buffer": "G1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMzJtaW5kZXguaHRtbCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtICAwLjU1IGtCG1syMm0bWzFtG1syMm0KG1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzMybUZBU1RSX0xvZ29fV2hpdGVfRW4tQlFSSGdEdVcucG5nICAbWzM5bRtbMW0bWzJtICA3LjY1IGtCG1syMm0bWzFtG1syMm0K"
},
{
"buffer": "G1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzM1bWluZGV4LUR0cTBUbkFaLmNzcyAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtIDE5LjgwIGtCG1syMm0bWzFtG1syMm0KG1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzM2bWluZGV4LURMaHF1V0NFLmpzICAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtNDc1LjAyIGtCG1syMm0bWzFtG1syMm0KG1szMm3inJMgYnVpbHQgaW4gNTMzbXMbWzM5bQo="
"buffer": "G1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzM1bWluZGV4LUR0cTBUbkFaLmNzcyAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtIDE5LjgwIGtCG1syMm0bWzFtG1syMm0KG1sybS4uLy4uL291dC9yZW5kZXJlci8bWzIybRtbMm1hc3NldHMvG1syMm0bWzM2bWluZGV4LURMaHF1V0NFLmpzICAgICAgICAgICAgICAgICAbWzM5bRtbMW0bWzJtNDc1LjAyIGtCG1syMm0bWzFtG1syMm0KG1szMm3inJMgYnVpbHQgaW4gNTU5bXMbWzM5bQo="
},
{
"text": "Running on platform: darwin\n"
Expand All @@ -155,7 +155,7 @@
}
],
"retry": 0,
"startTime": "2024-07-11T19:25:12.890Z",
"startTime": "2024-07-11T21:06:57.370Z",
"attachments": []
}
],
Expand All @@ -182,12 +182,16 @@
{
"workerIndex": 0,
"status": "passed",
"duration": 284,
"duration": 306,
"errors": [],
"stdout": [],
"stdout": [
{
"text": "TEST_DHIS2_URL: https://moph-dw.gov.af\n"
}
],
"stderr": [],
"retry": 0,
"startTime": "2024-07-11T19:25:14.392Z",
"startTime": "2024-07-11T21:06:59.238Z",
"attachments": []
}
],
Expand All @@ -206,8 +210,8 @@
],
"errors": [],
"stats": {
"startTime": "2024-07-11T19:25:12.648Z",
"duration": 2226.217,
"startTime": "2024-07-11T21:06:57.079Z",
"duration": 2574.254,
"expected": 2,
"skipped": 0,
"unexpected": 0,
Expand Down
28 changes: 17 additions & 11 deletions tests/example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,25 @@ test.describe('Electron app', () => {
})

test('Could fill in Login Form', async () => {
const window = await electronApp.firstWindow()
const dhis2UrlInput = await window.locator('xpath=//form//input[@placeholder="DHIS2 URL"]')
await dhis2UrlInput.fill(process.env.TEST_DHIS2_URL)
try {
const window = await electronApp.firstWindow()
const dhis2UrlInput = await window.locator('xpath=//form//input[@placeholder="DHIS2 URL"]')
console.log('TEST_DHIS2_URL:', process.env.TEST_DHIS2_URL)
await dhis2UrlInput.fill(process.env.TEST_DHIS2_URL)

// Fill in other input fields (example)
const usernameInput = await window.locator('xpath=//form//input[@placeholder="Username"]')
await usernameInput.fill(process.env.TEST_USERNAME)
// Fill in other input fields (example)
const usernameInput = await window.locator('xpath=//form//input[@placeholder="Username"]')
await usernameInput.fill(process.env.TEST_USERNAME)

const passwordInput = await window.locator('xpath=//form//input[@placeholder="Password"]')
await passwordInput.fill(process.env.TEST_PASSWORD)
const passwordInput = await window.locator('xpath=//form//input[@placeholder="Password"]')
await passwordInput.fill(process.env.TEST_PASSWORD)

// Optionally, click the submit button
const submitButton = await window.locator('xpath=//form//button[@type="submit"]')
await submitButton.click()
const submitButton = await window.locator('xpath=//form//button[@type="submit"]')
await submitButton.click()
} catch (error) {
console.error('Test failed:', error)
await window.screenshot({ path: path.join('test-results', 'error-screenshot.png') })
throw error
}
})
})

0 comments on commit 6d958e9

Please sign in to comment.