upskill-event-manager/wordpress-dev/tests/e2e/simple-dashboard-check.test.ts

93 lines
No EOL
3.5 KiB
TypeScript

import { STAGING_URL, PATHS, TIMEOUTS } from './config/staging-config';
import { test, expect } from '@playwright/test';
test.describe('Simple Dashboard Check', () => {
test('check dashboard using direct URL with manual login', async ({ page }) => {
const staging_url = 'https://upskill-staging.measurequick.com';
console.log('Accessing dashboard without cache...');
// Go directly to dashboard with cache busting
await page.goto(`${staging_url}/hvac-dashboard/?nocache=${Date.now()}`);
await page.waitForLoadState('domcontentloaded');
// Check if we're redirected to login
const url = page.url();
console.log('Current URL:', url);
if (url.includes('community-login') || url.includes('wp-login')) {
console.log('Redirected to login, attempting to log in...');
await page.waitForTimeout(2000);
// Try to find login fields
const loginFieldExists = await page.locator('#user_login').count() > 0;
if (loginFieldExists) {
await page.fill('#user_login', 'test_trainer');
await page.fill('#user_pass', 'password123!');
await page.click('#wp-submit');
await page.waitForLoadState('networkidle');
await page.waitForTimeout(3000);
// Navigate back to dashboard
await page.goto(`${staging_url}/hvac-dashboard/`);
await page.waitForLoadState('networkidle');
}
}
// Take screenshot
await page.screenshot({ path: 'simple-dashboard-check.png', fullPage: true });
// Get page content
const content = await page.content();
// Check what's on the page
console.log('\n=== Dashboard Content Check ===');
const pageTitle = await page.title();
console.log('Page title:', pageTitle);
// Check for dashboard elements
const elements = {
'Dashboard shortcode': '[hvac_trainer_dashboard]',
'Dashboard wrapper': 'hvac-dashboard-wrapper',
'Dashboard stats': 'hvac-dashboard-stats',
'Stat cards': 'hvac-stat-card',
'Login message': 'Please log in',
'Total Events': 'Total Events',
'Create Event': 'Create Event'
};
for (const [name, searchText] of Object.entries(elements)) {
const found = content.includes(searchText);
console.log(`${name}: ${found ? 'Found' : 'Not found'}`);
}
// Check if we're seeing the actual dashboard content
const isDashboardLoaded = content.includes('hvac-dashboard-wrapper') && content.includes('hvac-stat-card');
if (isDashboardLoaded) {
// Count stat cards
const statCardCount = await page.locator('.hvac-stat-card').count();
console.log('Number of stat cards:', statCardCount);
// Get values from stat cards
const statCards = await page.locator('.hvac-stat-card').all();
for (let i = 0; i < statCards.length; i++) {
const title = await statCards[i].locator('h3').textContent();
const value = await statCards[i].locator('.metric-value').textContent();
console.log(`${title}: ${value}`);
}
} else {
console.log('Dashboard content not loaded - checking for error messages');
const bodyText = await page.locator('body').innerText();
console.log('Page body text (first 500 chars):', bodyText.substring(0, 500));
}
console.log('=== End Dashboard Content Check ===\n');
// Save the full HTML for analysis
const fs = require('fs');
fs.writeFileSync('simple-dashboard-content.html', content);
console.log('Full page content saved to simple-dashboard-content.html');
});
});