-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added playwright e2e tests * Run playwright tests in github actions * Added staging e2e test for homepage * Added staging anonymous donation e2e test * Make sure we can donate on staging * Added staging donation test with custom amount * Skip local e2e tests * Update wait for navigation in e2e tests * Replace waitForNavigation with waitForURL * Update wait for url method * setup local env for paywright tests Signed-off-by: Ivan Milchev <ivan@mondoo.com> * don't skip local tests Signed-off-by: Ivan Milchev <ivan@mondoo.com> * make sure frontend is started before playwright tests Signed-off-by: Ivan Milchev <ivan@mondoo.com> * added caching and build step for frontend Signed-off-by: Ivan Milchev <ivan@mondoo.com> * removed playwright workflow and added caching Signed-off-by: Ivan Milchev <ivan@mondoo.com> * try out different cache configuration Signed-off-by: Ivan Milchev <ivan@mondoo.com> * add upterm for debugging Signed-off-by: Ivan Milchev <ivan@mondoo.com> * setup env Signed-off-by: Ivan Milchev <ivan@mondoo.com> * Update e2e tests * Comment out upterm * Rename report artifact * extract playwright tests into a reusable workflow Signed-off-by: Ivan Milchev <ivan@mondoo.com> * ignore e2e tests when running jest Signed-off-by: Ivan Milchev <ivan@mondoo.com> * Added testing readme Signed-off-by: Ivan Milchev <ivan@mondoo.com> Co-authored-by: Ilko Kacharov <kachar136@gmail.com>
- Loading branch information
Showing
17 changed files
with
803 additions
and
11 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
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,75 @@ | ||
name: Playwright tests | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
run-playwright: | ||
name: Run Playwright | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
path: './frontend' | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: podkrepi-bg/api | ||
ref: master | ||
path: './api' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
**/.next/cache | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Run db | ||
working-directory: ./api | ||
run: docker compose up -d pg-db | ||
|
||
- name: Run api | ||
working-directory: ./api | ||
run: docker compose up -d --force-recreate --no-build migrate-db seed-db api keycloak | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14.x' | ||
|
||
- name: Install dependencies | ||
working-directory: ./frontend | ||
run: yarn | ||
|
||
- name: Build frontend | ||
working-directory: ./frontend | ||
run: yarn run next build | ||
|
||
- name: Setup env | ||
working-directory: ./frontend | ||
run: cp .env.local.example .env.local | ||
|
||
- name: Start frontend | ||
working-directory: ./frontend | ||
run: yarn start & | ||
|
||
- name: Install Playwright Browsers | ||
working-directory: ./frontend | ||
run: npx playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
working-directory: ./frontend | ||
run: yarn playwright test e2e/local | ||
|
||
- uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: ./frontend/playwright-report/ | ||
retention-days: 30 |
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
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 |
---|---|---|
|
@@ -47,3 +47,6 @@ build/ | |
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
/test-results/ | ||
/playwright-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
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,58 @@ | ||
# End-to-end testing | ||
|
||
## Playwright | ||
|
||
- <https://playwright.dev/> | ||
|
||
## Running tests | ||
|
||
E2e tests are automated and running on every PR in Github Actions. [Link to the workflow](https://github.com/podkrepi-bg/frontend/blob/29b49f438541fa9254829a494e388202034b274d/.github/workflows/playwright.yml) | ||
|
||
```shell | ||
$ yarn test:e2e --help | ||
|
||
Run tests with Playwright Test | ||
|
||
Options: | ||
--browser <browser> Browser to use for tests, one of "all", "chromium", "firefox" or "webkit" (default: "chromium") | ||
--headed Run tests in headed browsers (default: headless) | ||
--debug Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --maxFailures=1 --headed --workers=1" options | ||
-c, --config <file> Configuration file, or a test directory with optional "playwright.config.ts"/"playwright.config.js"/"playwright.config.mjs" | ||
--forbid-only Fail if test.only is called (default: false) | ||
--fully-parallel Run all tests in parallel (default: false) | ||
-g, --grep <grep> Only run tests matching this regular expression (default: ".*") | ||
-gv, --grep-invert <grep> Only run tests that do not match this regular expression | ||
--global-timeout <timeout> Maximum time this test suite can run in milliseconds (default: unlimited) | ||
-j, --workers <workers> Number of concurrent workers, use 1 to run in a single worker (default: number of CPU cores / 2) | ||
--list Collect all the tests and report them, but do not run | ||
--max-failures <N> Stop after the first N failures | ||
--output <dir> Folder for output artifacts (default: "test-results") | ||
--quiet Suppress stdio | ||
--repeat-each <N> Run each test N times (default: 1) | ||
--reporter <reporter> Reporter to use, comma-separated, can be "list", "line", "dot", "json", "junit", "null", "github", "html" (default: "list") | ||
--retries <retries> Maximum retry count for flaky tests, zero for no retries (default: no retries) | ||
--shard <shard> Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5" | ||
--project <project-name...> Only run tests from the specified list of projects (default: run all projects) | ||
--timeout <timeout> Specify test timeout threshold in milliseconds, zero for unlimited (default: 30000) | ||
-u, --update-snapshots Update snapshots with actual results (default: only create missing snapshots) | ||
-x Stop after the first failure | ||
-h, --help display help for command | ||
``` | ||
### Run all test suites | ||
```shell | ||
yarn test:e2e | ||
``` | ||
### Run only local test suites | ||
```shell | ||
yarn test:e2e local | ||
``` | ||
### Run local test suites in headed mode with enabled debug | ||
```shell | ||
yarn test:e2e local --headed --debug -x -g support | ||
``` |
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,80 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3040/') | ||
}) | ||
|
||
test('test homepage', async ({ page }) => { | ||
// Click text=Това е бета версията на платформата на Подкрепи.бг преди предстоящия наесен офиц | ||
await expect( | ||
page.locator( | ||
'text=Това е бета версията на платформата на Подкрепи.бг преди предстоящия наесен офиц', | ||
), | ||
).toBeDefined() | ||
|
||
// Click text=Затвори | ||
await page.locator('text=Затвори').click() | ||
|
||
// Click text=Текущи кампании | ||
await page.locator('text=Текущи кампании').click() | ||
|
||
// Click text=Как работи Подкрепи.бг? | ||
await page.locator('text=Как работи Подкрепи.бг?').click() | ||
|
||
// Click text=Кой стои зад Подкрепи.бг? | ||
await page.locator('text=Кой стои зад Подкрепи.бг?').click() | ||
|
||
// Click text=Какво ни обединява? | ||
await page.locator('text=Какво ни обединява?').click() | ||
|
||
// Click text=Искам да помогна на Подкрепи.бг | ||
await page.locator('text=Искам да помогна на Подкрепи.бг').click() | ||
|
||
// Click h2:has-text("Често задавани въпроси") | ||
await page.locator('h2:has-text("Често задавани въпроси")').click() | ||
|
||
// Click text=Какво представлява Подкрепи.бг?Подкрепи.бг е платформа за среща между хора, коит >> [data-testid="ExpandMoreIcon"] | ||
await page | ||
.locator( | ||
'text=Какво представлява Подкрепи.бг?Подкрепи.бг е платформа за среща между хора, коит >> [data-testid="ExpandMoreIcon"]', | ||
) | ||
.click() | ||
|
||
// Click text=Подкрепи.бг е платформа за среща между хора, които искат да съберат средства за | ||
await page | ||
.locator( | ||
'text=Подкрепи.бг е платформа за среща между хора, които искат да съберат средства за ', | ||
) | ||
.click() | ||
|
||
// Click text=Защо направихте нова платформа, когато вече има и други? | ||
await page.locator('text=Защо направихте нова платформа, когато вече има и други?').click() | ||
|
||
// Click text=Накратко - целта ни е да увеличим доверието на обществото в дарителските организ | ||
await page | ||
.locator( | ||
'text=Накратко - целта ни е да увеличим доверието на обществото в дарителските организ', | ||
) | ||
.click() | ||
|
||
// Click text=Как гарантирате прозрачност и какво значи “софтуер с отворен код”? | ||
await page | ||
.locator('text=Как гарантирате прозрачност и какво значи “софтуер с отворен код”?') | ||
.click() | ||
|
||
// Click text=Софтуер с отворен код е установена практика, при която всеки, без ограничение, м | ||
await page | ||
.locator( | ||
'text=Софтуер с отворен код е установена практика, при която всеки, без ограничение, м', | ||
) | ||
.click() | ||
|
||
// Click text=Виж всички >> nth=1 | ||
await page.locator('text=Виж всички').nth(1).click() | ||
await expect(page).toHaveURL('http://localhost:3040/faq') | ||
|
||
// Click text=Моделът ни на работа се основава на Принципите, които ни обединяват | ||
await page | ||
.locator('text=Моделът ни на работа се основава на Принципите, които ни обединяват') | ||
.click() | ||
}) |
Oops, something went wrong.