# Comprehensive Testing Plan for New Trainer Features

## Overview
This document outlines the comprehensive testing plan for the major registration refactor and new trainer management pages implemented on July 30, 2025.

## Features to Test

### 1. Registration Form Refactor
- Application Details moved to Personal Information section
- Business Information renamed to Training Organization Information
- Organization Logo upload (required field)
- Headquarters location fields
- Conditional Training Venue Information section

### 2. Training Venues Management
- Venues List page (/trainer/venue/list)
- Manage Venue page (/trainer/venue/manage)
- CRUD operations
- The Events Calendar integration

### 3. Trainer Profile System
- Profile View page (/trainer/profile)
- Profile Edit page (/trainer/profile/edit)
- Photo upload functionality
- Stats and certifications display

### 4. Training Organizers Management
- Organizers List page (/trainer/organizer/list)
- Manage Organizer page (/trainer/organizer/manage)
- Logo upload and headquarters tracking
- TEC organizer integration

## Testing Approach

### Manual Testing Checklist

#### Registration Form
- [ ] Access registration page and verify new layout
- [ ] Verify Application Details appears in Personal Information section
- [ ] Verify Business Information is renamed to Training Organization Information
- [ ] Test Organization Logo upload (required validation)
- [ ] Test Headquarters fields (City, State/Province, Country)
- [ ] Test conditional venue fields (show/hide based on radio selection)
- [ ] Test venue name auto-population
- [ ] Test form submission with all fields
- [ ] Verify data persistence after submission

#### Venues Management
- [ ] Access venues list page as trainer
- [ ] Test search/filter functionality
- [ ] Test pagination
- [ ] Create new venue with all fields
- [ ] Edit existing venue
- [ ] Test venue deletion (with event check)
- [ ] Verify TEC venue post type integration
- [ ] Test validation for required fields
- [ ] Test phone number formatting
- [ ] Test URL validation

#### Profile Management
- [ ] Access profile view page
- [ ] Verify stats display (events, students, experience)
- [ ] Test profile edit functionality
- [ ] Upload profile photo
- [ ] Remove profile photo
- [ ] Test all field validations
- [ ] Test certifications list
- [ ] Verify data persistence

#### Organizers Management
- [ ] Access organizers list
- [ ] Test search functionality
- [ ] Create new organizer
- [ ] Upload organization logo
- [ ] Edit existing organizer
- [ ] Test deletion with event check
- [ ] Verify headquarters fields
- [ ] Test contact information fields

### E2E Playwright Tests

