Some checks failed
CI / lint-typecheck (pull_request) Failing after 13s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
114 lines
5.7 KiB
TypeScript
114 lines
5.7 KiB
TypeScript
/**
|
|
* BDD E2E Test: Driver Dashboard View
|
|
*
|
|
* Tests the main dashboard view that displays:
|
|
* - Current driver statistics (rating, rank, starts, wins, podiums, leagues)
|
|
* - Next race information (track, car, scheduled time, time until)
|
|
* - Upcoming races (list of 3 races)
|
|
* - Championship standings (league name, position, points)
|
|
* - Recent activity feed (race results, other events)
|
|
*
|
|
* Focus: Final user outcomes - what the driver sees and can verify
|
|
*/
|
|
|
|
import { expect, testWithAuth } from '../../shared/auth-fixture';
|
|
|
|
testWithAuth.describe('Driver Dashboard View', () => {
|
|
testWithAuth('Driver sees their current statistics on the dashboard', async ({ authenticatedDriver }) => {
|
|
// Ensure we're on the dashboard page
|
|
await authenticatedDriver.goto('/dashboard');
|
|
await authenticatedDriver.waitForLoadState('networkidle');
|
|
// Verify dashboard statistics section is visible
|
|
await expect(authenticatedDriver.getByTestId('dashboard-stats')).toBeVisible();
|
|
|
|
// Check individual KPI cards are displayed
|
|
await expect(authenticatedDriver.getByTestId('stat-rating')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('stat-rank')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('stat-starts')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('stat-wins')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('stat-podiums')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('stat-leagues')).toBeVisible();
|
|
});
|
|
|
|
testWithAuth('Driver sees next race information when a race is scheduled', async ({ authenticatedDriver }) => {
|
|
const nextRaceSection = authenticatedDriver.getByTestId('next-race-section');
|
|
// Use count() to check existence without triggering auto-wait timeout if it's not there
|
|
const count = await nextRaceSection.count();
|
|
if (count > 0) {
|
|
// If it exists, we expect it to be visible. If it's not, it's a failure.
|
|
// But we use a shorter timeout to avoid 30s hang if it's just not there.
|
|
const isVisible = await nextRaceSection.isVisible();
|
|
if (isVisible) {
|
|
const track = authenticatedDriver.getByTestId('next-race-track');
|
|
if (await track.count() > 0) {
|
|
await expect(track).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('next-race-car')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('next-race-time')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('next-race-countdown')).toBeVisible();
|
|
} else {
|
|
testWithAuth.skip(true, 'Next race section visible but details missing (null data), skipping');
|
|
}
|
|
} else {
|
|
testWithAuth.skip(true, 'Next race section exists but is not visible, skipping');
|
|
}
|
|
} else {
|
|
testWithAuth.skip(true, 'No next race scheduled, skipping detailed checks');
|
|
}
|
|
});
|
|
|
|
testWithAuth('Driver sees upcoming races list on the dashboard', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('upcoming-races-section')).toBeVisible();
|
|
const raceItems = authenticatedDriver.locator('[data-testid^="upcoming-race-"]');
|
|
await expect(raceItems.first()).toBeVisible();
|
|
});
|
|
|
|
testWithAuth('Driver sees championship standings on the dashboard', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('championship-standings-section')).toBeVisible();
|
|
const leagueItems = authenticatedDriver.locator('[data-testid^="league-standing-"]');
|
|
await expect(leagueItems.first()).toBeVisible();
|
|
});
|
|
|
|
testWithAuth('Driver sees recent activity feed on the dashboard', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('activity-feed-section')).toBeVisible();
|
|
const activityItems = authenticatedDriver.locator('[data-testid^="activity-item-"]');
|
|
const emptyState = authenticatedDriver.getByTestId('activity-empty');
|
|
|
|
if (await activityItems.count() > 0) {
|
|
await expect(activityItems.first()).toBeVisible();
|
|
} else {
|
|
await expect(emptyState).toBeVisible();
|
|
}
|
|
});
|
|
|
|
testWithAuth('Driver sees empty state when no upcoming races exist', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('upcoming-races-section')).toBeVisible();
|
|
const raceItems = authenticatedDriver.locator('[data-testid^="upcoming-race-"]');
|
|
if (await raceItems.count() === 0) {
|
|
await expect(authenticatedDriver.getByTestId('upcoming-races-empty')).toBeVisible();
|
|
} else {
|
|
testWithAuth.skip(true, 'Upcoming races exist, skipping empty state check');
|
|
}
|
|
});
|
|
|
|
testWithAuth('Driver sees empty state when no championship standings exist', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('championship-standings-section')).toBeVisible();
|
|
const leagueItems = authenticatedDriver.locator('[data-testid^="league-standing-"]');
|
|
if (await leagueItems.count() === 0) {
|
|
await expect(authenticatedDriver.getByTestId('standings-empty')).toBeVisible();
|
|
} else {
|
|
testWithAuth.skip(true, 'Championship standings exist, skipping empty state check');
|
|
}
|
|
});
|
|
|
|
testWithAuth('Driver sees empty state when no recent activity exists', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('activity-feed-section')).toBeVisible();
|
|
await expect(authenticatedDriver.getByTestId('activity-empty')).toBeVisible();
|
|
});
|
|
|
|
testWithAuth('Dashboard displays KPI overview with correct values', async ({ authenticatedDriver }) => {
|
|
await expect(authenticatedDriver.getByTestId('dashboard-stats')).toBeVisible();
|
|
const kpiItems = authenticatedDriver.locator('[data-testid^="stat-"]');
|
|
await expect(kpiItems).toHaveCount(6);
|
|
});
|
|
});
|