import { test, expect, Page } from '@playwright/test' import { LogInPage } from '../src/page-objects/COMM_LoginPage.js' import { loginAsAdmin, loginAsUser } from '../src/steps'; import { ADMIN_EMAIL, KO_ADMIN_K, KO_USER_K, URL_IDHUB, URL_PASS_RESET, USER1_EMAIL} from '../src/constants/env_constants.js'; 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) expect(loginPage.errorMessageIsValid()).toBeTruthy(); }) test('Navigate to Forgot password page from login page', async ({ page }) => { const loginPage = new LogInPage(page) await loginPage.visitForgotPassword(URL_PASS_RESET) await expect(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(page).toHaveTitle('Dashboard – IdHub'); }) 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(loginPage.errorMessageIsValid()).toBeTruthy(); }) })