upskill-event-manager/wordpress-dev/tests/e2e/test-wp-admin-login.test.ts
bengizmo a82616b6f7 Fix dashboard data inconsistency and enhance test suite with WP API
- Fixed dashboard data class to use consistent post_author queries instead of mixed _EventOrganizerID meta queries
- This resolves the issue where dashboard showed 18 events but 0 tickets/revenue
- Added WordPress API credentials to environment (.env)
- Created comprehensive API debugging utilities (wp-api-debug.sh, wp-api-fix.sh, api-only-debug.sh)
- Enhanced test and deployment suite with WordPress REST API capabilities
- Root cause: get_total_tickets_sold() and get_total_revenue() were using _EventOrganizerID while other methods used post_author

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-22 19:24:18 -03:00

32 lines
No EOL
1.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('should login via wp-admin and access dashboard', async ({ page }) => {
// Login via wp-admin
await page.goto('https://upskill-staging.measurequick.com/wp-admin');
await page.fill('#user_login', 'test_trainer');
await page.fill('#user_pass', 'password123!');
await page.click('#wp-submit');
// Wait for login to complete
await page.waitForLoadState('networkidle');
// Check if we're logged in (should not be on login page)
const currentUrl = page.url();
console.log('Current URL after login:', currentUrl);
expect(currentUrl).not.toContain('wp-login.php');
// Now navigate to HVAC dashboard
await page.goto('https://upskill-staging.measurequick.com/hvac-dashboard');
await page.waitForLoadState('networkidle');
// Check for dashboard elements
const pageContent = await page.content();
console.log('Dashboard page contains "dashboard":', pageContent.toLowerCase().includes('dashboard'));
// Check for stat cards
const statCards = await page.locator('.hvac-stat-card').count();
console.log('Number of stat cards found:', statCards);
// Take screenshot for debugging
await page.screenshot({ path: 'wp-admin-login-test.png', fullPage: true });
});