mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-07 13:00:59 +08:00
fix(web): unify password validation logic in RegisterPage (#943)
Remove duplicate password validation logic to ensure consistency. Changes: - Remove custom isStrongPassword function (RegisterPage.tsx:569-576) - Use PasswordChecklist validation result (passwordValid state) instead - Add comprehensive test suite with 28 test cases - Configure Vitest with jsdom environment and setup file Test Coverage: - Password validation rules (length, uppercase, lowercase, number, special chars) - Special character consistency (/[@#$%!&*?]/) - Edge cases and boundary conditions - Refactoring consistency verification All 78 tests passing (25 + 25 + 28). Co-authored-by: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
32
web/src/test/setup.ts
Normal file
32
web/src/test/setup.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import '@testing-library/jest-dom'
|
||||
import { beforeAll, afterEach } from 'vitest'
|
||||
|
||||
// Mock localStorage
|
||||
const localStorageMock = {
|
||||
getItem: (key: string) => {
|
||||
return localStorageMock._store[key] || null
|
||||
},
|
||||
setItem: (key: string, value: string) => {
|
||||
localStorageMock._store[key] = value
|
||||
},
|
||||
removeItem: (key: string) => {
|
||||
delete localStorageMock._store[key]
|
||||
},
|
||||
clear: () => {
|
||||
localStorageMock._store = {}
|
||||
},
|
||||
_store: {} as Record<string, string>,
|
||||
}
|
||||
|
||||
// Setup before all tests
|
||||
beforeAll(() => {
|
||||
Object.defineProperty(window, 'localStorage', {
|
||||
value: localStorageMock,
|
||||
writable: true,
|
||||
})
|
||||
})
|
||||
|
||||
// Clean up after each test
|
||||
afterEach(() => {
|
||||
localStorageMock.clear()
|
||||
})
|
||||
Reference in New Issue
Block a user