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

45 lines
No EOL
2.1 KiB
TypeScript

import { STAGING_URL, PATHS, TIMEOUTS } from './config/staging-config';
import { test } from '@playwright/test';
test.describe('Debug Create Event Link', () => {
test('Find create event button URL', async ({ page }) => {
// Navigate directly to community-login
const loginUrl = 'https://upskill-staging.measurequick.com/community-login/';
await page.goto(loginUrl);
await page.waitForLoadState('networkidle');
// Login
await page.fill('#user_login', 'test_trainer');
await page.fill('#user_pass', 'Test123!');
await page.click('#wp-submit');
await page.waitForURL((url) => !url.toString().includes('community-login'));
// We should be on the dashboard now
await page.waitForSelector('.dashboard-title');
// Find CREATE EVENT button and get its href
const createEventButtons = await page.$$eval('a:has-text("CREATE EVENT"), a:has-text("Create Event"), a:has-text("NEW EVENT"), a:has-text("Add Event"), button:has-text("CREATE EVENT"), button:has-text("Create Event")', elements => {
return elements.map(el => ({
tagName: el.tagName,
text: (el as HTMLElement).innerText,
href: el.getAttribute('href'),
className: el.className,
id: el.id,
visible: (el as HTMLElement).offsetParent !== null
}));
});
console.log('Create Event buttons found:', JSON.stringify(createEventButtons, null, 2));
// Take a screenshot showing where we are
await page.screenshot({ path: 'test-results/screenshots/dashboard-create-button.png', fullPage: true });
// Try to click the create event button if found
if (createEventButtons.length > 0 && createEventButtons[0].href) {
await page.goto(createEventButtons[0].href);
await page.waitForLoadState('networkidle');
console.log('Navigated to:', page.url());
await page.screenshot({ path: 'test-results/screenshots/create-event-page.png', fullPage: true });
}
});
});