I added logic for creating a custom user (with fake data), logging in, and using the token for this user in tests
I created a sample test using the new logic
Detailed description:
The new logic uses the new createUser function from the create-user.helper.ts file.
The createUser function uses the new generateFakeUserData function which generates user data using faker (avatar is randomly selected from images available in GAD)
The generated user data are consistent with the new UserData interface in the user.model.ts file.
Additional improvements:
To ensure the user type is correctly stated, I added a new enum (UserType) and replaced all instances of regular and admin with this new enum.
How to use it:
To test as a custom user, create headers with the UserType.custom parameter, e.g.
In general, to explicitly state the user type for creating headers, use the new enum, e.g. instead of createHeaders('admin') now you have to use createHeaders(UserType.admin).
Faker:
First install the faker library: npm i @faker-js/faker
To use the faker, import it (I suggest importing only EN version to improve test performance):
import {faker } from '@faker-js/faker/locale/en'
Any other comments?
See the exemplary test GET quiz questions endpoint tests › Returns 200 OK with authorization to check, how it works.
Before submitting Pull Request, I've ensured that:
[x] The PR is associated with the relevant Issue before its creation.
Resolves #65
Scope of changes:
Detailed description: The new logic uses the new
createUser
function from thecreate-user.helper.ts
file. ThecreateUser
function uses the newgenerateFakeUserData
function which generates user data using faker (avatar is randomly selected from images available in GAD) The generated user data are consistent with the newUserData
interface in theuser.model.ts
file.Additional improvements: To ensure the user type is correctly stated, I added a new enum (
UserType
) and replaced all instances ofregular
andadmin
with this new enum.How to use it:
To test as a custom user, create headers with the
UserType.custom
parameter, e.g.In general, to explicitly state the user type for creating headers, use the new enum, e.g. instead of
createHeaders('admin')
now you have to usecreateHeaders(UserType.admin)
.Faker:
First install the faker library:
npm i @faker-js/faker
To use the faker, import it (I suggest importing only EN version to improve test performance):
Any other comments?
See the exemplary test
GET quiz questions endpoint tests › Returns 200 OK with authorization
to check, how it works.Before submitting Pull Request, I've ensured that:
kawqa-gad-playwright
project's git commit message format.