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

55 lines
No EOL
2 KiB
TypeScript

import { STAGING_URL, PATHS, TIMEOUTS } from './config/staging-config';
import { test, expect } from '@playwright/test';
test.describe('Dashboard Elements Check', () => {
test('check what elements are on the dashboard', async ({ page }) => {
const staging_url = 'https://upskill-staging.measurequick.com';
// Login as test trainer
await page.goto(`${staging_url}/community-login`);
await page.fill('#user_login', 'test_trainer');
await page.fill('#user_pass', 'password123!');
await page.click('input[type="submit"]');
await page.waitForTimeout(3000);
// Go to dashboard
await page.goto(`${staging_url}/hvac-dashboard`);
await page.waitForLoadState('networkidle');
// Take a screenshot for debugging
await page.screenshot({ path: 'dashboard-screenshot.png' });
// Log the page content to see what's actually there
const pageContent = await page.content();
console.log('Dashboard HTML:', pageContent.substring(0, 2000)); // First 2000 chars
// Check for various possible selectors
const possibleSelectors = [
'.metric-value',
'.stats-value',
'.event-count',
'.total-events',
'.dashboard-stats',
'.stat-number',
'.card-value',
'#total-events',
'[data-metric="total-events"]'
];
for (const selector of possibleSelectors) {
const elements = await page.locator(selector).count();
if (elements > 0) {
console.log(`Found ${elements} elements with selector: ${selector}`);
const firstText = await page.locator(selector).first().textContent();
console.log(` First element text: "${firstText}"`);
}
}
// Look for text containing "Events" or numbers
const eventsTexts = await page.locator('text=/\\d+/').allTextContents();
console.log('All numeric texts on page:', eventsTexts);
const eventRelatedTexts = await page.locator('text=/event/i').allTextContents();
console.log('All event-related texts:', eventRelatedTexts);
});
});