// Comprehensive testing framework for Brazilian fintech applications. Use when implementing LGPD compliance, Portuguese voice validation, tRPC testing, Supabase RLS validation, or 4-phase quality control methodology.
| name | webapp-testing |
| description | Comprehensive testing framework for Brazilian fintech applications. Use when implementing LGPD compliance, Portuguese voice validation, tRPC testing, Supabase RLS validation, or 4-phase quality control methodology. |
| license | Apache 2.0 |
| metadata | {"version":"2.1.0","author":"AegisWallet Development Team","category":"testing","last-updated":"2025-11-27","domain":"brazilian-fintech-testing","expertise":["lgpd-compliance","voice-testing","trpc-testing","performance-testing","quality-control"]} |
Purpose: Comprehensive healthcare compliance testing framework for Brazilian fintech applications using Biome + Vitest integration.
When to use: Use this skill when you need to:
# Run all healthcare compliance tests
bun test:healthcare
# Run comprehensive healthcare test suite with quality gates
bun test:healthcare-full
# Run specific test categories
vitest run --config vitest.healthcare.config.ts src/test/healthcare/lgpd-compliance.test.ts
vitest run --config vitest.healthcare.config.ts src/test/healthcare/voice-interface.test.ts
# Run tests with Biome linting (50-100x faster than ESLint)
bun run lint && bun test:healthcare
# Generate comprehensive test report
bun scripts/run-healthcare-tests.ts
lgpd-compliance.test.ts)Purpose: Ensure Brazilian data protection law compliance
Test Coverage:
Key Validators:
// Custom LGPD compliance matcher
expect(maskedCPF).toBeLGPDCompliant('cpf')
expect(phone).toBeLGPDCompliant('phone')
// Consent validation
expect(patientData.lgpdConsent).toMatchObject({
timestamp: expect.any(String),
ip: '127.0.0.1',
deviceId: 'test-device-id',
consentType: 'treatment',
version: '1.0',
})
voice-interface.test.ts)Purpose: Validate Portuguese voice command processing for healthcare
Test Coverage:
Voice Command Examples:
// Financial commands
'transferir cem reais para João Silva'
'pagar consulta com Dr. Pedro'
'ver saldo da minha conta'
// Medical commands
'agendar consulta para amanhã'
'marcar exame com cardiologista'
'cancelar consulta de hoje'
trpc-integration.test.ts)Purpose: Type-safe API procedure testing with healthcare compliance
Test Coverage:
Key Patterns:
// Type-safe mocking with MSW
const trpc = createTRPCMsw<AppRouter>()
const mockProcedure = trpc.patients.getById.query((req, res, ctx) => {
// Validate LGPD compliance
if (!req.input.patientId) {
return res(ctx.status(400), ctx.data({
error: 'Patient ID required',
code: 'MISSING_PATIENT_ID'
}))
}
// Return masked patient data
return res(ctx.data({
id: req.input.id,
cpf: '***.***.***-**', // LGPD masked
phone: '+55******4321', // LGPD masked
}))
})
supabase-rls.test.ts)Purpose: Row Level Security policy validation for healthcare data
Test Coverage:
RLS Test Pattern:
await testRLSPolicy(
'authenticated', // User role
{ userId: 'patient-001' }, // User context
'select', // Operation
'patients', // Table
true // Expected access
)
vitest.healthcare.config.ts)Key Features:
export default defineConfig({
test: {
// Sequential testing for healthcare compliance
sequence: { concurrent: false, shuffle: false },
// Healthcare-specific coverage thresholds
coverage: {
thresholds: {
global: { branches: 90, functions: 90, lines: 90, statements: 90 },
'src/features/patients/**': { branches: 95, functions: 95, lines: 95, statements: 95 },
'src/features/appointments/**': { branches: 95, functions: 95, lines: 95, statements: 95 },
}
},
// Healthcare environment setup
globalSetup: './src/test/healthcare-global-setup.ts',
setupFiles: ['./src/test/healthcare-setup.ts'],
// Include healthcare-specific test files
include: [
'src/features/**/lgpd-compliance.test.{ts,tsx}',
'src/features/**/voice-interface.test.{ts,tsx}',
'src/features/**/healthcare-compliance.test.{ts,tsx}',
],
}
})
Healthcare-Specific Rules:
{
"files": {
"includes": [
"src/**/*.{test,spec}.{ts,tsx,js,jsx}",
"vitest.healthcare.config.ts"
]
},
"linter": {
"rules": {
"security": {
"noDangerouslySetInnerHtml": "warn"
},
"a11y": {
"noLabelWithoutControl": "warn",
"useButtonType": "warn"
},
"correctness": {
"useExhaustiveDependencies": "error"
}
}
}
}
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
import { expect } from 'vitest'
// Test consent flow
test('requires LGPD consent before data collection', async () => {
render(<PatientForm />)
const submitButton = screen.getByTestId('submit-patient')
expect(submitButton).toBeDisabled()
// Enable consent
await userEvent.click(screen.getByTestId('lgpd-consent'))
expect(submitButton).toBeEnabled()
})
// Mock speech recognition
global.SpeechRecognition = vi.fn().mockImplementation(() => ({
lang: 'pt-BR',
start: vi.fn(),
onresult: null,
}))
test('processes Portuguese voice commands', async () => {
const onCommand = vi.fn()
render(<VoiceAssistant onCommand={onCommand} />)
// Simulate voice command
await userEvent.click(screen.getByTestId('start-listening'))
await waitFor(() => {
expect(onCommand).toHaveBeenCalledWith(
expect.objectContaining({
command: 'transferir cem reais para João',
confidence: 0.95,
language: 'pt-BR',
})
)
})
})
import { createTRPCMsw } from 'msw-trpc'
import { setupServer } from 'msw/node'
test('validates LGPD compliance in API', async () => {
const trpc = createTRPCMsw<AppRouter>()
// Mock procedure with LGPD validation
trpc.patients.create.mutation((req, res, ctx) => {
if (!req.input.lgpdConsent) {
return res(ctx.status(400), ctx.data({
error: 'LGPD consent required',
code: 'LGPD_CONSENT_REQUIRED'
}))
}
return res(ctx.data({
...req.input,
cpf: '***.***.***-**', // Mask sensitive data
}))
})
const result = await trpc.patients.create.mutate({
name: 'Test Patient',
cpf: '12345678900',
// Missing LGPD consent
})
expect(result).toMatchObject({
error: 'LGPD consent required',
code: 'LGPD_CONSENT_REQUIRED'
})
})
import QualityControlTestingFramework from '@/test/utils/quality-control-integration'
test('full quality control workflow', async () => {
const qc = new QualityControlTestingFramework(global.testUtils)
// Phase 1: Detection
const detection = await qc.startDetectionPhase()
expect(detection.errors).toEqual(expect.any(Array))
// Phase 2: Research
const research = await qc.startResearchPhase(detection.errors)
expect(research.recommendations).toEqual(expect.any(Array))
// Phase 3: Planning
const planning = await qc.startPlanningPhase(research.research!)
expect(planning.plan?.atomicTasks).toEqual(expect.any(Array))
// Phase 4: Execution
const execution = await qc.startExecutionPhase(planning.plan!)
expect(execution.execution?.validationResults).toEqual(expect.any(Array))
})
const qualityMetrics = {
codeQuality: 95, // Biome score
security: 100, // LGPD + RLS compliance
performance: 92, // Core Web Vitals
compliance: 100, // Healthcare regulations
overall: 96.75 // Weighted average
}
1. Speech Recognition Mocking
// Ensure Web Speech API is properly mocked
beforeAll(() => {
global.SpeechRecognition = vi.fn()
global.webkitSpeechRecognition = global.SpeechRecognition
})
2. LGPD Data Masking
// Use custom matcher for validation
expect(patient.cpf).toBeLGPDCompliant('cpf')
expect(patient.phone).toBeLGPDCompliant('phone')
3. Supabase Authentication
// Mock JWT tokens for RLS testing
const createMockJWT = (payload) => {
const header = Buffer.from(JSON.stringify({ alg: 'HS256' })).toString('base64')
const body = Buffer.from(JSON.stringify(payload)).toString('base64')
return `${header}.${body}.mock-signature`
}
1. Test Execution
vitest.healthcare.config.ts for healthcare-specific configurationfileParallelism: false for data integrity2. Code Quality
bun lint + bun test)--coveragesrc/test/fixtures/patients/ - LGPD-compliant patient datasrc/test/fixtures/voice-commands/ - Portuguese voice commandssrc/test/fixtures/lgpd-audit/ - Audit trail examplesvitest.healthcare.config.ts - Healthcare test configurationbiome.json - Linting rules for test filessrc/test/healthcare-setup.ts - Global test setupsrc/test/healthcare-global-setup.ts - Test environment setupsrc/test/utils/quality-control-integration.ts - 4-phase methodologyscripts/run-healthcare-tests.ts - Comprehensive test runnerVersion: 2.0.0
Last Updated: 2025-01-20
Compatible: AegisWallet v1.0.0+
Requirements: Node.js 18+, Bun 1.0+, TypeScript 5.0+