const { chromium } = require('playwright'); async function validateTECDeployment() { console.log('šŸŽÆ TEC Enhanced Template Deployment Validation'); console.log('==============================================='); const browser = await chromium.launch({ headless: true }); const context = await browser.newContext(); const page = await context.newPage(); try { // Navigate directly to the TEC Community Events form without login first console.log('šŸ” Step 1: Testing public access to TEC form...'); await page.goto('https://upskill-staging.measurequick.com/events/network/add'); await page.waitForLoadState('networkidle'); // Check for login redirect or form presence const currentUrl = page.url(); console.log('šŸ“ Current URL after navigation:', currentUrl); if (currentUrl.includes('login') || currentUrl.includes('wp-login')) { console.log('šŸ” Login required - proceeding with authentication...'); // If redirected to login, handle login await page.fill('input[name="log"]', 'test_trainer'); await page.fill('input[name="pwd"]', 'TestTrainer123!'); await page.click('input[type="submit"]'); await page.waitForLoadState('networkidle'); // Navigate to form again after login await page.goto('https://upskill-staging.measurequick.com/events/network/add'); await page.waitForLoadState('networkidle'); } console.log('šŸ” Step 2: Validating enhanced template deployment...'); // Check for enhanced template indicators const enhancedIndicators = await page.locator('.hvac-success-indicator').count(); const enhancedForm = await page.locator('.hvac-tec-enhanced-form').count(); console.log('šŸ“‹ Enhanced Template Indicators:'); console.log(' Success Indicator:', enhancedIndicators > 0 ? 'āœ…' : 'āŒ'); console.log(' Enhanced Form:', enhancedForm > 0 ? 'āœ…' : 'āŒ'); // Check for basic TEC form const basicForm = await page.locator('#tribe-community-events').count(); const eventForm = await page.locator('form[id*="event"]').count(); const anyForm = await page.locator('form').count(); console.log('šŸ“‹ Form Presence:'); console.log(' TEC Community Form (#tribe-community-events):', basicForm > 0 ? 'āœ…' : 'āŒ'); console.log(' Event Form (any):', eventForm > 0 ? 'āœ…' : 'āŒ'); console.log(' Any Form:', anyForm > 0 ? 'āœ…' : 'āŒ'); if (anyForm > 0) { console.log('šŸ” Step 3: Checking for enhanced field sections...'); // Check for our specific enhanced fields from the partials const excerptField = await page.locator('.hvac-excerpt-field').count(); const categoriesField = await page.locator('.hvac-categories-field').count(); const featuredImageField = await page.locator('.hvac-featured-image-field').count(); const tagsField = await page.locator('.hvac-tags-field').count(); console.log('šŸ“‹ Enhanced Field Sections:'); console.log(' Excerpt Field (.hvac-excerpt-field):', excerptField > 0 ? 'āœ…' : 'āŒ'); console.log(' Categories Field (.hvac-categories-field):', categoriesField > 0 ? 'āœ…' : 'āŒ'); console.log(' Featured Image Field (.hvac-featured-image-field):', featuredImageField > 0 ? 'āœ…' : 'āŒ'); console.log(' Tags Field (.hvac-tags-field):', tagsField > 0 ? 'āœ…' : 'āŒ'); const totalFields = excerptField + categoriesField + featuredImageField + tagsField; const successRate = (totalFields / 4) * 100; console.log('šŸŽÆ Enhanced Fields Success Rate:', `${successRate}%`); if (successRate === 100) { console.log('šŸŽ‰ SUCCESS: 100% field population validation achieved!'); console.log('āœ… All enhanced template sections deployed and rendering correctly'); } else if (successRate >= 75) { console.log('āš ļø PARTIAL SUCCESS: Enhanced template deployed but some fields missing'); } else { console.log('āŒ DEPLOYMENT ISSUE: Enhanced fields not rendering properly'); } // Additional checks for template integration console.log('šŸ” Step 4: Additional template validation...'); // Check for standard TEC fields to ensure base functionality const titleField = await page.locator('input[name*="title"], input[id*="title"]').count(); const contentField = await page.locator('textarea[name*="content"], textarea[id*="content"]').count(); const dateField = await page.locator('input[name*="date"], input[id*="date"]').count(); console.log('šŸ“‹ Standard TEC Fields:'); console.log(' Title Field:', titleField > 0 ? 'āœ…' : 'āŒ'); console.log(' Content Field:', contentField > 0 ? 'āœ…' : 'āŒ'); console.log(' Date Field:', dateField > 0 ? 'āœ…' : 'āŒ'); const baseFieldsWorking = titleField > 0 && contentField > 0; console.log('šŸ”§ Base Template Integration:', baseFieldsWorking ? 'āœ…' : 'āŒ'); return { success: successRate === 100, successRate: successRate, enhancedFields: totalFields, baseFieldsWorking: baseFieldsWorking, templateDeployed: basicForm > 0 || eventForm > 0 }; } else { console.log('āŒ CRITICAL: No forms found on the page'); // Check if we're on the right page const pageContent = await page.content(); const hasEvents = pageContent.includes('event') || pageContent.includes('Event'); const hasCommunity = pageContent.includes('community') || pageContent.includes('Community'); console.log('šŸ“‹ Page Content Analysis:'); console.log(' Contains "event/Event":', hasEvents ? 'āœ…' : 'āŒ'); console.log(' Contains "community/Community":', hasCommunity ? 'āœ…' : 'āŒ'); console.log(' Page length:', pageContent.length, 'characters'); return { success: false, successRate: 0, enhancedFields: 0, baseFieldsWorking: false, templateDeployed: false, pageAnalysis: { hasEvents, hasCommunity, contentLength: pageContent.length } }; } } catch (error) { console.error('āŒ Validation failed:', error.message); return { success: false, error: error.message }; } finally { await browser.close(); } } // Run the validation validateTECDeployment().then(result => { console.log('\nšŸŽÆ FINAL VALIDATION RESULTS:'); console.log('=============================='); console.log('Success:', result.success ? 'āœ…' : 'āŒ'); console.log('Success Rate:', result.successRate + '%'); console.log('Enhanced Fields:', result.enhancedFields + '/4'); console.log('Base Template Working:', result.baseFieldsWorking ? 'āœ…' : 'āŒ'); console.log('Template Deployed:', result.templateDeployed ? 'āœ…' : 'āŒ'); if (result.success) { console.log('\nšŸŽ‰ DEPLOYMENT VALIDATION COMPLETE!'); console.log('āœ… Enhanced TEC template fully functional'); console.log('āœ… 100% field population success rate achieved'); console.log('āœ… Ready for production deployment'); } else { console.log('\nāš ļø DEPLOYMENT VALIDATION ISSUES DETECTED'); console.log('āŒ Further investigation required'); if (result.error) { console.log('Error:', result.error); } } });