forked from dedis/d-voting
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from c4dt/playwright
Add automated tests for navigation bar
- Loading branch information
Showing
18 changed files
with
577 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,7 @@ yarn-error.log* | |
.idea | ||
|
||
.vscode | ||
|
||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Automated Tests w/ Playwright | ||
|
||
## Setup | ||
|
||
To install Playwright run | ||
|
||
``` | ||
npm ci | ||
npx playwright install | ||
``` | ||
|
||
which will install the module and its dependencies. In | ||
order to execute the environment necessary for the tests, | ||
additional system dependencies need to be installed. | ||
|
||
Run | ||
|
||
``` | ||
npx playwright install-deps --dry-run | ||
``` | ||
|
||
to be shown the dependencies that you need to install on your machine (requires `root` access). | ||
|
||
Your local frontend must be accessible at `http://127.0.0.1:3000`. | ||
|
||
## Run tests | ||
|
||
Run | ||
|
||
``` | ||
npx playwright test | ||
``` | ||
|
||
to run the tests. This will open a window in your browser w/ the test results. | ||
|
||
To run interactive tests, run | ||
|
||
``` | ||
npx playwright test --ui | ||
``` | ||
|
||
this will open an user interface where you can interactively run and evaluate tests. | ||
|
||
## Update HAR files | ||
|
||
To update the HAR files, you need to make sure | ||
|
||
* that a complete D-Voting setup is running, as the API will be called for real, and | ||
* the `REACT_APP_SCIPER_ADMIN` of the D-Voting instance value is set to `123456` (i.e. the `SCIPER_ADMIN` value in the mocks). | ||
|
||
You then change the `UPDATE = false` value in `tests/mocks.ts` to `UPDATE = true` and execute | ||
the tests as usual. The tests that update the mocks will be run and the other tests will be skipped. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
baseURL: 'http://127.0.0.1:3000', | ||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
], | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
web/frontend/tests/hars/123456/a03037964db4d746517f562ccb09b049db7f7a12.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"sciper":123456,"lastName":"123456","firstName":"sciper-#","isLoggedIn":true,"authorization":{"roles":["add","list","remove"],"proxies":["post","put","delete"],"election":["create"]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"log": { | ||
"version": "1.2", | ||
"creator": { | ||
"name": "Playwright", | ||
"version": "1.40.1" | ||
}, | ||
"browser": { | ||
"name": "chromium", | ||
"version": "120.0.6099.28" | ||
}, | ||
"entries": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"log": { | ||
"version": "1.2", | ||
"creator": { | ||
"name": "Playwright", | ||
"version": "1.40.1" | ||
}, | ||
"browser": { | ||
"name": "chromium", | ||
"version": "120.0.6099.28" | ||
}, | ||
"entries": [ | ||
{ | ||
"startedDateTime": "2023-12-07T15:16:05.427Z", | ||
"time": 63.36, | ||
"request": { | ||
"method": "GET", | ||
"url": "http://127.0.0.1:3000/api/personal_info", | ||
"httpVersion": "HTTP/1.1", | ||
"cookies": [], | ||
"headers": [ | ||
{ "name": "Accept", "value": "*/*" }, | ||
{ "name": "Accept-Language", "value": "en-US" }, | ||
{ "name": "Cookie", "value": "connect.sid=s%3AxeUPf49ZYc9AUrUtzig9-O4g0Z_RVtVV.ChZVAx%2FL%2BIzfgIlkxzUxTLVduImdZIp68OdvODtveTU" }, | ||
{ "name": "Referer", "value": "http://127.0.0.1:3000/about" }, | ||
{ "name": "User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.28 Safari/537.36" } | ||
], | ||
"queryString": [], | ||
"headersSize": -1, | ||
"bodySize": -1 | ||
}, | ||
"response": { | ||
"status": 200, | ||
"statusText": "OK", | ||
"httpVersion": "HTTP/1.1", | ||
"cookies": [], | ||
"headers": [ | ||
{ "name": "access-control-allow-origin", "value": "*" }, | ||
{ "name": "connection", "value": "keep-alive" }, | ||
{ "name": "content-length", "value": "184" }, | ||
{ "name": "content-type", "value": "application/json; charset=utf-8" }, | ||
{ "name": "date", "value": "Thu, 07 Dec 2023 15:16:05 GMT" }, | ||
{ "name": "etag", "value": "W/\"b8-oDA3lk2010ZRf1YsywmwSdt/ehI\"" }, | ||
{ "name": "keep-alive", "value": "timeout=5" }, | ||
{ "name": "x-powered-by", "value": "Express" } | ||
], | ||
"content": { | ||
"size": -1, | ||
"mimeType": "application/json; charset=utf-8", | ||
"_file": "a03037964db4d746517f562ccb09b049db7f7a12.json" | ||
}, | ||
"headersSize": -1, | ||
"bodySize": -1, | ||
"redirectURL": "" | ||
}, | ||
"cache": {}, | ||
"timings": { "send": -1, "wait": -1, "receive": 63.36 } | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
web/frontend/tests/hars/789012/5f05240cb33cb9e581ea0ce24c4e728a04e2a5d1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"sciper":789012,"lastName":"789012","firstName":"sciper-#","isLoggedIn":true,"authorization":{}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"log": { | ||
"version": "1.2", | ||
"creator": { | ||
"name": "Playwright", | ||
"version": "1.40.1" | ||
}, | ||
"browser": { | ||
"name": "chromium", | ||
"version": "120.0.6099.28" | ||
}, | ||
"entries": [] | ||
} | ||
} |
Oops, something went wrong.