@birhaus/test-utils
Version:
BIRHAUS Testing & Validation Framework - Comprehensive testing utilities for cognitive load, accessibility, and BIRHAUS principle compliance
109 lines (107 loc) • 3.78 kB
text/typescript
/**
* BIRHAUS Spanish Coverage Validator
*
* Comprehensive testing utilities for BIRHAUS Principle #7: "Bilingual by design"
*
* Features:
* - Spanish-first label validation
* - Bilingual completeness testing
* - Financial terminology coverage
* - Paraguay-specific language patterns
* - Cultural context validation
*/
interface SpanishCoverageViolation {
type: 'missing-spanish' | 'missing-english' | 'invalid-pattern' | 'financial-term' | 'cultural-context';
element: Element;
severity: 'minor' | 'moderate' | 'serious' | 'critical';
message: string;
messageEs: string;
currentText?: string;
suggestedSpanish?: string;
suggestedEnglish?: string;
birhausPrinciple: number;
context: 'navigation' | 'form' | 'button' | 'content' | 'error' | 'financial';
}
interface SpanishTestOptions {
requireSpanishPrimary?: boolean;
requireEnglishFallback?: boolean;
strictFinancialTerms?: boolean;
validateParaguayanSpanish?: boolean;
validateFinancialVocabulary?: boolean;
validateCurrencyFormats?: boolean;
checkBirhausComponents?: boolean;
checkErrorMessages?: boolean;
checkButtonLabels?: boolean;
checkFormLabels?: boolean;
birhausSelector?: string;
interactiveSelector?: string;
contentSelector?: string;
}
declare class SpanishCoverageValidator {
private options;
private readonly financialTerms;
private readonly spanishPatterns;
constructor(options?: SpanishTestOptions);
/**
* Validate all Spanish coverage requirements
*/
validateAll(container?: HTMLElement): SpanishCoverageViolation[];
/**
* Validate BIRHAUS components have Spanish-first labels
*/
validateBirhausComponents(container: HTMLElement): SpanishCoverageViolation[];
/**
* Validate button labels are in Spanish-first
*/
validateButtonLabels(container: HTMLElement): SpanishCoverageViolation[];
/**
* Validate form labels and placeholders
*/
validateFormLabels(container: HTMLElement): SpanishCoverageViolation[];
/**
* Validate error messages are in Spanish with "Qué pasó + cómo resolver" pattern
*/
validateErrorMessages(container: HTMLElement): SpanishCoverageViolation[];
/**
* Validate financial terminology is properly translated
*/
validateFinancialTerminology(container: HTMLElement): SpanishCoverageViolation[];
/**
* Validate currency formats follow Paraguay conventions
*/
validateCurrencyFormats(container: HTMLElement): SpanishCoverageViolation[];
private checkSpanishLabels;
private checkEnglishFallbacks;
private isSpanishText;
private getElementText;
private getElementContext;
private isFinancialElement;
private suggestSpanishLabel;
private suggestEnglishLabel;
private translateButtonText;
private translateFormLabel;
private translatePlaceholder;
private translateErrorMessage;
private translateToEnglish;
private hasProperErrorPattern;
private improveErrorPattern;
private getAssociatedLabel;
private isValidParaguayanCurrency;
private formatAsParaguayanCurrency;
}
/**
* Test helper functions for Spanish coverage assertions
*/
/**
* Assert Spanish-first compliance
*/
declare function expectSpanishFirst(container?: HTMLElement, strict?: boolean): void;
/**
* Assert bilingual completeness
*/
declare function expectBilingualCompleteness(container?: HTMLElement): void;
/**
* Assert financial terminology is properly translated
*/
declare function expectFinancialSpanish(container?: HTMLElement): void;
export { SpanishCoverageValidator, type SpanishCoverageViolation, type SpanishTestOptions, expectBilingualCompleteness, expectFinancialSpanish, expectSpanishFirst };