import { Page } from '@playwright/test';
import { LoginPage } from '../pages/LoginPage';

/**
 * Helper function to login as a trainer
 * @param page Playwright Page object
 */
export async function loginAsTrainer(page: Page): Promise<void> {
  const loginPage = new LoginPage(page);
  await loginPage.navigate();
  await loginPage.login('trainer');
}

/**
 * Helper function to login as an admin trainer
 * @param page Playwright Page object
 */
export async function loginAsAdminTrainer(page: Page): Promise<void> {
  const loginPage = new LoginPage(page);
  await loginPage.navigate();
  await loginPage.login('adminTrainer');
}

/**
 * Helper function to login with custom credentials
 * @param page Playwright Page object
 * @param username Username to login with
 * @param password Password to login with
 */
export async function loginWithCredentials(page: Page, username: string, password: string): Promise<void> {
  const loginPage = new LoginPage(page);
  await loginPage.navigate();
  await loginPage.loginWithCredentials(username, password);
}