# Table Explorer CSV Export Test Hints

## Critical Selectors and Patterns

### Navigation to Table Explorer
```typescript
// MANDATORY: Long wait times for stability
await page.waitForTimeout(40000); // Initial stabilization
await page.waitForTimeout(30000); // Before clicking Table Explorer

// Table Explorer selection priority
1. page.getByRole('button', { name: 'Table Explorer' })  // Try button first
2. page.getByRole('radio', { name: 'Table Explorer' })   // Then radio
3. page.getByText('Table Explorer', { exact: true })     // Then text
```

### Occupancy Trends Navigation
```typescript
// Required steps in order
1. Click "Occupancy Trends" text (exact match)
2. Wait 2 seconds
3. Click "By Properties" text (exact match)
4. Wait 3 seconds for table to load
```

### Date Filter Configuration
```typescript
// CRITICAL: Close Table Explorer dialog first
await page.getByRole('button', { name: 'Table Explorer' }).click();
await page.waitForTimeout(3000);

// Then change date filter
await page.getByText('Last Quarter').click();
await page.getByText('Last Month', { exact: true }).click();
```

### CSV Export Methods (Try in Order)
```typescript
// Method 1: Share button approach
const shareButton = page.getByRole('button', { name: 'Share' });
await shareButton.click();
// Look for CSV option in dropdown

// Method 2: Direct export button
const exportButton = page.locator('button:has-text("Export")').first();

// Method 3: Download link
const downloadLink = page.locator('a[download], .download-link').first();
```

## Required Test Structure

### Test Configuration
- **MANDATORY**: `test.setTimeout(10 * 60 * 1000)` at top of test
- **REQUIRED**: Use page objects (LoginPage, DashboardMainPage)
- **CRITICAL**: Use environment variables for credentials

### Import Requirements
```typescript
import { test, expect } from '@playwright/test';
import { LoginPage } from '../../pages/login.page';
import { DashboardMainPage } from '../../pages/dashboard-main.page';
import * as dotenv from 'dotenv';
import * as fs from 'fs';
import * as path from 'path';
```

## Wait Time Requirements
- Initial page load: 40 seconds
- Before Table Explorer click: 30 seconds  
- After clicking Table Explorer: 5 seconds
- After expanding Occupancy Trends: 2 seconds
- After clicking By Properties: 3 seconds
- After closing dialog: 3 seconds
- After date filter change: 2 seconds

## Validation Steps
1. Verify table is visible after navigation
2. Count table rows to ensure data loaded
3. Check CSV file download completed
4. Verify file size > 0
5. Confirm CSV contains commas and multiple lines

## Common Issues to Avoid
- **DON'T** rush through navigation - use long wait times
- **DON'T** skip closing Table Explorer dialog before date filter
- **DON'T** assume single export method - try multiple approaches
- **DON'T** forget to clean up downloaded test files

## Expected Flow
1. Login → Dashboard loads
2. Wait 40 seconds for stabilization
3. Click Table Explorer (try multiple selectors)
4. Expand Occupancy Trends
5. Click By Properties
6. Close Table Explorer dialog
7. Change date filter to Last Month
8. Export data as CSV (try multiple methods)
9. Verify download and clean up

## Success Criteria
- Table Explorer opens successfully
- Occupancy Trends data loads
- Date filter changes to Last Month
- CSV file downloads with size > 0
- File contains comma-separated data
- Test completes within 10 minutes