update readme examples
This commit is contained in:
parent
ae6524bd4c
commit
bbd08dffb6
18
README.md
18
README.md
|
@ -81,16 +81,17 @@ An example of a simple test might look like this:
|
||||||
```typescript
|
```typescript
|
||||||
test('Successful login as user', async ({ page }) => {
|
test('Successful login as user', async ({ page }) => {
|
||||||
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
||||||
await expect.soft(page).toHaveTitle('Dashboard – IdHub');
|
await expect(page).toHaveTitle('Dashboard – IdHub');
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
The 'loginAs<User>' function, is defined in `steps.ts` as follow:
|
The 'loginAs<User>' function, is defined in `steps.ts` as follow:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export async function loginAsUser(page: Page, userEmail: string, url: string) {
|
export async function loginAsUser(page: Page, userEmail: string, url: string) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const loginPage = new LogInPage(page);
|
const loginPage = new LogInPage(page);
|
||||||
|
const dataProtectionPage = new DataProtectionPage(page);
|
||||||
|
|
||||||
await loginPage.visit(url);
|
await loginPage.visit(url);
|
||||||
await loginPage.login(userEmail, USER_K);
|
await loginPage.login(userEmail, USER_K);
|
||||||
|
|
||||||
|
@ -98,10 +99,10 @@ export async function loginAsUser(page: Page, userEmail: string, url: string) {
|
||||||
|
|
||||||
if (currentTitle === 'Data Protection – IdHub') {
|
if (currentTitle === 'Data Protection – IdHub') {
|
||||||
// Code to accept terms and conditions
|
// Code to accept terms and conditions
|
||||||
await page.click('#id_accept_privacy');
|
await dataProtectionPage.checkAcceptPrivacyCheckBox();
|
||||||
await page.click('#id_accept_legal');
|
await dataProtectionPage.checkAcceptCookiesCheckBox();
|
||||||
await page.click('#id_accept_cookies');
|
await dataProtectionPage.checkAcceptLegalCheckBox();
|
||||||
await page.click('a[type="button"]');
|
await dataProtectionPage.clickConfirmButton();
|
||||||
}
|
}
|
||||||
await expect(page).toHaveTitle('Dashboard – IdHub');
|
await expect(page).toHaveTitle('Dashboard – IdHub');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -110,7 +111,7 @@ export async function loginAsUser(page: Page, userEmail: string, url: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
The 'loginAs<User>' function in `steps.ts` use the 'LoginPage' page object, where are defined all the user related actions (e.g., visit, login, etc.).
|
The 'loginAs<User>' function in `steps.ts` use the 'LoginPage' page object, where are defined all the user related actions (e.g., visit, login, etc.) and the 'DataProtectionPage' page object where the interactions to accept or deny the data protection options are defined.
|
||||||
|
|
||||||
## Project Directory Structure
|
## Project Directory Structure
|
||||||
|
|
||||||
|
@ -163,6 +164,7 @@ end2end-tests:
|
||||||
```
|
```
|
||||||
|
|
||||||
**Adding reporting**: Uploads the `playwright-report/` directory as an artifact named `playwright-report`. This step always runs, even if previous steps fail, and the artifact is retained for 30 days before automatic deletion.
|
**Adding reporting**: Uploads the `playwright-report/` directory as an artifact named `playwright-report`. This step always runs, even if previous steps fail, and the artifact is retained for 30 days before automatic deletion.
|
||||||
|
```yaml
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
|
@ -170,6 +172,6 @@ end2end-tests:
|
||||||
path: playwright-report/
|
path: playwright-report/
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ test.describe('Admin login functionality', () => {
|
||||||
test('Navigate to Forgot password page from login page', async ({ page }) => {
|
test('Navigate to Forgot password page from login page', async ({ page }) => {
|
||||||
const loginPage = new LogInPage(page)
|
const loginPage = new LogInPage(page)
|
||||||
await loginPage.visitForgotPassword(URL_PASS_RESET)
|
await loginPage.visitForgotPassword(URL_PASS_RESET)
|
||||||
await expect.soft(page).toHaveTitle('Password reset – IdHub');
|
await expect(page).toHaveTitle('Password reset – IdHub');
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -24,14 +24,13 @@ test.describe('Admin login functionality', () => {
|
||||||
test.describe('User login functionality', () => {
|
test.describe('User login functionality', () => {
|
||||||
test('Successful login as user', async ({ page }) => {
|
test('Successful login as user', async ({ page }) => {
|
||||||
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
||||||
await expect.soft(page).toHaveTitle('Dashboard – IdHub');
|
await expect(page).toHaveTitle('Dashboard – IdHub');
|
||||||
//TODO: check email at the right corner
|
|
||||||
})
|
})
|
||||||
test('Unsuccessful login as user', async ({ page }) => {
|
test('Unsuccessful login as user', async ({ page }) => {
|
||||||
const loginPage = new LogInPage(page)
|
const loginPage = new LogInPage(page)
|
||||||
await loginPage.visit(URL_IDHUB);
|
await loginPage.visit(URL_IDHUB);
|
||||||
await loginPage.login(USER1_EMAIL, KO_USER_K)
|
await loginPage.login(USER1_EMAIL, KO_USER_K)
|
||||||
await expect.soft(loginPage.errorMessageIsValid()).toBeTruthy();
|
await expect(loginPage.errorMessageIsValid()).toBeTruthy();
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
Reference in New Issue