import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
  await page.goto('https://opensource-demo.orangehrmlive.com/', { timeout: 60000 });
});


test('Login with valid credentials', async ({ page }) => {
  await page.getByPlaceholder('Username').fill('Admin');
  await page.getByPlaceholder('Password').fill('admin123');
  await page.getByRole('button', { name: 'Login' }).click();
  await expect(page).toHaveURL(/dashboard/);
});

test('Login with invalid credentials', async ({ page }) => {
  await page.getByPlaceholder('Username').fill('fakeuser');
  await page.getByPlaceholder('Password').fill('fakepass');
  await page.getByRole('button', { name: 'Login' }).click();
  await expect(page.locator('.oxd-alert-content-text')).toContainText('Invalid credentials');
});

test('Error message on empty login', async ({ page }) => {
  await page.getByRole('button', { name: 'Login' }).click();
  await expect(page.locator('.oxd-input-field-error-message')).toHaveCount(2);
});
