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

59 lines
No EOL
2.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Trainer Dashboard', () => {
test('should allow a logged-in trainer to view their dashboard', async ({ page }) => {
// --- Login Steps (reused from login.test.ts) ---
// Navigate to the community login page
await page.goto('/community-login/');
// Check if the login form fields are visible and enabled
const usernameField = page.locator('#user_login');
const passwordField = page.locator('#user_pass');
const loginButton = page.locator('#wp-submit');
await expect(usernameField).toBeVisible();
await expect(usernameField).toBeEnabled();
await expect(passwordField).toBeVisible();
await expect(passwordField).toBeEnabled();
await expect(loginButton).toBeVisible();
await expect(loginButton).toBeEnabled();
// Fill in login credentials (using the test user from README)
const username = 'test_trainer';
const password = 'Test123!';
await usernameField.fill(username);
console.log(`Filled in username field with: ${username}`);
await passwordField.fill(password);
console.log('Filled in password field.');
// Click the login button
await loginButton.click();
console.log('Clicked login button.');
// Assert successful login (redirection to dashboard)
await page.waitForURL('/hvac-dashboard/', { timeout: 15000 });
console.log('Successfully logged in and redirected to dashboard.');
// --- End Login Steps ---
// --- Dashboard Content Analysis ---
// Log current URL and take a screenshot of the dashboard
console.log('On Dashboard page:', page.url());
await page.screenshot({ path: 'dashboard-page.png', fullPage: true });
// Print the page content to analyze available links/buttons
console.log('Dashboard page content:');
console.log(await page.content());
// Assert that a key element on the dashboard is visible (optional, but good practice)
const dashboardTitle = page.locator('h1.entry-title');
await expect(dashboardTitle).toBeVisible();
console.log('Dashboard page loaded. Analyzing content for event creation link.');
// --- End Dashboard Content Analysis ---
// Note: The test will currently pass after logging in and printing content.
// We will update this test or create a new one once the navigation to event creation is identified.
});
});