Skip to content

Commit

Permalink
chore: add auth e2e test readme section
Browse files Browse the repository at this point in the history
  • Loading branch information
gparlakov committed Oct 20, 2024
1 parent 12a7a2a commit 0112db6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates:
## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for:
Expand Down
19 changes: 19 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,22 @@ Options:
```shell
yarn test:e2e --headed --debug -x -g support
```
### Tests with Authenticated user
### Writing
To auth a user we rely on the Storage where the session is stored. And the storage is filled in and accessed via a `test.extend` [fixture](https://playwright.dev/docs/auth#authenticate-with-api-request). It takes care to login and store the session and then use it in the tests. See the `e2e/utils/fixtures.ts` file
This is the process for writing tests for auth user.
- import the desired user `test` from the fixture
```import { expect, giverTest as test } from '../../../utils/fixtures'``` for the `giver` user
- write your e2e tests ...
>[Examples] `e2e/tests/regression/campaign-application/campaign-application-giver.spec.ts` and `e2e/tests/regression/campaign-application/campaign-application-admin.spec.ts`
### Running
- [Locally] run the 'docker compose -d keycloak pg-db', the api (`yarn dev` in the api repo folder), the app (`yarn dev` in the frontend repo folder),
- in the `frontend/e2e` folder run `yarn e2e:tests --ui` to start the playwright visual testing tool
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {
CampaignApplicationResponse,
CampaignApplicationExisting,
CampaignApplicationAdminResponse,
} from '../../../../src/gql/campaign-applications'
import { Page } from 'playwright/test'
import { expect, giverTest as test } from '../../../utils/fixtures'
import { textLocalized } from '../../../utils/texts-localized'
Expand Down
4 changes: 4 additions & 0 deletions e2e/utils/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* This is logic for authenticating and storing the session to be used in the tests. See the e2e/Readme.md - the section about Authenticated user
*/

import { test, test as base } from '@playwright/test'
import dotenv from 'dotenv'
import fs from 'fs'
Expand Down

0 comments on commit 0112db6

Please sign in to comment.