- Create consistent test structure with latest Playwright version (1.52.0) - Implement trainer-journey-harmonized.test.ts that works with updated Playwright - Fix package.json to ensure consistent dependencies - Add certificate-basic.spec.ts that avoids framework compatibility issues - Create run-advanced-tests.sh script with enhanced configuration options - Add comprehensive documentation for the harmonized testing approach 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			119 lines
		
	
	
		
			No EOL
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			119 lines
		
	
	
		
			No EOL
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { test, expect } from '@playwright/test';
 | |
| 
 | |
| // Constants
 | |
| const STAGING_URL = 'https://wordpress-974670-5399585.cloudwaysapps.com';
 | |
| const LOGIN_URL = `${STAGING_URL}/community-login/`;
 | |
| const DASHBOARD_URL = `${STAGING_URL}/hvac-dashboard/`;
 | |
| const USERNAME = 'test_trainer';
 | |
| const PASSWORD = 'Test123!';
 | |
| 
 | |
| // Test: Login and navigate to Generate Certificates page
 | |
| test('Should navigate to Generate Certificates page', async ({ page }) => {
 | |
|   // Login
 | |
|   await page.goto(LOGIN_URL);
 | |
|   await page.fill('#user_login', USERNAME);
 | |
|   await page.fill('#user_pass', PASSWORD);
 | |
|   await page.click('#wp-submit');
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Verify login was successful
 | |
|   await expect(page).toHaveURL(/hvac-dashboard/);
 | |
|   
 | |
|   // Navigate to dashboard first
 | |
|   await page.goto(DASHBOARD_URL);
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Look for Generate Certificates link
 | |
|   const generateLink = page.locator('a:has-text("Generate Certificates")');
 | |
|   await expect(generateLink).toBeVisible();
 | |
|   
 | |
|   // Click the link
 | |
|   await generateLink.click();
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Check page title
 | |
|   const title = await page.title();
 | |
|   expect(title).toContain('Generate Certificates');
 | |
|   
 | |
|   // Check for event dropdown
 | |
|   const eventDropdown = page.locator('#event_id');
 | |
|   await expect(eventDropdown).toBeVisible();
 | |
|   
 | |
|   // Count options to verify dropdown is populated
 | |
|   const optionCount = await page.locator('#event_id option').count();
 | |
|   expect(optionCount).toBeGreaterThan(1);
 | |
| });
 | |
| 
 | |
| // Test: Login and navigate to Certificate Reports page
 | |
| test('Should navigate to Certificate Reports page', async ({ page }) => {
 | |
|   // Login
 | |
|   await page.goto(LOGIN_URL);
 | |
|   await page.fill('#user_login', USERNAME);
 | |
|   await page.fill('#user_pass', PASSWORD);
 | |
|   await page.click('#wp-submit');
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Verify login was successful
 | |
|   await expect(page).toHaveURL(/hvac-dashboard/);
 | |
|   
 | |
|   // Navigate to dashboard first
 | |
|   await page.goto(DASHBOARD_URL);
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Look for Certificate Reports link
 | |
|   const reportsLink = page.locator('a:has-text("Certificate Reports")');
 | |
|   await expect(reportsLink).toBeVisible();
 | |
|   
 | |
|   // Click the link
 | |
|   await reportsLink.click();
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Check page title
 | |
|   const title = await page.title();
 | |
|   expect(title).toContain('Certificate Reports');
 | |
|   
 | |
|   // Check for filter form
 | |
|   const filterForm = page.locator('form.hvac-certificate-filters');
 | |
|   await expect(filterForm).toBeVisible();
 | |
| });
 | |
| 
 | |
| // Test: Filter certificates by event
 | |
| test('Should filter certificates by event', async ({ page }) => {
 | |
|   // Login
 | |
|   await page.goto(LOGIN_URL);
 | |
|   await page.fill('#user_login', USERNAME);
 | |
|   await page.fill('#user_pass', PASSWORD);
 | |
|   await page.click('#wp-submit');
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Navigate to Certificate Reports page
 | |
|   await page.goto(`${STAGING_URL}/certificate-reports/`);
 | |
|   await page.waitForLoadState('networkidle');
 | |
|   
 | |
|   // Check for filter form
 | |
|   const filterForm = page.locator('form.hvac-certificate-filters');
 | |
|   await expect(filterForm).toBeVisible();
 | |
|   
 | |
|   // Check if event filter exists
 | |
|   const eventFilter = page.locator('#filter_event');
 | |
|   await expect(eventFilter).toBeVisible();
 | |
|   
 | |
|   // Get options count
 | |
|   const optionCount = await page.locator('#filter_event option').count();
 | |
|   
 | |
|   // Test different filter options
 | |
|   if (optionCount > 1) {
 | |
|     // Select the first non-empty option
 | |
|     await eventFilter.selectOption({ index: 1 });
 | |
|     
 | |
|     // Apply filter
 | |
|     const filterButton = page.locator('button[type="submit"]');
 | |
|     await filterButton.click();
 | |
|     await page.waitForLoadState('networkidle');
 | |
|     
 | |
|     // Log the filter results (can't guarantee there will be certificates)
 | |
|     const certificateItems = page.locator('.hvac-certificate-item');
 | |
|     const certificateCount = await certificateItems.count();
 | |
|     console.log(`Found ${certificateCount} certificates after filtering by event`);
 | |
|   }
 | |
| }); |