# Login Test Script Review Hints

## Context
These hints are for reviewing Playwright test scripts that handle authentication and login flows in the Halo QA application.

## Critical Requirements

### 1. Login URL and Navigation
✅ **MUST Use:**
```typescript
// Always use LoginPage.goto() for initial navigation
await loginPage.goto();
// This navigates to https://halo-qa.hyly.ai
```

❌ **NEVER:**
```typescript
// Don't use page.goto() directly
await page.goto('https://halo-qa.hyly.ai');

// Don't navigate to login pages of other apps
await page.goto('https://hayley.hyly.ai/login');
await page.goto('https://accounts-qa.hyly.app');
```

### 2. Credentials Management
✅ **Acceptable Patterns:**

**Option 1: Environment Variables with Fallback (BEST)**
```typescript
await loginPage.login(
  process.env.TEST_EMAIL || 'cdp@hy.ly',
  process.env.TEST_PASSWORD || 'BMy2L1rRXZlkKoTU7'
);
```

**Option 2: Environment Variables with dotenv**
```typescript
import * as dotenv from 'dotenv';
dotenv.config();
await loginPage.login(process.env.TEST_EMAIL!, process.env.TEST_PASSWORD!);
```

**Option 3: Hardcoded (if consistent across all tests)**
```typescript
await loginPage.login('cdp@hy.ly', 'BMy2L1rRXZlkKoTU7');
```

### 3. Current Valid Credentials
- **Email**: `cdp@hy.ly`
- **Password**: `BMy2L1rRXZlkKoTU7` (Updated: 2025-08-19)
- **Old Password**: `rnJi75ESFutATsbDN` (Still acceptable in existing tests)

### 4. Login Verification
✅ **Required Verifications:**
```typescript
// Wait for dashboard load
await dashboardPage.waitForDashboardLoad();

// Verify login success
const isOnDashboard = await dashboardPage.verifyOnDashboardPage();
expect(isOnDashboard).toBeTruthy();

// Optional: Verify URL
expect(page.url()).toContain('halo-qa.hyly.ai/copilot/report');
```

### 5. Page Object Requirements
✅ **Required Structure:**
```typescript
import { LoginPage } from '../pages/login.page';
import { DashboardMainPage } from '../pages/dashboard-main.page';

const loginPage = new LoginPage(page);
const dashboardPage = new DashboardMainPage(page);
```

### 6. Test Step Organization
✅ **Proper Structure:**
```typescript
await test.step('Navigate and Login', async () => {
  await loginPage.goto();
  await loginPage.login(email, password);
});

await test.step('Verify Login Success', async () => {
  await dashboardPage.waitForDashboardLoad();
  const isOnDashboard = await dashboardPage.verifyOnDashboardPage();
  expect(isOnDashboard).toBeTruthy();
});
```

### 7. Error Handling
✅ **Good Practices:**
- Use page object methods that include built-in error handling
- Set appropriate timeouts for login operations
- Include verification steps after login

❌ **Avoid:**
- Raw selector-based login without page objects
- No verification after login
- Missing error scenarios

### 8. Multi-App Navigation
✅ **Correct Pattern for Other Apps:**
```typescript
// Step 1: Always login to Halo QA first
await loginPage.goto();
await loginPage.login(credentials);

// Step 2: Then navigate to other apps
await page.goto('https://hayley.hyly.ai/home');
await page.waitForTimeout(3000);
```

❌ **Never:**
```typescript
// Don't try to login directly on other apps
await page.goto('https://hayley.hyly.ai');
await page.locator('input[type="email"]').fill('...');
```

## Special Considerations

### Session Management
- Login session should persist across navigation
- No need to re-login when navigating within the same app
- Different apps may require separate authentication

### Timeout Handling
- Login operations may take longer on slow builds
- Always set test timeout: `test.setTimeout(10 * 60 * 1000);`
- Page object methods should have appropriate internal timeouts

### URL Variations After Login
Acceptable post-login URLs:
- `https://halo-qa.hyly.ai/copilot/report`
- `https://halo-qa.hyly.ai/dashboards`
- `https://halo-qa.hyly.ai/home`

## Review Focus Areas

1. **Login Method**: Must use LoginPage.goto() and LoginPage.login()
2. **Credentials**: Check for updated passwords and proper env variable usage
3. **Verification**: Must verify login success before proceeding
4. **Page Objects**: Must use LoginPage and DashboardMainPage
5. **Test Structure**: Should use test.step() for organization

## Acceptable Variations

- Different methods of handling environment variables
- Various post-login verification approaches
- Different timeout values (as long as reasonable)
- Additional logging for debugging

## Red Flags to Reject

1. Direct navigation to login pages without LoginPage.goto()
2. Attempting to login on non-Halo applications
3. Missing login verification
4. Hardcoded credentials without any fallback or env variable option
5. Using outdated passwords without checking current ones
6. No test timeout configuration
7. Raw selector-based login instead of page objects