diff --git a/README.md b/README.md index 67bd26945..cd0668bdf 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates: ## Contributors ✨ + [![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg?style=flat-square)](#contributors-) + Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for: diff --git a/e2e/README.md b/e2e/README.md index 0f3b4bde9..f270dd84e 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -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 diff --git a/e2e/tests/regression/campaign-application/campaign-application-giver.spec.ts b/e2e/tests/regression/campaign-application/campaign-application-giver.spec.ts index 558a0ab83..d657221b6 100644 --- a/e2e/tests/regression/campaign-application/campaign-application-giver.spec.ts +++ b/e2e/tests/regression/campaign-application/campaign-application-giver.spec.ts @@ -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' diff --git a/e2e/utils/fixtures.ts b/e2e/utils/fixtures.ts index ea13fef30..a51ad18a1 100644 --- a/e2e/utils/fixtures.ts +++ b/e2e/utils/fixtures.ts @@ -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'