```typescript
// File: wordpress-dev/tests/e2e/trainer-features.spec.ts

import { test, expect } from '@playwright/test';
import { login } from './utils/auth';

test.describe('Trainer Registration Refactor', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/trainer-registration/');
  });

  test('should display refactored registration form', async ({ page }) => {
    // Test new section structure
    await expect(page.locator('h3:has-text("Personal Information")')).toBeVisible();
    await expect(page.locator('#application_details')).toBeVisible();
    
    // Test renamed section
    await expect(page.locator('h3:has-text("Training Organization Information")')).toBeVisible();
    
    // Test required org logo field
    await expect(page.locator('label:has-text("Organization Logo") .required')).toBeVisible();
    
    // Test headquarters fields
    await expect(page.locator('#hq_city')).toBeVisible();
    await expect(page.locator('#hq_state')).toBeVisible();
    await expect(page.locator('#hq_country')).toBeVisible();
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/registration-form-refactor.png', fullPage: true });
  });

  test('should show/hide venue fields conditionally', async ({ page }) => {
    // Test conditional venue section
    await page.click('input[name="create_venue"][value="yes"]');
    await expect(page.locator('#venue_details_wrapper')).toBeVisible();
    
    await page.click('input[name="create_venue"][value="no"]');
    await expect(page.locator('#venue_details_wrapper')).toBeHidden();
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/venue-conditional-fields.png' });
  });
});

test.describe('Venues Management', () => {
  test.beforeEach(async ({ page }) => {
    await login(page, 'test_trainer', 'password123');
  });

  test('should display venues list', async ({ page }) => {
    await page.goto('/trainer/venue/list/');
    
    await expect(page.locator('h1:has-text("Training Venues")')).toBeVisible();
    await expect(page.locator('.hvac-venues-table')).toBeVisible();
    await expect(page.locator('a:has-text("Add New Venue")')).toBeVisible();
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/venues-list.png', fullPage: true });
  });

  test('should create new venue', async ({ page }) => {
    await page.goto('/trainer/venue/manage/');
    
    // Fill venue form
    await page.fill('#venue_name', 'Test Training Center');
    await page.fill('#venue_address', '123 Main St');
    await page.fill('#venue_city', 'Test City');
    await page.fill('#venue_state', 'CA');
    await page.fill('#venue_zip', '12345');
    await page.selectOption('#venue_country', 'United States');
    
    // Take screenshot before submission
    await page.screenshot({ path: 'screenshots/venue-create-form.png' });
    
    // Submit form
    await page.click('button:has-text("Create Venue")');
    
    // Verify success message
    await expect(page.locator('.hvac-message-success')).toBeVisible();
    
    // Take screenshot after creation
    await page.screenshot({ path: 'screenshots/venue-created.png' });
  });
});

test.describe('Profile Management', () => {
  test.beforeEach(async ({ page }) => {
    await login(page, 'test_trainer', 'password123');
  });

  test('should display profile view', async ({ page }) => {
    await page.goto('/trainer/profile/');
    
    await expect(page.locator('h1:has-text("Trainer Profile")')).toBeVisible();
    await expect(page.locator('.hvac-profile-sidebar')).toBeVisible();
    await expect(page.locator('.hvac-profile-stats')).toBeVisible();
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/profile-view.png', fullPage: true });
  });

  test('should edit profile', async ({ page }) => {
    await page.goto('/trainer/profile/edit/');
    
    // Update profile fields
    await page.fill('#years_experience', '10');
    await page.fill('#certifications', 'NATE Certified\nEPA 608 Universal');
    await page.fill('#linkedin', 'https://linkedin.com/in/testtrainer');
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/profile-edit.png', fullPage: true });
    
    // Save changes
    await page.click('button:has-text("Save Changes")');
    
    // Verify success
    await expect(page.locator('.hvac-message-success')).toBeVisible();
  });
});

test.describe('Organizers Management', () => {
  test.beforeEach(async ({ page }) => {
    await login(page, 'test_trainer', 'password123');
  });

  test('should display organizers list', async ({ page }) => {
    await page.goto('/trainer/organizer/list/');
    
    await expect(page.locator('h1:has-text("Training Organizers")')).toBeVisible();
    await expect(page.locator('.hvac-organizers-table')).toBeVisible();
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/organizers-list.png', fullPage: true });
  });

  test('should create new organizer', async ({ page }) => {
    await page.goto('/trainer/organizer/manage/');
    
    // Fill organizer form
    await page.fill('#org_name', 'HVAC Training Institute');
    await page.fill('#hq_city', 'New York');
    await page.fill('#hq_state', 'NY');
    await page.selectOption('#hq_country', 'United States');
    await page.fill('#org_email', 'info@hvactraining.com');
    await page.fill('#org_website', 'https://hvactraining.com');
    
    // Take screenshot
    await page.screenshot({ path: 'screenshots/organizer-create.png', fullPage: true });
    
    // Submit
    await page.click('button:has-text("Create Organizer")');
    
    // Verify success
    await expect(page.locator('.hvac-message-success')).toBeVisible();
  });
});
```

### Performance Testing
- Test page load times for all new pages
- Test AJAX response times for form submissions
- Test with large datasets (100+ venues/organizers)

### Security Testing
- Verify nonce validation on all AJAX endpoints
- Test user permission checks
- Test SQL injection prevention
- Test XSS prevention in form inputs

### Compatibility Testing
- Test on different browsers (Chrome, Firefox, Safari, Edge)
- Test on mobile devices
- Test with different WordPress themes
- Test with/without The Events Calendar plugin

### Integration Testing
- Verify TEC venue post type integration
- Verify TEC organizer post type integration
- Test user meta integration
- Test media library integration for uploads

## Test Data Requirements

### Users
- Regular trainer account: test_trainer / password123
- Master trainer account: JoeMedosch@gmail.com / JoeTrainer2025@
- New registration test account

### Venues
- Create 5-10 test venues with various locations
- Test venues with/without all optional fields

### Organizers
- Create 3-5 test organizers
- Test with/without logos
- Various headquarters locations

### Events
- Create events using new venues/organizers
- Test venue/organizer assignment

## Automation Setup

1. Install test dependencies:
```bash
cd wordpress-dev
npm install
```

2. Run E2E tests:
```bash
npm run test:e2e -- trainer-features.spec.ts
```

3. View test results and screenshots:
```bash
ls screenshots/
```

## Success Criteria

1. All manual test cases pass
2. All E2E tests pass with screenshots verified
3. No JavaScript console errors
4. No PHP errors or warnings
5. Proper data persistence
6. Responsive design works on all devices
7. AJAX operations complete within 2 seconds
8. All validations work correctly
9. TEC integration functions properly
10. User permissions enforced correctly

## Risk Areas

1. File upload functionality (logos/photos)
2. TEC integration dependencies
3. AJAX error handling
4. Mobile responsiveness
5. Browser compatibility

## Rollback Plan

If critical issues are found:
1. Restore backup files (*.backup.php/js)
2. Revert git commit
3. Clear caches
4. Test core functionality