# Hayley Navigation Test Script Review Hints

## Context
These hints are for reviewing Playwright test scripts that navigate to Hayley applications and verify access permissions.

## Critical Requirements

### 1. Login Flow
- **MUST** login through Halo QA first (https://halo-qa.hyly.ai)
- **NEVER** attempt direct login on Hayley applications
- **ALWAYS** use LoginPage.goto() and LoginPage.login() methods

### 2. Navigation Patterns
- After Halo login, navigation to Hayley can be:
  - Through UI elements (menus, buttons, links)
  - Direct URL navigation to https://hayley.hyly.ai or similar
  - Through app-switcher components

### 3. Acceptable Selectors
✅ **Good Selectors:**
- `page.getByText('Dashboards', { exact: true }).first()`
- `page.getByRole('button', { name: 'text' })`
- `page.getByRole('link', { name: 'text' })`
- `page.locator('[data-testid="element"]')`

❌ **Avoid:**
- Complex CSS selectors without fallbacks
- XPath selectors
- Index-based selectors without context

### 4. Wait Strategies
✅ **Acceptable:**
- `waitForTimeout(2000-5000)` for page settling
- `waitForURL()` with patterns
- `waitFor({ state: 'visible' })` on elements

❌ **Never Use:**
- `waitForLoadState('networkidle')` - causes browser issues

### 5. Assertions
- Must verify URL contains expected paths
- Should check for absence of error messages
- Should verify key UI elements are visible
- Flexible enough to handle URL variations

### 6. Test Structure
- Must have `test.setTimeout(10 * 60 * 1000)` for long-running tests
- Should use `test.step()` for logical grouping
- Each step should have clear purpose

## Special Considerations for Hayley

1. **URL Variations**: Hayley URLs may vary:
   - https://hayley.hyly.ai
   - https://halo-qa.hyly.ai/hayley
   - https://hayley-report.hyly.ai
   
2. **Access Patterns**: Different users may see different interfaces:
   - Full Hayley access
   - Limited Hayley access
   - Combined Halo + Hayley access

3. **Fallback Strategies**: Good scripts should have multiple approaches:
   - Try UI navigation first
   - Fall back to direct URL if needed
   - Handle both scenarios gracefully

## Review Focus Areas

When reviewing, prioritize:
1. **Correctness**: Will the script actually work?
2. **Robustness**: Will it handle variations in the UI?
3. **Maintainability**: Is it easy to update when UI changes?
4. **Clarity**: Is the intent clear from reading the code?

## Acceptable Variations

The following patterns are all acceptable:
- Multiple selector strategies with try-catch
- Direct navigation after failed UI search
- Flexible URL verification using `includes()` or `match()`
- Comments explaining fallback strategies

## Red Flags to Reject

- Hardcoded credentials without env variables
- Login attempts on non-Halo applications
- Missing timeout configuration
- No error handling for navigation failures
- Overly rigid assertions that assume exact UI