52 lines
No EOL
2.1 KiB
TypeScript
52 lines
No EOL
2.1 KiB
TypeScript
import { test, expect, Page } from '@playwright/test';
|
|
import { LoginPage } from './pages/LoginPage';
|
|
import { DashboardPage } from './pages/DashboardPage';
|
|
import { EventSummaryPage } from './pages/EventSummaryPage';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
test.describe('Dashboard and Event Summary Screenshots', () => {
|
|
const screenshotsDir = path.join(__dirname, 'screenshots');
|
|
|
|
// Create screenshots directory if it doesn't exist
|
|
test.beforeAll(async () => {
|
|
if (!fs.existsSync(screenshotsDir)) {
|
|
fs.mkdirSync(screenshotsDir, { recursive: true });
|
|
}
|
|
});
|
|
|
|
test('Take screenshots of trainer dashboard and event summary', async ({ page }) => {
|
|
// Set viewport size
|
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
|
|
// Login
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.navigate();
|
|
await loginPage.login('test_trainer', 'Test123!');
|
|
|
|
// Take screenshot of dashboard
|
|
const dashboardPage = new DashboardPage(page);
|
|
await dashboardPage.navigate();
|
|
const dashboardPath = path.join(screenshotsDir, 'trainer-dashboard.png');
|
|
await page.screenshot({ path: dashboardPath, fullPage: true });
|
|
console.log(`Dashboard screenshot saved to: ${dashboardPath}`);
|
|
|
|
// Navigate to event summary page
|
|
const eventSummaryPage = new EventSummaryPage(page);
|
|
await eventSummaryPage.navigateToEventSummary('5484');
|
|
|
|
// Take screenshot of event summary
|
|
const eventSummaryPath = path.join(screenshotsDir, 'event-summary.png');
|
|
await page.screenshot({ path: eventSummaryPath, fullPage: true });
|
|
console.log(`Event summary screenshot saved to: ${eventSummaryPath}`);
|
|
|
|
// Check if tickets data is visible on the event summary page
|
|
const isTransactionsTableVisible = await eventSummaryPage.isTransactionsTableVisible();
|
|
if (isTransactionsTableVisible) {
|
|
const transactionCount = await eventSummaryPage.getTransactionCount();
|
|
console.log(`Transactions table is visible with ${transactionCount} transactions`);
|
|
} else {
|
|
console.log('Transactions table is not visible');
|
|
}
|
|
});
|
|
}); |