diff --git a/app/components/register/PasswordStrength.vue b/app/components/register/PasswordStrength.vue index debcbf8..9be10cb 100644 --- a/app/components/register/PasswordStrength.vue +++ b/app/components/register/PasswordStrength.vue @@ -11,7 +11,8 @@ const score = computed(() => { const hasDigit = /\d/.test(p) const hasSpecial = /[^a-zA-Z\d]/.test(p) - if (p.length >= 8 && hasLower && hasDigit) s = 2 + const hasLetter = hasLower || hasUpper + if (p.length >= 8 && hasLetter && hasDigit) s = 2 if (p.length >= 10 && hasLower && hasUpper && hasDigit) s = 3 if (p.length >= 12 && hasLower && hasUpper && hasDigit && hasSpecial) s = 4 // Fallback: any input < 8 or single-type = weak diff --git a/app/components/register/__tests__/PasswordStrength.test.ts b/app/components/register/__tests__/PasswordStrength.test.ts index 82b70ef..37f9433 100644 --- a/app/components/register/__tests__/PasswordStrength.test.ts +++ b/app/components/register/__tests__/PasswordStrength.test.ts @@ -25,6 +25,12 @@ describe('PasswordStrength', () => { expect(wrapper.text()).toContain('中') }) + it('score 2 for uppercase letters+digits >= 8 chars', () => { + const wrapper = mount(PasswordStrength, { props: { password: 'ABC12345' } }) + expect(wrapper.find('[data-testid="strength-bar"]').attributes('data-score')).toBe('2') + expect(wrapper.text()).toContain('中') + }) + it('score 3 for upper+lower+digits >= 10 chars', () => { const wrapper = mount(PasswordStrength, { props: { password: 'Abcdef1234' } }) expect(wrapper.find('[data-testid="strength-bar"]').attributes('data-score')).toBe('3')