~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat: add inline form validation utility with ARIA support (#1985)
LearningCircuitcdc82fb8d87d
diff --git a/src/local_deep_research/web/static/css/styles.css b/src/local_deep_research/web/static/css/styles.cssindex 2b8aa58efe..f89fce7526 100644--- a/src/local_deep_research/web/static/css/styles.css+++ b/src/local_deep_research/web/static/css/styles.css@@ -2742,6 +2742,24 @@ input[type="number"].ldr-form-control::-webkit-inner-spin-button {color: var(--accent-tertiary);}+/* Form validation styles */+.ldr-field-invalid {+ border-color: var(--error-color) !important;+ box-shadow: 0 0 0 2px rgba(var(--error-color-rgb), 0.2);+}++.ldr-field-invalid:focus {+ border-color: var(--error-color) !important;+ box-shadow: 0 0 0 3px rgba(var(--error-color-rgb), 0.3);+}++.ldr-field-error {+ color: var(--error-color);+ font-size: 0.85rem;+ margin-top: 0.25rem;+ display: none;+}+/* Inline Error Message */.ldr-inline-error {display: flex;diff --git a/src/local_deep_research/web/static/js/components/research.js b/src/local_deep_research/web/static/js/components/research.jsindex 92e1168d78..dda362009c 100644--- a/src/local_deep_research/web/static/js/components/research.js+++ b/src/local_deep_research/web/static/js/components/research.js@@ -4,6 +4,9 @@* Manages the research form and handles submissions*/(function() {+ // Form validator instance+ let researchValidator = null;+// DOM Elementslet form = null;let queryInput = null;@@ -617,6 +620,16 @@function setupEventListeners() {if (!form || !startBtn) return;+ // Setup inline form validation for query field+ if (window.FormValidator && queryInput) {+ researchValidator = new window.FormValidator();+ researchValidator.addValidation(+ queryInput,+ window.formValidators.required('Please enter a research query.'),+ { validateOnBlur: true, validateOnInput: false }+ );+ }+// INITIALIZE ADVANCED OPTIONS FIRST - before any async operations// Advanced options toggle - make immediately responsiveif (advancedToggle && advancedPanel) {@@ -2270,6 +2283,23 @@event.preventDefault();SafeLogger.log('Research form submitted');+ // Validate the query BEFORE any UI changes+ const query = queryInput.value.trim();+ if (!query) {+ if (researchValidator) {+ researchValidator.validateAll();+ queryInput.focus();+ } else {+ showAlert('Please enter a research query.', 'error');+ }+ return;+ }++ // Clear any previous validation errors+ if (researchValidator) {+ researchValidator.clearErrors();+ }+// Disable the submit button to prevent multiple submissionsstartBtn.disabled = true;@@ -2300,8 +2330,7 @@const selectedModeRadio = document.querySelector('input[name="research_mode"]:checked');const mode = selectedModeRadio ? selectedModeRadio.value : 'quick';- // Get values from form fields- const query = queryInput.value.trim();+ // Get values from form fields (query already read above)const modelProvider = modelProviderSelect ? modelProviderSelect.value : '';// Get values from hidden inputs for custom dropdowns@@ -2325,23 +2354,6 @@const questionsInput = document.getElementById('questions_per_iteration');const questionsPerIteration = questionsInput ? parseInt(questionsInput.value) : 3;- // Validate the query- if (!query) {- // Show error if query is empty- showAlert('Please enter a research query.', 'error');-- // Re-enable the button- startBtn.disabled = false;- // Use centralized security utilities for button reset- window.safeUpdateButton(startBtn, 'fa-rocket', ' Start Research');-- // Remove loading overlay- const overlay = document.querySelector('.ldr-loading-overlay');- if (overlay) overlay.remove();-- return;- }-// Prepare the data for submissionconst formData = {query: query,diff --git a/src/local_deep_research/web/static/js/utils/form-validation.js b/src/local_deep_research/web/static/js/utils/form-validation.jsnew file mode 100644index 0000000000..ea81f5c6c6--- /dev/null+++ b/src/local_deep_research/web/static/js/utils/form-validation.js@@ -0,0 +1,168 @@+/**+ * Form Validation Utility+ * Provides inline validation with ARIA support+ */+(function() {+ 'use strict';++ /**+ * FormValidator class for managing form field validation+ */+ class FormValidator {+ constructor() {+ this.validators = new Map();+ this.errorElements = new Map();+ }++ /**+ * Add validation to a field+ * @param {HTMLElement|string} field - Field element or selector+ * @param {Function} validatorFn - Function that returns error message or null+ * @param {Object} options - Validation options+ * @param {boolean} options.validateOnBlur - Validate when field loses focus+ * @param {boolean} options.validateOnInput - Validate on input change+ */+ addValidation(field, validatorFn, options = {}) {+ const element = typeof field === 'string' ? document.querySelector(field) : field;+ if (!element) return;++ const { validateOnBlur = true, validateOnInput = false } = options;++ this.validators.set(element, validatorFn);++ // Ensure the field has an ID for aria-describedby+ if (!element.id) {+ element.id = `form-field-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;+ }++ // Create error element+ const errorId = `${element.id}-error`;+ let errorElement = document.getElementById(errorId);+ if (!errorElement) {+ errorElement = document.createElement('div');+ errorElement.id = errorId;+ errorElement.className = 'ldr-field-error';+ errorElement.setAttribute('aria-live', 'polite');+ element.parentNode.insertBefore(errorElement, element.nextSibling);+ }+ this.errorElements.set(element, errorElement);++ // Set up aria-describedby+ const existingDescribedBy = element.getAttribute('aria-describedby');+ if (!existingDescribedBy || !existingDescribedBy.includes(errorId)) {+ element.setAttribute('aria-describedby',+ existingDescribedBy ? `${existingDescribedBy} ${errorId}` : errorId);+ }++ // Add event listeners+ if (validateOnBlur) {+ element.addEventListener('blur', () => this.validateField(element));+ }+ if (validateOnInput) {+ element.addEventListener('input', () => this.validateField(element));+ }+ }++ /**+ * Validate a single field+ * @param {HTMLElement} element - The field to validate+ * @returns {boolean} - Whether the field is valid+ */+ validateField(element) {+ const validatorFn = this.validators.get(element);+ const errorElement = this.errorElements.get(element);++ if (!validatorFn) return true;++ const errorMessage = validatorFn(element.value, element);++ if (errorMessage) {+ element.classList.add('ldr-field-invalid');+ element.setAttribute('aria-invalid', 'true');+ if (errorElement) {+ errorElement.textContent = errorMessage;+ errorElement.style.display = 'block';+ }+ return false;+ } else {+ element.classList.remove('ldr-field-invalid');+ element.removeAttribute('aria-invalid');+ if (errorElement) {+ errorElement.textContent = '';+ errorElement.style.display = 'none';+ }+ return true;+ }+ }++ /**+ * Validate all registered fields+ * @returns {boolean} - Whether all fields are valid+ */+ validateAll() {+ let allValid = true;+ this.validators.forEach((_, element) => {+ if (!this.validateField(element)) {+ allValid = false;+ }+ });+ return allValid;+ }++ /**+ * Clear all validation errors+ */+ clearErrors() {+ this.validators.forEach((_, element) => {+ element.classList.remove('ldr-field-invalid');+ element.removeAttribute('aria-invalid');+ const errorElement = this.errorElements.get(element);+ if (errorElement) {+ errorElement.textContent = '';+ errorElement.style.display = 'none';+ }+ });+ }++ /**+ * Show error on a specific field+ * @param {HTMLElement|string} field - Field element or selector+ * @param {string} message - Error message to display+ */+ showError(field, message) {+ const element = typeof field === 'string' ? document.querySelector(field) : field;+ if (!element) return;++ const errorElement = this.errorElements.get(element);+ element.classList.add('ldr-field-invalid');+ element.setAttribute('aria-invalid', 'true');+ if (errorElement) {+ errorElement.textContent = message;+ errorElement.style.display = 'block';+ }+ }+ }++ // Common validators+ const validators = {+ required: (message = 'This field is required') => (value) => {+ return value && value.trim() ? null : message;+ },+ minLength: (min, message) => (value) => {+ if (!value) return null; // Let required handle empty+ return value.length >= min ? null : (message || `Must be at least ${min} characters`);+ },+ maxLength: (max, message) => (value) => {+ if (!value) return null;+ return value.length <= max ? null : (message || `Must be no more than ${max} characters`);+ },+ pattern: (regex, message) => (value) => {+ if (!value) return null;+ return regex.test(value) ? null : (message || 'Invalid format');+ }+ };++ // Export to window+ window.FormValidator = FormValidator;+ window.formValidators = validators;+})();diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.htmlindex 667e75caaa..7353d38e99 100644--- a/src/local_deep_research/web/templates/base.html+++ b/src/local_deep_research/web/templates/base.html@@ -166,6 +166,9 @@<!-- Security Utilities --><script defer src="/static/js/security/xss-protection.js"></script>+ <!-- Form Utilities -->+ <script defer src="/static/js/utils/form-validation.js"></script>+<!-- Shared Components --><script defer src="/static/js/components/logpanel.js"></script>diff --git a/src/local_deep_research/web/templates/pages/research.html b/src/local_deep_research/web/templates/pages/research.htmlindex b4fc6c928e..abab83e1f1 100644--- a/src/local_deep_research/web/templates/pages/research.html+++ b/src/local_deep_research/web/templates/pages/research.html@@ -23,7 +23,7 @@<form id="research-form"><div class="ldr-form-group"><label for="query">Research Query</label>- <textarea id="query" name="query" rows="3" placeholder="Enter your research topic or question..." autofocus></textarea>+ <textarea id="query" name="query" rows="3" placeholder="Enter your research topic or question..." autofocus aria-required="true"></textarea><div class="ldr-search-hints"><div class="ldr-hint-row"><span class="ldr-hint-item">diff --git a/tests/ui_tests/run_all_tests.js b/tests/ui_tests/run_all_tests.jsindex 448be8599a..b2a2cf3b93 100644--- a/tests/ui_tests/run_all_tests.js+++ b/tests/ui_tests/run_all_tests.js@@ -265,6 +265,11 @@ const tests = [file: 'test_research_form_validation.js',description: 'Tests research form field validation'},+ {+ name: 'Form Validation ARIA Tests',+ file: 'test_form_validation_aria_ci.js',+ description: 'Tests inline form validation with ARIA support'+ },{name: 'Research Simple Test',file: 'test_research_simple.js',diff --git a/tests/ui_tests/test_form_validation_aria_ci.js b/tests/ui_tests/test_form_validation_aria_ci.jsnew file mode 100644index 0000000000..152ebf5459--- /dev/null+++ b/tests/ui_tests/test_form_validation_aria_ci.js@@ -0,0 +1,519 @@+#!/usr/bin/env node+/**+ * Form Validation ARIA Support Tests+ *+ * Tests the FormValidator utility on the research form:+ * - Inline error display with ldr-field-invalid class+ * - aria-invalid attribute toggling+ * - aria-describedby linking to error element+ * - aria-required on query textarea+ * - Error clears after typing valid input+ * - Validation fires on blur+ *+ * Run: node test_form_validation_aria_ci.js+ */++const { setupTest, teardownTest, TestResults, log, delay } = require('./test_lib');++// ============================================================================+// ARIA Attribute Tests+// ============================================================================+const AriaAttributeTests = {+ async queryHasAriaRequired(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });++ const result = await page.evaluate(() => {+ const query = document.querySelector('#query');+ return {+ exists: !!query,+ ariaRequired: query?.getAttribute('aria-required'),+ hasHtmlRequired: query?.hasAttribute('required')+ };+ });++ if (!result.exists) {+ return { passed: null, skipped: true, message: 'Query textarea not found' };+ }++ return {+ passed: result.ariaRequired === 'true' && !result.hasHtmlRequired,+ message: `aria-required="${result.ariaRequired}", HTML required=${result.hasHtmlRequired}`+ };+ },++ async formValidatorLoaded(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ const result = await page.evaluate(() => {+ return {+ hasFormValidator: typeof window.FormValidator === 'function',+ hasFormValidators: typeof window.formValidators === 'object' && window.formValidators !== null+ };+ });++ return {+ passed: result.hasFormValidator && result.hasFormValidators,+ message: `FormValidator=${result.hasFormValidator}, formValidators=${result.hasFormValidators}`+ };+ }+};++// ============================================================================+// Inline Validation Tests+// ============================================================================+const InlineValidationTests = {+ async emptySubmitShowsInlineError(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // Clear query and submit+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) {+ query.value = '';+ query.dispatchEvent(new Event('input', { bubbles: true }));+ }+ });++ // Click submit+ await page.click('button[type="submit"], .start-research, #start-research').catch(() => {});+ await delay(300);++ const result = await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (!query) return { exists: false };++ const hasInvalidClass = query.classList.contains('ldr-field-invalid');+ const ariaInvalid = query.getAttribute('aria-invalid');++ // Find the error element+ const errorId = query.getAttribute('aria-describedby');+ let errorElement = null;+ let errorText = '';+ let errorVisible = false;++ if (errorId) {+ // aria-describedby may contain multiple IDs+ const ids = errorId.split(' ');+ for (const id of ids) {+ const el = document.getElementById(id);+ if (el && el.classList.contains('ldr-field-error')) {+ errorElement = el;+ errorText = el.textContent;+ errorVisible = window.getComputedStyle(el).display !== 'none';+ break;+ }+ }+ }++ return {+ exists: true,+ hasInvalidClass,+ ariaInvalid,+ hasErrorElement: !!errorElement,+ errorText,+ errorVisible+ };+ });++ if (!result.exists) {+ return { passed: null, skipped: true, message: 'Query textarea not found' };+ }++ const passed = result.hasInvalidClass &&+ result.ariaInvalid === 'true' &&+ result.hasErrorElement &&+ result.errorVisible &&+ result.errorText.length > 0;++ return {+ passed,+ message: `invalid-class=${result.hasInvalidClass}, aria-invalid="${result.ariaInvalid}", ` ++ `error-visible=${result.errorVisible}, error="${result.errorText}"`+ };+ },++ async blurOnEmptyShowsError(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // Clear query field+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) {+ query.value = '';+ query.dispatchEvent(new Event('input', { bubbles: true }));+ }+ });++ // Focus then blur the query field+ await page.focus('#query');+ await delay(100);+ // Click somewhere else to trigger blur+ await page.click('label[for="query"]').catch(() =>+ page.click('h1').catch(() => {})+ );+ await delay(300);++ const result = await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (!query) return { exists: false };++ return {+ exists: true,+ hasInvalidClass: query.classList.contains('ldr-field-invalid'),+ ariaInvalid: query.getAttribute('aria-invalid')+ };+ });++ if (!result.exists) {+ return { passed: null, skipped: true, message: 'Query textarea not found' };+ }++ return {+ passed: result.hasInvalidClass && result.ariaInvalid === 'true',+ message: `After blur on empty: invalid-class=${result.hasInvalidClass}, aria-invalid="${result.ariaInvalid}"`+ };+ },++ async errorClearsOnValidSubmit(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // First trigger the error by submitting empty+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) {+ query.value = '';+ query.dispatchEvent(new Event('input', { bubbles: true }));+ }+ });+ await page.click('button[type="submit"], .start-research, #start-research').catch(() => {});+ await delay(300);++ // Verify error is shown+ const errorShown = await page.evaluate(() => {+ const query = document.querySelector('#query');+ return query?.classList.contains('ldr-field-invalid') === true;+ });++ if (!errorShown) {+ return { passed: null, skipped: true, message: 'Could not trigger validation error first' };+ }++ // Now type a valid query - this should clear the error on next submit attempt+ await page.focus('#query');+ await page.keyboard.type('Test research query');+ await delay(100);++ // Submit again - should clear errors and proceed+ // We intercept the fetch to avoid actual submission+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ return {+ hasInvalidClass: query?.classList.contains('ldr-field-invalid'),+ ariaInvalid: query?.getAttribute('aria-invalid')+ };+ });++ // Click submit - the validation should pass and clear errors+ await page.click('button[type="submit"], .start-research, #start-research').catch(() => {});+ await delay(500);++ const result = await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (!query) return { exists: false };++ return {+ exists: true,+ hasInvalidClass: query.classList.contains('ldr-field-invalid'),+ ariaInvalid: query.getAttribute('aria-invalid')+ };+ });++ if (!result.exists) {+ return { passed: null, skipped: true, message: 'Query textarea not found' };+ }++ return {+ passed: !result.hasInvalidClass && result.ariaInvalid !== 'true',+ message: `After valid submit: invalid-class=${result.hasInvalidClass}, aria-invalid="${result.ariaInvalid}"`+ };+ },++ async noLoadingUiOnEmptySubmit(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // Clear query+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) {+ query.value = '';+ query.dispatchEvent(new Event('input', { bubbles: true }));+ }+ });++ // Submit and immediately check for loading overlay+ await page.click('button[type="submit"], .start-research, #start-research').catch(() => {});++ // Check immediately - there should be no loading overlay or spinner+ const result = await page.evaluate(() => {+ const overlay = document.querySelector('.ldr-loading-overlay');+ const btn = document.querySelector('button[type="submit"], .start-research, #start-research');+ const btnDisabled = btn?.disabled;+ const btnHasSpinner = btn?.innerHTML?.includes('fa-spinner');++ return {+ hasOverlay: !!overlay,+ btnDisabled: !!btnDisabled,+ btnHasSpinner: !!btnHasSpinner+ };+ });++ return {+ passed: !result.hasOverlay && !result.btnDisabled && !result.btnHasSpinner,+ message: `On empty submit: overlay=${result.hasOverlay}, btn-disabled=${result.btnDisabled}, spinner=${result.btnHasSpinner}`+ };+ }+};++// ============================================================================+// Error Element Structure Tests+// ============================================================================+const ErrorElementTests = {+ async errorElementHasAriaLive(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // Trigger validation to create error element+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) {+ query.value = '';+ query.dispatchEvent(new Event('input', { bubbles: true }));+ }+ });+ await page.focus('#query');+ await delay(100);+ await page.click('label[for="query"]').catch(() =>+ page.click('h1').catch(() => {})+ );+ await delay(300);++ const result = await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (!query) return { exists: false };++ const describedBy = query.getAttribute('aria-describedby');+ if (!describedBy) return { exists: true, hasDescribedBy: false };++ const ids = describedBy.split(' ');+ for (const id of ids) {+ const el = document.getElementById(id);+ if (el && el.classList.contains('ldr-field-error')) {+ return {+ exists: true,+ hasDescribedBy: true,+ errorId: id,+ ariaLive: el.getAttribute('aria-live'),+ className: el.className+ };+ }+ }++ return { exists: true, hasDescribedBy: true, errorElementFound: false };+ });++ if (!result.exists) {+ return { passed: null, skipped: true, message: 'Query textarea not found' };+ }++ if (!result.hasDescribedBy) {+ return { passed: false, message: 'No aria-describedby on query field' };+ }++ return {+ passed: result.ariaLive === 'polite',+ message: `Error element: id="${result.errorId}", aria-live="${result.ariaLive}", class="${result.className}"`+ };+ },++ async errorPositionedAfterTextarea(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // Trigger validation+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) query.value = '';+ });+ await page.focus('#query');+ await delay(100);+ await page.click('label[for="query"]').catch(() =>+ page.click('h1').catch(() => {})+ );+ await delay(300);++ const result = await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (!query) return { exists: false };++ const nextSibling = query.nextElementSibling;+ const isErrorElement = nextSibling?.classList.contains('ldr-field-error');+ const searchHints = query.parentNode?.querySelector('.ldr-search-hints');++ return {+ exists: true,+ nextSiblingIsError: isErrorElement,+ nextSiblingClass: nextSibling?.className,+ hintsExist: !!searchHints+ };+ });++ if (!result.exists) {+ return { passed: null, skipped: true, message: 'Query textarea not found' };+ }++ return {+ passed: result.nextSiblingIsError,+ message: `Next sibling after textarea: class="${result.nextSiblingClass}", hints exist=${result.hintsExist}`+ };+ },++ async focusMovesToFieldOnError(page, baseUrl) {+ await page.goto(`${baseUrl}/`, { waitUntil: 'networkidle2' });+ await delay(500);++ // Clear and submit+ await page.evaluate(() => {+ const query = document.querySelector('#query');+ if (query) {+ query.value = '';+ query.dispatchEvent(new Event('input', { bubbles: true }));+ // Focus something else first+ document.body.focus();+ }+ });++ await page.click('button[type="submit"], .start-research, #start-research').catch(() => {});+ await delay(300);++ const result = await page.evaluate(() => {+ const activeElement = document.activeElement;+ return {+ focusedId: activeElement?.id,+ focusedTag: activeElement?.tagName?.toLowerCase()+ };+ });++ return {+ passed: result.focusedId === 'query',+ message: `Focus after empty submit: id="${result.focusedId}", tag="${result.focusedTag}"`+ };+ }+};++// ============================================================================+// Main Test Runner+// ============================================================================+async function main() {+ log.section('Form Validation ARIA Support Tests');++ const ctx = await setupTest({ authenticate: true });+ const results = new TestResults('Form Validation ARIA Tests');+ const { page } = ctx;+ const { baseUrl } = ctx.config;++ try {+ // ARIA Attribute Tests+ log.section('ARIA Attributes');++ const ariaRequiredResult = await AriaAttributeTests.queryHasAriaRequired(page, baseUrl);+ if (ariaRequiredResult.skipped) {+ results.skip('ARIA', 'Query has aria-required', ariaRequiredResult.message);+ } else {+ results.add('ARIA', 'Query has aria-required', ariaRequiredResult.passed, ariaRequiredResult.message);+ }++ const validatorLoadedResult = await AriaAttributeTests.formValidatorLoaded(page, baseUrl);+ results.add('ARIA', 'FormValidator loaded', validatorLoadedResult.passed, validatorLoadedResult.message);++ // Inline Validation Tests+ log.section('Inline Validation');++ const emptySubmitResult = await InlineValidationTests.emptySubmitShowsInlineError(page, baseUrl);+ if (emptySubmitResult.skipped) {+ results.skip('Validation', 'Empty submit shows inline error', emptySubmitResult.message);+ } else {+ results.add('Validation', 'Empty submit shows inline error', emptySubmitResult.passed, emptySubmitResult.message);+ }++ const blurResult = await InlineValidationTests.blurOnEmptyShowsError(page, baseUrl);+ if (blurResult.skipped) {+ results.skip('Validation', 'Blur on empty shows error', blurResult.message);+ } else {+ results.add('Validation', 'Blur on empty shows error', blurResult.passed, blurResult.message);+ }++ const clearResult = await InlineValidationTests.errorClearsOnValidSubmit(page, baseUrl);+ if (clearResult.skipped) {+ results.skip('Validation', 'Error clears on valid submit', clearResult.message);+ } else {+ results.add('Validation', 'Error clears on valid submit', clearResult.passed, clearResult.message);+ }++ const noLoadingResult = await InlineValidationTests.noLoadingUiOnEmptySubmit(page, baseUrl);+ results.add('Validation', 'No loading UI on empty submit', noLoadingResult.passed, noLoadingResult.message);++ // Error Element Structure Tests+ log.section('Error Element Structure');++ const ariaLiveResult = await ErrorElementTests.errorElementHasAriaLive(page, baseUrl);+ if (ariaLiveResult.skipped) {+ results.skip('Structure', 'Error element has aria-live=polite', ariaLiveResult.message);+ } else {+ results.add('Structure', 'Error element has aria-live=polite', ariaLiveResult.passed, ariaLiveResult.message);+ }++ const positionResult = await ErrorElementTests.errorPositionedAfterTextarea(page, baseUrl);+ if (positionResult.skipped) {+ results.skip('Structure', 'Error positioned after textarea', positionResult.message);+ } else {+ results.add('Structure', 'Error positioned after textarea', positionResult.passed, positionResult.message);+ }++ const focusResult = await ErrorElementTests.focusMovesToFieldOnError(page, baseUrl);+ results.add('Structure', 'Focus moves to field on error', focusResult.passed, focusResult.message);++ } catch (error) {+ const isNavigationError = error.message &&+ (error.message.includes('context was destroyed') ||+ error.message.includes('Target closed') ||+ error.message.includes('Protocol error') ||+ error.message.includes('Session closed') ||+ error.message.includes('page has been closed'));++ if (isNavigationError) {+ log.warn(`Browser navigation error (test infrastructure issue): ${error.message}`);+ } else {+ log.error(`Fatal error: ${error.message}`);+ console.error(error.stack);+ }+ } finally {+ results.print();+ results.save();+ await teardownTest(ctx);+ process.exit(results.exitCode());+ }+}++if (require.main === module) {+ main().catch(error => {+ console.error('Test runner failed:', error);+ process.exit(1);+ });+}++module.exports = { AriaAttributeTests, InlineValidationTests, ErrorElementTests };