ui improvements
This commit is contained in:
83
tests/minimal-submit.spec.ts
Normal file
83
tests/minimal-submit.spec.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Minimal Form Submission Test', () => {
|
||||
test('should submit minimal valid form', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
// Wait for page to load
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Fill required fields with minimal valid data
|
||||
await page.fill('input[id="playerName"]', 'TestPlayer');
|
||||
await page.fill('input[id="currentPoints"]', '0');
|
||||
|
||||
// Select a simple crime that doesn't require additional inputs
|
||||
// Click "all" category first to show all crimes
|
||||
await page.locator('button').filter({ hasText: 'all' }).click();
|
||||
|
||||
// Wait for select trigger to be available
|
||||
await page.waitForSelector('button:has-text("select an offense")');
|
||||
|
||||
// Click the select trigger
|
||||
await page.locator('button').filter({ hasText: 'select an offense' }).click();
|
||||
|
||||
// Wait for dropdown and select "Abusive Chat" (simple crime)
|
||||
await page.locator('[data-slot="select-content"]').locator('text=Abusive Chat').click();
|
||||
|
||||
// Take screenshot before submit
|
||||
await page.screenshot({ path: 'debug-screenshots/minimal-before-submit.png', fullPage: true });
|
||||
|
||||
// Check if button is enabled before submitting
|
||||
const button = page.locator('button[type="submit"]');
|
||||
const isEnabled = await button.isEnabled();
|
||||
console.log('Submit button is enabled:', isEnabled);
|
||||
|
||||
// Check form validity by looking at the DOM
|
||||
const hasErrors = await page.locator('.text-red-500').count() > 0;
|
||||
console.log('Form has errors:', hasErrors);
|
||||
|
||||
// Submit the form
|
||||
await button.click();
|
||||
|
||||
// Wait for processing
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Take screenshot after submit
|
||||
await page.screenshot({ path: 'debug-screenshots/minimal-after-submit.png', fullPage: true });
|
||||
|
||||
// Listen for console messages after submit
|
||||
const consoleMessages: string[] = [];
|
||||
page.on('console', msg => {
|
||||
consoleMessages.push(msg.text());
|
||||
});
|
||||
|
||||
// Wait a bit more for any async operations
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
console.log('Console messages after submit:', consoleMessages);
|
||||
|
||||
// Check for results
|
||||
const resultsVisible = await page.locator('h3').filter({ hasText: 'results' }).count() > 0;
|
||||
console.log('Results visible:', resultsVisible);
|
||||
|
||||
if (resultsVisible) {
|
||||
console.log('SUCCESS: Form submission worked!');
|
||||
} else {
|
||||
console.log('FAILURE: Form submission did not work');
|
||||
|
||||
// Check for any form errors
|
||||
const formErrors = await page.locator('.text-red-500').allTextContents();
|
||||
console.log('Form errors:', formErrors);
|
||||
|
||||
// Check form data
|
||||
const playerName = await page.inputValue('input[id="playerName"]');
|
||||
const currentPoints = await page.inputValue('input[id="currentPoints"]');
|
||||
console.log('Form data - playerName:', playerName, 'currentPoints:', currentPoints);
|
||||
|
||||
// Check if crimeId is set
|
||||
const crimeTrigger = page.locator('button').filter({ hasText: 'select an offense' });
|
||||
const crimeTriggerText = await crimeTrigger.textContent();
|
||||
console.log('Crime trigger text:', crimeTriggerText);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user