caefb0dcc0
- Replace window.location.reload() with router.refresh() in ScheduleGenerator, MatchEditor, RecalculateEloButton for proper Next.js cache invalidation - Add revalidatePath() call after schedule generation in POST handler - Add ownerId to tournament creation in cucumber tests for proper permission checks - Assign tournament_admin role via Prisma after user creation in cucumber tests - Fix TypeScript type annotations in hooks.ts (tournament id map) - Update page reload to use networkidle in common-steps.ts - Clear .next/ cache before cucumber tests in justfile - Add .turbo to clean target - Add comprehensive debug logging to schedule API route - Document findings in docs/TROUBLESHOOTING_SCHEDULE_GENERATION.md
77 lines
1.9 KiB
TypeScript
77 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?: {
|
|
id?: string;
|
|
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?: {
|
|
id?: string;
|
|
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();
|