Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test: Add registration form validation UI test

LearningCircuit4cc797e19d86
diff --git a/.github/workflows/critical-ui-tests.yml b/.github/workflows/critical-ui-tests.yml
index 983b84205f..9f01880baa 100644
--- a/.github/workflows/critical-ui-tests.yml
+++ b/.github/workflows/critical-ui-tests.yml
@@ -154,6 +154,9 @@ jobs:
echo "Running critical authentication test..."
node test_auth_flow.js || exit 1
+ echo "Running registration form validation test..."
+ node test_register_validation.js || exit 1
+
echo "Running critical research submission tests..."
node test_research_submit.js || exit 1
node test_research_simple.js || exit 1
diff --git a/tests/ui_tests/test_register_validation.js b/tests/ui_tests/test_register_validation.js
new file mode 100644
index 0000000000..898967983a
--- /dev/null
+++ b/tests/ui_tests/test_register_validation.js
@@ -0,0 +1,307 @@
+/**
+ * Registration Form Validation Test
+ * Tests that the username field correctly validates input while typing
+ * Specifically checks that numbers don't incorrectly trigger validation warnings
+ * CI-compatible: Works in both local and CI environments
+ */
+
+const puppeteer = require('puppeteer');
+const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
+const fs = require('fs');
+const path = require('path');
+
+async function testRegisterValidation() {
+ const isCI = !!process.env.CI;
+ console.log(`🧪 Running registration form validation test (CI mode: ${isCI})`);
+
+ // Create screenshots directory if it doesn't exist
+ const screenshotsDir = path.join(__dirname, 'screenshots');
+ if (!fs.existsSync(screenshotsDir)) {
+ fs.mkdirSync(screenshotsDir, { recursive: true });
+ }
+
+ const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
+ const page = await browser.newPage();
+ const baseUrl = 'http://127.0.0.1:5000';
+
+ // Increase default timeout in CI
+ if (isCI) {
+ page.setDefaultTimeout(60000);
+ page.setDefaultNavigationTimeout(60000);
+ }
+
+ let testsPassed = 0;
+ let testsFailed = 0;
+
+ console.log('🧪 Starting registration form validation tests...\n');
+
+ try {
+ // Navigate to register page
+ console.log('📄 Navigating to registration page...');
+ await page.goto(`${baseUrl}/auth/register`, {
+ waitUntil: 'networkidle2',
+ timeout: 30000
+ });
+
+ // Wait for the username input
+ await page.waitForSelector('input[name="username"]', { timeout: 10000 });
+ console.log('✅ Registration page loaded\n');
+
+ // Test 1: Check CSS class consistency
+ console.log('📋 Test 1: CSS class consistency');
+ const usernameInput = await page.$('input[name="username"]');
+ const usernameClass = await page.evaluate(el => el.className, usernameInput);
+
+ if (usernameClass.includes('ldr-form-control')) {
+ console.log('✅ Username input uses ldr-form-control class');
+ testsPassed++;
+ } else {
+ console.log(`❌ Username input has incorrect class: "${usernameClass}" (expected ldr-form-control)`);
+ testsFailed++;
+ }
+
+ // Check password fields too
+ const passwordInput = await page.$('input[name="password"]');
+ const passwordClass = await page.evaluate(el => el.className, passwordInput);
+
+ if (passwordClass.includes('ldr-form-control')) {
+ console.log('✅ Password input uses ldr-form-control class');
+ testsPassed++;
+ } else {
+ console.log(`❌ Password input has incorrect class: "${passwordClass}" (expected ldr-form-control)`);
+ testsFailed++;
+ }
+
+ const confirmPasswordInput = await page.$('input[name="confirm_password"]');
+ const confirmPasswordClass = await page.evaluate(el => el.className, confirmPasswordInput);
+
+ if (confirmPasswordClass.includes('ldr-form-control')) {
+ console.log('✅ Confirm password input uses ldr-form-control class');
+ testsPassed++;
+ } else {
+ console.log(`❌ Confirm password input has incorrect class: "${confirmPasswordClass}" (expected ldr-form-control)`);
+ testsFailed++;
+ }
+
+ // Test 2: Check pattern attribute
+ console.log('\n📋 Test 2: Pattern attribute validation');
+ const pattern = await page.evaluate(el => el.pattern, usernameInput);
+ console.log(` Pattern: ${pattern}`);
+
+ // The pattern should allow letters, numbers, underscores, and hyphens
+ if (pattern && pattern.includes('a-zA-Z') && pattern.includes('0-9')) {
+ console.log('✅ Pattern correctly includes letters and numbers');
+ testsPassed++;
+ } else {
+ console.log('❌ Pattern may not correctly include letters and numbers');
+ testsFailed++;
+ }
+
+ // Test 3: Type letters only - should be valid
+ console.log('\n📋 Test 3: Typing letters only');
+ await page.focus('input[name="username"]');
+ await page.keyboard.type('testuser', { delay: 50 });
+
+ let validity = await page.evaluate(el => ({
+ valid: el.validity.valid,
+ patternMismatch: el.validity.patternMismatch,
+ valueMissing: el.validity.valueMissing,
+ tooShort: el.validity.tooShort
+ }), usernameInput);
+
+ console.log(` Value: "testuser", Valid: ${validity.valid}, PatternMismatch: ${validity.patternMismatch}`);
+
+ if (validity.valid && !validity.patternMismatch) {
+ console.log('✅ Letters-only username is valid');
+ testsPassed++;
+ } else {
+ console.log('❌ Letters-only username incorrectly marked invalid');
+ testsFailed++;
+ }
+
+ // Clear the input
+ await page.evaluate(() => document.querySelector('input[name="username"]').value = '');
+
+ // Test 4: Type numbers only - should be valid
+ console.log('\n📋 Test 4: Typing numbers only');
+ await page.focus('input[name="username"]');
+ await page.keyboard.type('12345', { delay: 50 });
+
+ validity = await page.evaluate(el => ({
+ valid: el.validity.valid,
+ patternMismatch: el.validity.patternMismatch,
+ valueMissing: el.validity.valueMissing,
+ tooShort: el.validity.tooShort
+ }), usernameInput);
+
+ console.log(` Value: "12345", Valid: ${validity.valid}, PatternMismatch: ${validity.patternMismatch}`);
+
+ // Note: "12345" has 5 characters but minlength is 3, so it should pass length check
+ // It should NOT have a pattern mismatch since numbers are allowed
+ if (!validity.patternMismatch) {
+ console.log('✅ Numbers-only username does not trigger pattern mismatch');
+ testsPassed++;
+ } else {
+ console.log('❌ Numbers-only username incorrectly triggers pattern mismatch');
+ testsFailed++;
+ }
+
+ // Clear the input
+ await page.evaluate(() => document.querySelector('input[name="username"]').value = '');
+
+ // Test 5: Type mixed letters and numbers - should be valid
+ console.log('\n📋 Test 5: Typing mixed letters and numbers');
+ await page.focus('input[name="username"]');
+ await page.keyboard.type('user123', { delay: 50 });
+
+ validity = await page.evaluate(el => ({
+ valid: el.validity.valid,
+ patternMismatch: el.validity.patternMismatch,
+ valueMissing: el.validity.valueMissing,
+ tooShort: el.validity.tooShort
+ }), usernameInput);
+
+ console.log(` Value: "user123", Valid: ${validity.valid}, PatternMismatch: ${validity.patternMismatch}`);
+
+ if (validity.valid && !validity.patternMismatch) {
+ console.log('✅ Mixed letters/numbers username is valid');
+ testsPassed++;
+ } else {
+ console.log('❌ Mixed letters/numbers username incorrectly marked invalid');
+ testsFailed++;
+ }
+
+ // Clear the input
+ await page.evaluate(() => document.querySelector('input[name="username"]').value = '');
+
+ // Test 6: Type with underscores and hyphens - should be valid
+ console.log('\n📋 Test 6: Typing with underscores and hyphens');
+ await page.focus('input[name="username"]');
+ await page.keyboard.type('test_user-123', { delay: 50 });
+
+ validity = await page.evaluate(el => ({
+ valid: el.validity.valid,
+ patternMismatch: el.validity.patternMismatch,
+ valueMissing: el.validity.valueMissing,
+ tooShort: el.validity.tooShort
+ }), usernameInput);
+
+ console.log(` Value: "test_user-123", Valid: ${validity.valid}, PatternMismatch: ${validity.patternMismatch}`);
+
+ if (validity.valid && !validity.patternMismatch) {
+ console.log('✅ Username with underscores and hyphens is valid');
+ testsPassed++;
+ } else {
+ console.log('❌ Username with underscores and hyphens incorrectly marked invalid');
+ testsFailed++;
+ }
+
+ // Clear the input
+ await page.evaluate(() => document.querySelector('input[name="username"]').value = '');
+
+ // Test 7: Type special characters - should be invalid (pattern mismatch)
+ console.log('\n📋 Test 7: Typing special characters (should be invalid)');
+ await page.focus('input[name="username"]');
+ await page.keyboard.type('[email protected]', { delay: 50 });
+
+ validity = await page.evaluate(el => ({
+ valid: el.validity.valid,
+ patternMismatch: el.validity.patternMismatch,
+ valueMissing: el.validity.valueMissing,
+ tooShort: el.validity.tooShort
+ }), usernameInput);
+
+ console.log(` Value: "[email protected]", Valid: ${validity.valid}, PatternMismatch: ${validity.patternMismatch}`);
+
+ if (validity.patternMismatch) {
+ console.log('✅ Special characters correctly trigger pattern mismatch');
+ testsPassed++;
+ } else {
+ console.log('❌ Special characters should trigger pattern mismatch but did not');
+ testsFailed++;
+ }
+
+ // Clear the input
+ await page.evaluate(() => document.querySelector('input[name="username"]').value = '');
+
+ // Test 8: Check for any visual validation indicators
+ console.log('\n📋 Test 8: Visual validation state check');
+ await page.focus('input[name="username"]');
+ await page.keyboard.type('test123', { delay: 50 });
+
+ // Check for any CSS classes that might indicate invalid state
+ const inputClasses = await page.evaluate(el => el.className, usernameInput);
+ const hasInvalidClass = inputClasses.includes('invalid') ||
+ inputClasses.includes('is-invalid') ||
+ inputClasses.includes('error');
+
+ // Also check computed styles for any red border or warning colors
+ const computedStyle = await page.evaluate(el => {
+ const style = window.getComputedStyle(el);
+ return {
+ borderColor: style.borderColor,
+ backgroundColor: style.backgroundColor,
+ boxShadow: style.boxShadow
+ };
+ }, usernameInput);
+
+ console.log(` Classes: "${inputClasses}"`);
+ console.log(` Border color: ${computedStyle.borderColor}`);
+
+ // Check if there's a red/error border (common in validation)
+ const hasErrorBorder = computedStyle.borderColor.includes('rgb(255, 0, 0)') ||
+ computedStyle.borderColor.includes('rgb(220, 53, 69)') ||
+ computedStyle.borderColor.includes('rgb(250, 92, 124)');
+
+ if (!hasInvalidClass && !hasErrorBorder) {
+ console.log('✅ No visual error state for valid input "test123"');
+ testsPassed++;
+ } else {
+ console.log('❌ Visual error state detected for valid input');
+ if (hasInvalidClass) console.log(' Has invalid class');
+ if (hasErrorBorder) console.log(' Has error border color');
+ testsFailed++;
+ }
+
+ // Take a screenshot of the final state
+ await page.screenshot({
+ path: path.join(screenshotsDir, 'register_validation_test.png'),
+ fullPage: true
+ });
+ console.log('\n📸 Screenshot saved to screenshots/register_validation_test.png');
+
+ // Summary
+ console.log('\n' + '='.repeat(50));
+ console.log(`📊 Test Summary: ${testsPassed} passed, ${testsFailed} failed`);
+ console.log('='.repeat(50));
+
+ if (testsFailed > 0) {
+ throw new Error(`${testsFailed} test(s) failed`);
+ }
+
+ console.log('\n🎉 All registration validation tests passed!');
+
+ } catch (error) {
+ console.error('\n❌ Test failed:', error.message);
+
+ // Take error screenshot
+ try {
+ await page.screenshot({
+ path: path.join(screenshotsDir, 'register_validation_error.png'),
+ fullPage: true
+ });
+ console.log('📸 Error screenshot saved');
+ } catch (screenshotError) {
+ console.log('⚠️ Could not take error screenshot:', screenshotError.message);
+ }
+
+ await browser.close();
+ process.exit(1);
+ }
+
+ await browser.close();
+ console.log('\n✅ Test completed successfully');
+}
+
+// Run the test
+testRegisterValidation().catch(console.error);