- Added hvac_master_trainer role with special capabilities: * view_master_dashboard * view_all_trainer_data * manage_google_sheets_integration - Created Master Dashboard page and template: * System overview with 6 key statistics (events, trainers, revenue) * Trainer performance analytics table * All events management with filtering * System-wide data aggregation across all trainers - Implemented comprehensive access control: * Master trainers and administrators can access * Regular trainers denied with proper error handling * Non-logged users redirected to login - Added data aggregation class (HVAC_Master_Dashboard_Data): * Direct database queries bypass TEC trainer filters * Aggregates events, tickets, and revenue across all users * Methods for total events, trainer stats, and events data - Enhanced template loading and shortcode registration: * Added [hvac_master_dashboard] shortcode * Integrated master dashboard template loading * Uses harmonized CSS framework for consistent styling - Created comprehensive Playwright test suite: * Tests administrator and trainer access * Verifies access control and error handling * Validates data display and UI rendering * Includes visual verification with screenshots 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			113 lines
		
	
	
		
			No EOL
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			113 lines
		
	
	
		
			No EOL
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { test, expect } from '@playwright/test';
 | |
| import { STAGING_URL } from './config/staging-config';
 | |
| 
 | |
| /**
 | |
|  * Simple Master Dashboard test to verify functionality
 | |
|  */
 | |
| 
 | |
| test.describe('Master Dashboard Simple Test', () => {
 | |
|   
 | |
|   test('Direct Master Dashboard access with admin user', async ({ page }) => {
 | |
|     test.setTimeout(60000);
 | |
|     
 | |
|     // Navigate to WordPress login page directly
 | |
|     await page.goto('https://upskill-staging.measurequick.com/wp-login.php');
 | |
|     
 | |
|     // Use admin credentials - these should work
 | |
|     await page.fill('#user_login', 'upskilldevadmin');
 | |
|     await page.fill('#user_pass', 'Uberrxmprk@321');
 | |
|     await page.click('#wp-submit');
 | |
|     
 | |
|     // Wait for login to complete
 | |
|     await page.waitForLoadState('networkidle');
 | |
|     
 | |
|     // Take screenshot after login
 | |
|     await page.screenshot({ 
 | |
|       path: `test-results/screenshots/admin-after-login-${Date.now()}.png`,
 | |
|       fullPage: true 
 | |
|     });
 | |
|     
 | |
|     // Navigate directly to master dashboard
 | |
|     await page.goto('https://upskill-staging.measurequick.com/master-dashboard/');
 | |
|     await page.waitForLoadState('networkidle');
 | |
|     
 | |
|     // Take screenshot of master dashboard
 | |
|     await page.screenshot({ 
 | |
|       path: `test-results/screenshots/master-dashboard-final-${Date.now()}.png`,
 | |
|       fullPage: true 
 | |
|     });
 | |
|     
 | |
|     // Check what we see
 | |
|     const title = await page.title();
 | |
|     console.log('Page title:', title);
 | |
|     
 | |
|     const h1Elements = await page.locator('h1').count();
 | |
|     console.log('Number of h1 elements:', h1Elements);
 | |
|     
 | |
|     if (h1Elements > 0) {
 | |
|       const h1Text = await page.locator('h1').first().textContent();
 | |
|       console.log('First h1 text:', h1Text);
 | |
|     }
 | |
|     
 | |
|     // Look for dashboard content
 | |
|     const dashboardStats = await page.locator('.hvac-dashboard-stats, .dashboard-stats, .stats-grid').count();
 | |
|     console.log('Dashboard stats sections found:', dashboardStats);
 | |
|     
 | |
|     // Check for master dashboard specific content
 | |
|     const systemOverview = await page.locator('text=System Overview').count();
 | |
|     console.log('System Overview text found:', systemOverview);
 | |
|     
 | |
|     // Verify we're not on a login or error page
 | |
|     const loginForm = await page.locator('#loginform').count();
 | |
|     expect(loginForm).toBe(0);
 | |
|     
 | |
|     // Expect to find some dashboard content
 | |
|     expect(h1Elements).toBeGreaterThan(0);
 | |
|   });
 | |
|   
 | |
|   test('Check master trainer user capabilities', async ({ page }) => {
 | |
|     test.setTimeout(60000);
 | |
|     
 | |
|     // Login as master trainer with SSH to check capabilities
 | |
|     const checkCapabilities = `
 | |
|       wp user meta get master_trainer wp_capabilities --format=json | jq .
 | |
|       wp user list --role=hvac_master_trainer --fields=ID,user_login,display_name
 | |
|       wp cap list hvac_master_trainer
 | |
|     `;
 | |
|     
 | |
|     console.log('Checking master trainer capabilities via SSH...');
 | |
|     
 | |
|     // Navigate to login page
 | |
|     await page.goto('https://upskill-staging.measurequick.com/wp-login.php');
 | |
|     
 | |
|     // Try logging in as master trainer
 | |
|     await page.fill('#user_login', 'master_trainer');
 | |
|     await page.fill('#user_pass', 'MasterTrainer#2025!');
 | |
|     await page.click('#wp-submit');
 | |
|     
 | |
|     await page.waitForLoadState('networkidle');
 | |
|     
 | |
|     // Check where we ended up
 | |
|     const currentUrl = page.url();
 | |
|     console.log('Current URL after login:', currentUrl);
 | |
|     
 | |
|     await page.screenshot({ 
 | |
|       path: `test-results/screenshots/master-trainer-login-result-${Date.now()}.png`,
 | |
|       fullPage: true 
 | |
|     });
 | |
|     
 | |
|     // If login successful, try to access master dashboard
 | |
|     if (!currentUrl.includes('wp-login')) {
 | |
|       await page.goto('https://upskill-staging.measurequick.com/master-dashboard/');
 | |
|       await page.waitForLoadState('networkidle');
 | |
|       
 | |
|       const finalUrl = page.url();
 | |
|       console.log('Final URL after navigation:', finalUrl);
 | |
|       
 | |
|       await page.screenshot({ 
 | |
|         path: `test-results/screenshots/master-trainer-dashboard-attempt-${Date.now()}.png`,
 | |
|         fullPage: true 
 | |
|       });
 | |
|     }
 | |
|   });
 | |
| }); |