106 lines
4.1 KiB
JavaScript
106 lines
4.1 KiB
JavaScript
const { chromium } = require('playwright');
|
|
const path = require('path');
|
|
|
|
async function testMaintenancePages() {
|
|
const browser = await chromium.launch({ headless: false });
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
|
|
const baseDir = 'Z:\\Repos\\harborsmith\\website-mockups\\maintenance';
|
|
const pages = [
|
|
'maintenance-dashboard.html',
|
|
'maintenance-schedule.html',
|
|
'maintenance-documents.html',
|
|
'maintenance-reports.html',
|
|
'maintenance-invoices.html'
|
|
];
|
|
|
|
console.log('Starting maintenance portal testing...\n');
|
|
|
|
for (const pageName of pages) {
|
|
const filePath = `file:///${baseDir}/${pageName}`;
|
|
console.log(`Testing: ${pageName}`);
|
|
|
|
try {
|
|
await page.goto(filePath, { waitUntil: 'networkidle' });
|
|
|
|
// Take screenshot
|
|
const screenshotPath = `Z:\\Repos\\harborsmith\\screenshot-${pageName.replace('.html', '')}.png`;
|
|
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
console.log(`Screenshot saved: ${screenshotPath}`);
|
|
|
|
// Get page title and basic info
|
|
const title = await page.title();
|
|
console.log(`Page title: ${title}`);
|
|
|
|
// Check for any console errors
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error') {
|
|
console.log(`Console error: ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
// Test interactive elements based on page
|
|
if (pageName === 'maintenance-dashboard.html') {
|
|
// Try to click on navigation items or cards
|
|
const navItems = await page.locator('nav a, .card, .btn').count();
|
|
console.log(`Found ${navItems} interactive elements on dashboard`);
|
|
}
|
|
|
|
if (pageName === 'maintenance-schedule.html') {
|
|
// Try to interact with schedule form
|
|
const formElements = await page.locator('input, select, button').count();
|
|
console.log(`Found ${formElements} form elements on schedule page`);
|
|
}
|
|
|
|
if (pageName === 'maintenance-reports.html') {
|
|
// Try to expand a report
|
|
const reports = await page.locator('.report-item, .accordion, .expandable').count();
|
|
console.log(`Found ${reports} report items`);
|
|
|
|
// Try to click first expandable element if it exists
|
|
const firstExpandable = page.locator('.report-item, .accordion-header, [data-toggle]').first();
|
|
if (await firstExpandable.count() > 0) {
|
|
try {
|
|
await firstExpandable.click();
|
|
await page.waitForTimeout(1000);
|
|
const expandedScreenshot = `Z:\\Repos\\harborsmith\\screenshot-${pageName.replace('.html', '')}-expanded.png`;
|
|
await page.screenshot({ path: expandedScreenshot, fullPage: true });
|
|
console.log(`Expanded view screenshot: ${expandedScreenshot}`);
|
|
} catch (e) {
|
|
console.log('Could not interact with expandable element:', e.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pageName === 'maintenance-invoices.html') {
|
|
// Try to show payment modal
|
|
const payButtons = await page.locator('button:has-text("Pay"), .pay-btn, [data-payment]').count();
|
|
console.log(`Found ${payButtons} payment buttons`);
|
|
|
|
if (payButtons > 0) {
|
|
try {
|
|
await page.locator('button:has-text("Pay"), .pay-btn, [data-payment]').first().click();
|
|
await page.waitForTimeout(1000);
|
|
const modalScreenshot = `Z:\\Repos\\harborsmith\\screenshot-${pageName.replace('.html', '')}-modal.png`;
|
|
await page.screenshot({ path: modalScreenshot, fullPage: true });
|
|
console.log(`Modal view screenshot: ${modalScreenshot}`);
|
|
} catch (e) {
|
|
console.log('Could not interact with payment button:', e.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
await page.waitForTimeout(2000);
|
|
console.log(`✓ ${pageName} tested successfully\n`);
|
|
|
|
} catch (error) {
|
|
console.log(`✗ Error testing ${pageName}: ${error.message}\n`);
|
|
}
|
|
}
|
|
|
|
await browser.close();
|
|
console.log('Testing complete!');
|
|
}
|
|
|
|
testMaintenancePages().catch(console.error); |