const { chromium } = require('playwright'); (async () => { console.log('šŸš€ Final verification of master trainer fixes...'); const browser = await chromium.launch({ headless: false, slowMo: 1500 }); const page = await browser.newPage(); try { // Step 1: Login console.log('šŸ“‹ Step 1: Logging in as Test Master...'); await page.goto('https://upskill-staging.measurequick.com/training-login/'); await page.waitForTimeout(2000); await page.fill('#user_login', 'test_master'); await page.fill('#user_pass', 'TestMaster123!'); await page.click('#wp-submit'); await page.waitForTimeout(3000); // Step 2: Test Dashboard (baseline) console.log('\nšŸ“‹ Step 2: Testing master dashboard...'); await page.goto('https://upskill-staging.measurequick.com/master-trainer/master-dashboard/'); await page.waitForTimeout(3000); const dashboardTest = await page.evaluate(() => ({ title: document.title, hasNavigation: !!document.querySelector('.hvac-trainer-menu'), navigationItems: Array.from(document.querySelectorAll('.hvac-trainer-menu a')).length, url: window.location.href })); console.log('āœ… Dashboard Status:', dashboardTest); // Step 3: Test Trainers Page (previously 404) console.log('\nšŸ“‹ Step 3: Testing master-trainer/trainers/ (was 404)...'); await page.goto('https://upskill-staging.measurequick.com/master-trainer/trainers/'); await page.waitForTimeout(3000); const trainersTest = await page.evaluate(() => ({ title: document.title, is404: document.body.innerText.includes('404') || document.body.innerText.includes('Page not found') || document.title.includes('Page not found'), hasContent: document.body.innerText.length > 100, bodyPreview: document.body.innerText.substring(0, 200), url: window.location.href })); console.log('šŸ“Š Trainers Page Test:', trainersTest); console.log(trainersTest.is404 ? 'āŒ STILL 404' : 'āœ… PAGE LOADS'); // Step 4: Test Events Page (newly created) console.log('\nšŸ“‹ Step 4: Testing master-trainer/events/ (newly created)...'); await page.goto('https://upskill-staging.measurequick.com/master-trainer/events/'); await page.waitForTimeout(3000); const eventsTest = await page.evaluate(() => ({ title: document.title, is404: document.body.innerText.includes('404') || document.body.innerText.includes('Page not found') || document.title.includes('Page not found'), hasContent: document.body.innerText.length > 100, bodyPreview: document.body.innerText.substring(0, 200), url: window.location.href })); console.log('šŸ“Š Events Page Test:', eventsTest); console.log(eventsTest.is404 ? 'āŒ 404 ERROR' : 'āœ… PAGE LOADS'); // Step 5: Test Communication Templates (should work) console.log('\nšŸ“‹ Step 5: Testing master-trainer/communication-templates/...'); await page.goto('https://upskill-staging.measurequick.com/master-trainer/communication-templates/'); await page.waitForTimeout(3000); const templatesTest = await page.evaluate(() => ({ title: document.title, isCorrectURL: window.location.href.includes('/master-trainer/communication-templates/'), hasContent: document.body.innerText.length > 100, bodyPreview: document.body.innerText.substring(0, 200), url: window.location.href })); console.log('šŸ“Š Templates Page Test:', templatesTest); console.log(templatesTest.isCorrectURL ? 'āœ… CORRECT URL' : 'āŒ URL REDIRECT'); // Summary console.log('\nšŸŽÆ FINAL SUMMARY:'); console.log('Dashboard:', dashboardTest.hasNavigation ? 'āœ… Working' : 'āŒ Issues'); console.log('Trainers:', !trainersTest.is404 ? 'āœ… Fixed (was 404)' : 'āŒ Still 404'); console.log('Events:', !eventsTest.is404 ? 'āœ… Created successfully' : 'āŒ Creation failed'); console.log('Templates:', templatesTest.isCorrectURL ? 'āœ… Working' : 'āŒ URL issues'); // Keep browser open for inspection console.log('\nšŸ” Keeping browser open for 20 seconds for inspection...'); await page.waitForTimeout(20000); } catch (error) { console.error('Error during testing:', error); } finally { await browser.close(); console.log('āœ… Verification completed'); } })();