fix: reduce timeout values and fix test auth issues
- Reduce URL wait timeouts from 10000ms to 5000ms across tests - Fix tournament-edit-allowTies: add login before navigating to edit page - Fix epic4-tournament-creation: fill name field before clicking Next - Fix cucumber config: remove broken cucumber-pretty formatter
This commit is contained in:
@@ -11,11 +11,54 @@
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
const BASE_URL = process.env.CI ? 'https://euchre-ci.notsosm.art' : 'http://localhost:3000';
|
||||
|
||||
function getTestCredentials() {
|
||||
const timestamp = Date.now();
|
||||
return {
|
||||
email: `allowties-admin-${timestamp}@example.com`,
|
||||
password: 'AdminPassword123!',
|
||||
name: `AllowTies Admin ${timestamp}`,
|
||||
};
|
||||
}
|
||||
|
||||
test.describe('Tournament Edit - allowTies functionality', () => {
|
||||
let tournamentId: number;
|
||||
let testEmail: string;
|
||||
let testPassword: string;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
// Create admin user via API
|
||||
const credentials = getTestCredentials();
|
||||
testEmail = credentials.email;
|
||||
testPassword = credentials.password;
|
||||
|
||||
const response = await fetch(`${BASE_URL}/api/auth/sign-up/email`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Origin: BASE_URL,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: testEmail,
|
||||
password: testPassword,
|
||||
name: credentials.name,
|
||||
}),
|
||||
});
|
||||
|
||||
console.log('allowTies test user creation response:', response.status);
|
||||
|
||||
// Update user to club_admin role
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { email: testEmail },
|
||||
});
|
||||
if (user) {
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { role: 'club_admin' },
|
||||
});
|
||||
}
|
||||
|
||||
// Create a test tournament for editing
|
||||
const tournament = await prisma.event.create({
|
||||
data: {
|
||||
@@ -25,6 +68,7 @@ test.describe('Tournament Edit - allowTies functionality', () => {
|
||||
status: 'planned',
|
||||
allowTies: false,
|
||||
targetScore: 5,
|
||||
ownerId: user?.id,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
@@ -37,16 +81,28 @@ test.describe('Tournament Edit - allowTies functionality', () => {
|
||||
if (tournamentId) {
|
||||
await prisma.event.delete({
|
||||
where: { id: tournamentId },
|
||||
});
|
||||
}).catch(() => {});
|
||||
}
|
||||
// Clean up user
|
||||
const user = await prisma.user.findUnique({ where: { email: testEmail } });
|
||||
if (user) {
|
||||
await prisma.user.delete({ where: { id: user.id } });
|
||||
}
|
||||
});
|
||||
|
||||
test('should display allowTies checkbox on edit form @chromium-admin', async ({ page }) => {
|
||||
// Login first
|
||||
await page.goto('/auth/login');
|
||||
await page.fill('input[name="email"]', testEmail);
|
||||
await page.fill('input[name="password"]', testPassword);
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(/\/(admin|players)/, { timeout: 5000 });
|
||||
|
||||
// Navigate to tournament edit page
|
||||
await page.goto(`/admin/tournaments/${tournamentId}/edit`);
|
||||
|
||||
// Wait for form to load - edit page shows "Edit Tournament" heading
|
||||
await expect(page.locator('text=Edit Tournament')).toBeVisible();
|
||||
await expect(page.locator('text=Edit Tournament')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Check that allowTies checkbox exists
|
||||
const allowTiesCheckbox = page.locator('input[name="allowTies"]');
|
||||
@@ -55,11 +111,18 @@ test.describe('Tournament Edit - allowTies functionality', () => {
|
||||
});
|
||||
|
||||
test('should save allowTies when toggled to true @chromium-admin', async ({ page }) => {
|
||||
// Login first
|
||||
await page.goto('/auth/login');
|
||||
await page.fill('input[name="email"]', testEmail);
|
||||
await page.fill('input[name="password"]', testPassword);
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(/\/(admin|players)/, { timeout: 5000 });
|
||||
|
||||
// Navigate to tournament edit page
|
||||
await page.goto(`/admin/tournaments/${tournamentId}/edit`);
|
||||
|
||||
// Wait for form to load
|
||||
await expect(page.locator('text=Edit Tournament')).toBeVisible();
|
||||
await expect(page.locator('text=Edit Tournament')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Toggle allowTies checkbox
|
||||
const allowTiesCheckbox = page.locator('input[name="allowTies"]');
|
||||
@@ -87,11 +150,18 @@ test.describe('Tournament Edit - allowTies functionality', () => {
|
||||
data: { allowTies: true },
|
||||
});
|
||||
|
||||
// Login first
|
||||
await page.goto('/auth/login');
|
||||
await page.fill('input[name="email"]', testEmail);
|
||||
await page.fill('input[name="password"]', testPassword);
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(/\/(admin|players)/, { timeout: 5000 });
|
||||
|
||||
// Navigate to tournament edit page
|
||||
await page.goto(`/admin/tournaments/${tournamentId}/edit`);
|
||||
|
||||
// Wait for form to load
|
||||
await expect(page.locator('text=Edit Tournament')).toBeVisible();
|
||||
await expect(page.locator('text=Edit Tournament')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Verify checkbox is checked
|
||||
const allowTiesCheckbox = page.locator('input[name="allowTies"]');
|
||||
@@ -114,4 +184,4 @@ test.describe('Tournament Edit - allowTies functionality', () => {
|
||||
|
||||
expect(updatedTournament?.allowTies).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user