# Export and Download Test Review Hints

## Context
These hints are for reviewing Playwright test scripts that handle various export and download functionalities, including dashboard exports, PDF downloads, and table explorer CSV exports.

## Test Categories

### 1. Dashboard Export (DASH-006)
- Exporting dashboard content to PDF
- Using Share button workflow
- Handling export settings

### 2. Dashboard PDF Download
- Direct PDF downloads of dashboards
- PDF quality settings
- Download verification

### 3. Table Explorer CSV Export
- CSV exports from table explorer
- Data formatting
- File download handling

## Critical Requirements

### 1. Required Page Objects
✅ **Required Imports:**
```typescript
import { test, expect } from '@playwright/test';
import { LoginPage } from '../../../../pages/login.page';
import { DashboardMainPage } from '../../../../pages/dashboard-main.page';
import { WidgetsPage } from '../../../../pages/widgets.page';
import { DashboardExportPage } from '../../../../pages/dashboard-export.page';
import * as dotenv from 'dotenv';

// Initialize all needed page objects
const loginPage = new LoginPage(page);
const dashboardPage = new DashboardMainPage(page);
const widgetsPage = new WidgetsPage(page);
const exportPage = new DashboardExportPage(page);
```

### 2. Export Workflow Pattern
✅ **Correct Export Flow:**
```typescript
await test.step('Export Dashboard as PDF', async () => {
  const exportSuccess = await exportPage.exportDashboardAsPdf();
  expect(exportSuccess).toBeTruthy();
});
```

### 3. Pre-Export Requirements
✅ **Must Have Before Export:**
1. Dashboard must be created
2. At least one widget should be added (for content)
3. Dashboard should be in a saved/stable state

✅ **Typical Setup:**
```typescript
// Add widget for export content
await test.step('Add Widget for Export Content', async () => {
  await widgetsPage.clickSeeAllWidgets();
  await widgetsPage.selectTouredConversions();
  await widgetsPage.addFirstCard();
});
```

### 4. Export Button Access Pattern
Based on CLAUDE.md knowledge:
- **Export is accessed via Share button** on the top right
- **Only PDF export is available** (not Excel, PowerPoint, or Image)

✅ **Export Steps:**
1. Click Share button (top right)
2. Click "Download PDF" option (opens right side panel)
3. Click "Download" button in the right side panel
4. PDF file downloads automatically

### 5. Export Verification
✅ **Good Verification:**
```typescript
// Using page object method
const exportSuccess = await exportPage.exportDashboardAsPdf();
expect(exportSuccess).toBeTruthy();

// The page object should handle:
// - Clicking Share button
// - Selecting PDF option
// - Clicking Download in side panel
// - Verifying download initiated
```

### 6. Post-Export Actions
✅ **Typical Flow After Export:**
```typescript
// Rename and save dashboard after export
await test.step('Rename and Save Dashboard', async () => {
  await dashboardPage.renameDashboard(uniqueDashboardName);
  await expect(page.locator(`text="${uniqueDashboardName}"`).first()).toBeVisible({ timeout: 5000 });
  await dashboardPage.saveDashboard();
});
```

### 7. Test Identification
✅ **Good Practice:**
```typescript
test('Dashboard Export - Test ID: DASH-006', async ({ page }) => {
  // Test implementation
});

// Final verification with test details
await test.step('Final Verification', async () => {
  console.log('\n=== Test Summary ===');
  console.log('Test ID: DASH-006');
  console.log('Test Name: Dashboard Export');
  console.log('Priority: Medium');
  console.log(`✅ Test completed - Dashboard "${uniqueDashboardName}" exported successfully`);
});
```

## Special Considerations

### Export Limitations
- Only PDF export is currently available
- Excel, PowerPoint, and Image exports are NOT supported
- Export happens through Share button, not a dedicated Export button

### Download Handling
- Playwright should be configured to handle downloads
- The page object method should handle download verification
- File size validation (>0 bytes) is important

### Timing Considerations
- Export may take time for complex dashboards
- Allow sufficient timeout for PDF generation
- Side panel animations may require wait time

### Browser Configuration
- Browser should be configured to auto-download PDFs
- Download directory should be accessible
- No download dialogs should block the test

## Review Focus Areas

1. **Export Method**: Must use DashboardExportPage.exportDashboardAsPdf()
2. **Share Button**: Export accessed via Share button, not direct Export
3. **PDF Only**: Only PDF export should be tested
4. **Content Setup**: Dashboard should have content before export
5. **Verification**: Must verify export success
6. **Page Objects**: Must use appropriate page objects

## Acceptable Variations

- Different widgets added before export
- Various dashboard naming strategies
- Different ways to verify export success
- Additional logging for debugging

## Red Flags to Reject

1. Testing non-PDF export formats (Excel, PowerPoint, Image)
2. Looking for direct "Export" button instead of Share button
3. Missing DashboardExportPage usage
4. No verification of export success
5. Attempting export on empty dashboard
6. Missing proper test identification
7. No content added before export attempt

## Common Issues to Check

1. **Share Button Location**: Top right of dashboard
2. **Side Panel**: Must handle right side panel that opens
3. **Download Button**: Must click Download in the side panel
4. **PDF Validation**: Should verify PDF actually downloads