115 lines
No EOL
4 KiB
TypeScript
115 lines
No EOL
4 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 details and stats', 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');
|
|
|
|
console.log('Looking for dashboard statistics...');
|
|
|
|
// Find all divs and look for ones with statistics
|
|
const divs = await page.locator('div').all();
|
|
console.log(`Found ${divs.length} divs on the page`);
|
|
|
|
// Look for text content that might contain stats
|
|
const statsTexts = [
|
|
'Total Events',
|
|
'Upcoming Events',
|
|
'Past Events',
|
|
'Total Tickets',
|
|
'Total Revenue',
|
|
'Annual Revenue Target'
|
|
];
|
|
|
|
for (const text of statsTexts) {
|
|
const elements = await page.locator(`text="${text}"`).all();
|
|
console.log(`"${text}": Found ${elements.length} instances`);
|
|
|
|
if (elements.length > 0) {
|
|
// Try to find associated number/value
|
|
const parentElement = elements[0];
|
|
const parent = await parentElement.locator('..').first();
|
|
const parentText = await parent.textContent();
|
|
console.log(` Parent text: ${parentText}`);
|
|
|
|
// Look for sibling elements
|
|
const siblings = await parent.locator('*').all();
|
|
for (let i = 0; i < siblings.length; i++) {
|
|
const siblingText = await siblings[i].textContent();
|
|
console.log(` Sibling ${i}: ${siblingText}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Look for the events table more specifically
|
|
console.log('\nLooking for events table structure...');
|
|
const tables = await page.locator('table').all();
|
|
|
|
for (let i = 0; i < tables.length; i++) {
|
|
console.log(`\nTable ${i + 1}:`);
|
|
const table = tables[i];
|
|
|
|
// Check for headers
|
|
const headers = await table.locator('th').all();
|
|
console.log(` Headers: ${headers.length}`);
|
|
for (let j = 0; j < headers.length; j++) {
|
|
const headerText = await headers[j].textContent();
|
|
console.log(` Header ${j}: ${headerText}`);
|
|
}
|
|
|
|
// Check for rows
|
|
const rows = await table.locator('tbody tr').all();
|
|
console.log(` Rows: ${rows.length}`);
|
|
|
|
if (rows.length > 0) {
|
|
// Check first row
|
|
const firstRow = rows[0];
|
|
const cells = await firstRow.locator('td').all();
|
|
console.log(` First row cells: ${cells.length}`);
|
|
for (let k = 0; k < cells.length; k++) {
|
|
const cellText = await cells[k].textContent();
|
|
console.log(` Cell ${k}: ${cellText}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Take a focused screenshot
|
|
await page.screenshot({ path: 'test-results/debug-dashboard-focused.png', fullPage: true });
|
|
|
|
// Try to find the specific dashboard container
|
|
console.log('\nLooking for dashboard containers...');
|
|
const possibleContainers = [
|
|
'.hvac-trainer-dashboard',
|
|
'#hvac-trainer-dashboard',
|
|
'.trainer-dashboard-container',
|
|
'.dashboard-content',
|
|
'.entry-content',
|
|
'article.page',
|
|
'.page-content'
|
|
];
|
|
|
|
for (const selector of possibleContainers) {
|
|
const exists = await page.locator(selector).count() > 0;
|
|
if (exists) {
|
|
console.log(`${selector}: FOUND`);
|
|
const content = await page.locator(selector).first().textContent();
|
|
console.log(` Content preview: ${content?.substring(0, 200)}...`);
|
|
} else {
|
|
console.log(`${selector}: NOT FOUND`);
|
|
}
|
|
}
|
|
}); |