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

99 lines
No EOL
3.2 KiB
TypeScript

import { STAGING_URL, PATHS, TIMEOUTS } from './config/staging-config';
import { test, expect } from '@playwright/test';
import { LoginPage } from './pages/LoginPage';
import { TEST_USERS } from './data/test-users';
// STAGING_URL is now imported from config
test('Debug dashboard page after login', async ({ page }) => {
const loginPage = new LoginPage(page);
const trainer = TEST_USERS.trainer;
// Set base URL
await page.goto(STAGING_URL);
// Login
await loginPage.navigateToLogin();
await loginPage.login(trainer.username, trainer.password);
// Wait for navigation
await page.waitForLoadState('networkidle');
// Check where we were redirected
const currentUrl = page.url();
console.log('After login, current URL:', currentUrl);
// Take a screenshot
await page.screenshot({ path: 'test-results/debug-after-login.png', fullPage: true });
// Check if we're on the dashboard
if (!currentUrl.includes('dashboard')) {
console.log('Not on dashboard, navigating to it...');
await page.goto(PATHS.dashboard);
await page.waitForLoadState('networkidle');
const dashboardUrl = page.url();
console.log('Dashboard URL:', dashboardUrl);
await page.screenshot({ path: 'test-results/debug-dashboard.png', fullPage: true });
}
// Look for dashboard elements
console.log('\nLooking for dashboard elements...');
const dashboardSelectors = [
'.dashboard',
'#dashboard',
'.hvac-dashboard',
'.trainer-dashboard',
'.statistics-summary',
'.events-table',
'a:has-text("Create Event")',
'a:has-text("View Trainer Profile")',
'a:has-text("Logout")',
'.total-events-count',
'.upcoming-events-count',
'.past-events-count',
'.total-tickets-sold',
'.total-revenue'
];
for (const selector of dashboardSelectors) {
const exists = await page.locator(selector).count() > 0;
console.log(`${selector}: ${exists ? 'FOUND' : 'NOT FOUND'}`);
}
// Check for tables
const tables = await page.locator('table').all();
console.log(`\nFound ${tables.length} tables on the page`);
// Check for links
const links = await page.locator('a').all();
console.log(`Found ${links.length} links on the page`);
for (let i = 0; i < Math.min(links.length, 10); i++) {
const link = links[i];
const text = await link.textContent();
const href = await link.getAttribute('href');
console.log(`Link ${i + 1}: "${text?.trim()}" -> ${href}`);
}
// Check for main content areas
const contentAreas = [
'.content',
'.main-content',
'#content',
'#main',
'main',
'article',
'.entry-content'
];
console.log('\nLooking for content areas...');
for (const selector of contentAreas) {
const exists = await page.locator(selector).count() > 0;
if (exists) {
console.log(`${selector}: FOUND`);
const text = await page.locator(selector).first().textContent();
console.log(` Content preview: ${text?.substring(0, 100)}...`);
}
}
});