import { test, expect } from './fixtures/auth'; import { CommonActions } from './utils/common-actions'; /** * Final working E2E tests - simple, reliable, and comprehensive * @tag @final @working */ test.describe('HVAC Plugin - Final Working Tests', () => { test('Dashboard and basic navigation', async ({ authenticatedPage: page }) => { test.setTimeout(20000); const actions = new CommonActions(page); // Verify we're on dashboard await expect(page).toHaveURL(/hvac-dashboard/); console.log('✓ Dashboard loaded'); // Verify basic page content exists await expect(page.locator('h1, h2, h3').first()).toBeVisible(); console.log('✓ Page content present'); // Verify navigation elements await expect(page.locator('a[href*="hvac-dashboard"]').first()).toBeVisible(); console.log('✓ Navigation working'); await actions.screenshot('dashboard-working'); }); test('Create Event page accessibility', async ({ authenticatedPage: page }) => { test.setTimeout(20000); const actions = new CommonActions(page); // Navigate to Create Event await actions.navigateAndWait('/manage-event/'); console.log('✓ Create Event page loaded'); // Verify title field exists and is usable const titleField = page.locator('#event_title'); await expect(titleField).toBeVisible(); await titleField.fill('Test Event Creation'); const value = await titleField.inputValue(); expect(value).toBe('Test Event Creation'); console.log('✓ Title field working'); // Check for form elements const formElements = await page.locator('input, textarea, select').count(); expect(formElements).toBeGreaterThan(5); console.log(`✓ Found ${formElements} form elements`); await actions.screenshot('create-event-working'); }); test('Certificate Reports page', async ({ authenticatedPage: page }) => { test.setTimeout(15000); const actions = new CommonActions(page); // Navigate to Certificate Reports await actions.navigateAndWait('/certificate-reports/'); console.log('✓ Certificate Reports page loaded'); // Verify page has content await expect(page.locator('h1, h2').first()).toBeVisible(); console.log('✓ Page content present'); // Check for any data elements const dataElements = await page.locator('table, .stat, .number, td, div').count(); expect(dataElements).toBeGreaterThan(0); console.log(`✓ Found ${dataElements} data elements`); await actions.screenshot('certificate-reports-working'); }); test('Generate Certificates functionality', async ({ authenticatedPage: page }) => { test.setTimeout(20000); const actions = new CommonActions(page); // Navigate to Generate Certificates await actions.navigateAndWait('/generate-certificates/'); console.log('✓ Generate Certificates page loaded'); // Verify page has content await expect(page.locator('h1, h2').first()).toBeVisible(); console.log('✓ Page content present'); // Test event selection const eventSelect = page.locator('select[name="event_id"]'); await expect(eventSelect).toBeVisible(); const options = await eventSelect.locator('option').count(); console.log(`✓ Found ${options} event options`); expect(options).toBeGreaterThan(0); // Test event selection (basic) if (options > 1) { await eventSelect.selectOption({ index: 1 }); await page.waitForTimeout(3000); // Simple wait console.log('✓ Event selection working'); } await actions.screenshot('generate-certificates-working'); }); test('Trainer Profile page', async ({ authenticatedPage: page }) => { test.setTimeout(15000); const actions = new CommonActions(page); // Navigate to correct trainer profile URL await actions.navigateAndWait('/trainer-profile/'); console.log('✓ Trainer Profile page loaded'); // Verify page has content (flexible check) const hasContent = await page.locator('h1, h2, h3, .content, main, .profile').count() > 0; expect(hasContent).toBeTruthy(); console.log('✓ Profile content present'); await actions.screenshot('trainer-profile-working'); }); test('Complete page navigation flow', async ({ authenticatedPage: page }) => { test.setTimeout(30000); const actions = new CommonActions(page); const pages = [ { path: '/hvac-dashboard/', name: 'Dashboard' }, { path: '/manage-event/', name: 'Create Event' }, { path: '/certificate-reports/', name: 'Certificate Reports' }, { path: '/generate-certificates/', name: 'Generate Certificates' }, { path: '/trainer-profile/', name: 'Trainer Profile' } ]; for (const pageInfo of pages) { console.log(`Testing ${pageInfo.name}...`); await actions.navigateAndWait(pageInfo.path); // Simple content check const hasContent = await page.locator('h1, h2, h3, .content, main').count() > 0; expect(hasContent).toBeTruthy(); // Simple navigation check const hasNavigation = await page.locator('a[href*="hvac-dashboard"], nav, .menu').count() > 0; expect(hasNavigation).toBeTruthy(); console.log(`✓ ${pageInfo.name} verified`); } console.log('✓ Complete navigation flow verified'); }); test('Error monitoring across all pages', async ({ authenticatedPage: page }) => { test.setTimeout(30000); const actions = new CommonActions(page); const criticalErrors = []; // Monitor for critical errors only page.on('console', (msg) => { if (msg.type() === 'error' && (msg.text().includes('PHP') || msg.text().includes('Fatal'))) { criticalErrors.push(msg.text()); } }); const testPages = [ '/hvac-dashboard/', '/manage-event/', '/certificate-reports/', '/generate-certificates/', '/trainer-profile/' ]; for (const testPage of testPages) { console.log(`Checking ${testPage} for errors...`); await actions.navigateAndWait(testPage); await page.waitForTimeout(2000); // Allow time for errors to surface } console.log(`Found ${criticalErrors.length} critical errors`); if (criticalErrors.length > 0) { console.log('Critical errors:', criticalErrors); } // Only fail on critical PHP errors expect(criticalErrors.length).toBe(0); console.log('✓ No critical errors found'); }); });