feat: set up development database and test cleanup utilities
This commit is contained in:
@@ -5,10 +5,24 @@
|
||||
|
||||
import { chromium, type FullConfig } from '@playwright/test';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import { cleanupAllTestData } from '@/__tests__/test-utils';
|
||||
|
||||
const authFile = 'playwright/.auth/user.json';
|
||||
const adminAuthFile = 'playwright/.auth/admin.json';
|
||||
|
||||
// Check if we're using the dev database
|
||||
function isDevDatabase(): boolean {
|
||||
const dbUrl = process.env.DATABASE_URL || '';
|
||||
return dbUrl.includes('euchre_camp_dev');
|
||||
}
|
||||
|
||||
// Warn if not using dev database
|
||||
if (!isDevDatabase()) {
|
||||
console.warn('⚠️ WARNING: Not using dev database!');
|
||||
console.warn(' Current DATABASE_URL:', process.env.DATABASE_URL);
|
||||
console.warn(' Expected to contain: euchre_camp_dev');
|
||||
}
|
||||
|
||||
export default async function globalSetup(config: FullConfig) {
|
||||
const baseURL = config.projects[0]?.use?.baseURL || 'http://localhost:3000';
|
||||
|
||||
@@ -144,18 +158,13 @@ export default async function globalSetup(config: FullConfig) {
|
||||
|
||||
// Return teardown function
|
||||
return async () => {
|
||||
// Clean up test users
|
||||
console.log('\n=== Global Teardown ===');
|
||||
|
||||
// Clean up all test data
|
||||
try {
|
||||
await prisma.user.deleteMany({
|
||||
where: {
|
||||
email: {
|
||||
startsWith: 'setup-'
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log('Cleaned up test users');
|
||||
await cleanupAllTestData();
|
||||
} catch (error) {
|
||||
console.error('Error cleaning up test users:', error);
|
||||
console.error('Error cleaning up test data:', error);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user