2024-03-04 19:57:54 +00:00
|
|
|
|
import { test, expect, Page } from '@playwright/test'
|
|
|
|
|
import { LogInPage } from '../src/page-objects/COMM_LoginPage.js'
|
|
|
|
|
import { loginAsAdmin, loginAsUser } from '../src/steps';
|
2024-03-07 10:52:37 +00:00
|
|
|
|
import { ADMIN_EMAIL, KO_ADMIN_K, KO_USER_K, URL_IDHUB, URL_PASS_RESET, USER1_EMAIL} from '../src/constants/env_constants.js';
|
2024-03-04 19:57:54 +00:00
|
|
|
|
|
|
|
|
|
test.describe('Admin login functionality', () => {
|
|
|
|
|
test('Successful login as admin', async ({ page }) => {
|
|
|
|
|
await loginAsAdmin(page, URL_IDHUB);
|
|
|
|
|
})
|
|
|
|
|
test('Unsuccessful login as admin', async ({ page }) => {
|
|
|
|
|
const loginPage = new LogInPage(page)
|
|
|
|
|
await loginPage.visit(URL_IDHUB);
|
|
|
|
|
await loginPage.login(ADMIN_EMAIL, KO_ADMIN_K)
|
2024-03-08 22:38:18 +00:00
|
|
|
|
expect(loginPage.errorMessageIsValid()).toBeTruthy();
|
2024-03-04 19:57:54 +00:00
|
|
|
|
})
|
|
|
|
|
test('Navigate to Forgot password page from login page', async ({ page }) => {
|
|
|
|
|
const loginPage = new LogInPage(page)
|
|
|
|
|
await loginPage.visitForgotPassword(URL_PASS_RESET)
|
|
|
|
|
await expect.soft(page).toHaveTitle('Password reset – IdHub');
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test.describe('User login functionality', () => {
|
|
|
|
|
test('Successful login as user', async ({ page }) => {
|
|
|
|
|
await loginAsUser(page, USER1_EMAIL, URL_IDHUB);
|
|
|
|
|
await expect.soft(page).toHaveTitle('Dashboard – IdHub');
|
|
|
|
|
//TODO: check email at the right corner
|
|
|
|
|
})
|
|
|
|
|
test('Unsuccessful login as user', async ({ page }) => {
|
|
|
|
|
const loginPage = new LogInPage(page)
|
|
|
|
|
await loginPage.visit(URL_IDHUB);
|
|
|
|
|
await loginPage.login(USER1_EMAIL, KO_USER_K)
|
|
|
|
|
await expect.soft(loginPage.errorMessageIsValid()).toBeTruthy();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|