Files
euchre_camp/e2e/cucumber/support/world.ts
T
david 9353ab1edc
Pull Request / unit-tests (pull_request) Successful in 57s
Pull Request / e2e-tests (pull_request) Failing after 1m49s
Pull Request / analyze-bump-type (pull_request) Has been skipped
wip: Tournament schedule tests - 27/30 passing
Progress on issue #7 - tournament schedule e2e tests:
- Created ScheduleDisplay component with clickthrough to matches
- Updated ScheduleGenerator to use router.refresh() instead of window.location.reload()
- Fixed step definitions to handle page hydration and reloads
- Fixed database cleanup hook to use Prisma API instead of raw SQL
- Added test IDs and logging for debugging
- Updated feature file to match actual UI behavior

27/30 scenarios passing:
- All auth and navigation scenarios pass
- Scenario 1 (view schedule page) passes
- Scenarios 2-4 (generate schedule, view rounds, click matchup) need investigation

Remaining issues:
1. Page refresh not picking up newly generated schedule data
2. Round data not visible after 'Generated' message
3. Matchup elements not found after refresh
4. Database cleanup hook needs proper handling of foreign keys

Next steps:
1. Investigate why router.refresh() and explicit reload don't show new data
2. Check if there's a caching issue in the production build
3. Verify database transactions are committing correctly
4. Add more logging to trace data flow
2026-04-27 00:29:38 -07:00

75 lines
1.9 KiB
TypeScript

/**
* World context for Cucumber tests
* Provides shared state between step definitions
*/
import { Page, BrowserContext, chromium, Browser } from '@playwright/test';
export interface WorldState {
page: Page;
context: BrowserContext;
prisma: any; // Lazy-loaded PrismaClient
baseURL: string;
user?: {
email: string;
name: string;
password: string;
};
tournament?: any;
tournamentTeamCount?: number;
player?: any;
playerId?: string; // Added for storing extracted player ID
match?: any;
generatedData?: {
uniqueEmail?: string;
[key: string]: any;
};
}
export class World implements WorldState {
page!: Page;
context!: BrowserContext;
prisma: any;
baseURL: string;
user?: {
email: string;
name: string;
password: string;
};
tournament?: any;
tournamentTeamCount?: number;
player?: any;
playerId?: string; // Added for storing extracted player ID
match?: any;
generatedData?: {
uniqueEmail?: string;
[key: string]: any;
};
constructor() {
this.baseURL = process.env.BASE_URL || 'http://localhost:3000';
this.prisma = null; // Will be lazily loaded when needed
}
async getPrisma() {
if (!this.prisma) {
// Load .env.development file for test database configuration (fallback)
require('dotenv').config({ path: '.env.development' })
// Ensure database environment is set for Cucumber tests BEFORE importing PrismaClient
if (!process.env.DATABASE_URL) {
throw new Error('DATABASE_URL not set. Make sure .env.development exists and contains DATABASE_URL or set DATABASE_URL environment variable.');
}
// Use the shared prisma instance from the app's lib
// This handles the adapter setup correctly
const { prisma } = require('@/lib/prisma');
this.prisma = prisma;
}
return this.prisma;
}
}
// Export singleton instance
export const world = new World();