upskill-event-manager/scripts/verify-authenticated-pages.js
bengizmo 993a820a84 feat: Add comprehensive development artifacts to repository
- Add 26 documentation files including test reports, deployment guides, and troubleshooting documentation
- Include 3 CSV data files for trainer imports and user registration tracking
- Add 43 JavaScript test files covering mobile optimization, Safari compatibility, and E2E testing
- Include 18 PHP utility files for debugging, geocoding, and data analysis
- Add 12 shell scripts for deployment verification, user management, and database operations
- Update .gitignore with whitelist patterns for development files, documentation, and CSV data

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 12:26:11 -03:00

80 lines
No EOL
3.2 KiB
JavaScript

const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
// Create screenshots directory
const screenshotDir = path.join(__dirname, '../screenshots/authenticated-pages');
if (!fs.existsSync(screenshotDir)) {
fs.mkdirSync(screenshotDir, { recursive: true });
}
const baseUrl = 'https://upskill-staging.measurequick.com';
console.log('Logging in as test trainer...');
// Navigate to login page
await page.goto(baseUrl + '/training-login/', { waitUntil: 'networkidle' });
// Fill login form
await page.fill('input[name="log"]', 'test_trainer');
await page.fill('input[name="pwd"]', 'TestPass123!');
await page.click('input[type="submit"]');
// Wait for redirect
await page.waitForURL('**/trainer/dashboard/**', { timeout: 10000 }).catch(() => {
console.log('Did not redirect to dashboard - checking current page');
});
// Test authenticated pages
const testPages = [
{ name: 'trainer-dashboard', url: '/trainer/dashboard/', expectedContent: 'Welcome' },
{ name: 'certificate-reports', url: '/trainer/certificate-reports/', expectedContent: 'Certificate Reports' },
{ name: 'generate-certificates', url: '/trainer/generate-certificates/', expectedContent: 'Generate Certificates' },
{ name: 'email-attendees', url: '/trainer/email-attendees/', expectedContent: 'Email Attendees' },
{ name: 'trainer-profile', url: '/trainer/my-profile/', expectedContent: 'Profile' }
];
console.log('\nTesting authenticated pages...');
for (const testPage of testPages) {
console.log(`\nTesting ${testPage.name}...`);
try {
await page.goto(baseUrl + testPage.url, { waitUntil: 'networkidle' });
// Check for expected content
const bodyText = await page.textContent('body');
if (bodyText.includes(testPage.expectedContent)) {
console.log(`${testPage.name} - Content found: "${testPage.expectedContent}"`);
} else {
console.log(`${testPage.name} - Expected content not found`);
}
// Check if page has sidebar (indicates template issue)
const hasSidebar = await page.locator('.widget-area, .sidebar, #secondary').count();
if (hasSidebar > 0) {
console.log(`⚠️ ${testPage.name} - Has sidebar (possible template issue)`);
} else {
console.log(`${testPage.name} - No sidebar (template working)`);
}
// Take screenshot
await page.screenshot({
path: path.join(screenshotDir, `${testPage.name}.png`),
fullPage: true
});
} catch (error) {
console.log(`${testPage.name} - Error: ${error.message}`);
}
}
console.log('\nVerification complete. Screenshots saved to:', screenshotDir);
await browser.close();
})();