Skip to content

Commit aaccfcf

Browse files
committed
fix(chat): preserve password visibility on regenerate
1 parent a3d1c0e commit aaccfcf

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

apps/sim/components/ui/generated-password-input.test.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,26 @@ describe('GeneratedPasswordInput', () => {
134134
expect(passwordInput()).not.toHaveAttribute('placeholder', '••••••••')
135135
})
136136

137-
it('reveals a generated password without fetching the saved password', () => {
137+
it('keeps a generated password hidden when the field is hidden', () => {
138138
const fetchCurrentPassword = vi.fn().mockResolvedValue('saved-secret')
139139
const onChange = vi.fn()
140140
renderInput({ fetchCurrentPassword, onChange, showGenerate: true })
141141

142142
act(() => passwordButton('Generate password').click())
143143

144144
expect(fetchCurrentPassword).not.toHaveBeenCalled()
145+
expect(passwordInput()).toHaveAttribute('type', 'password')
146+
expect(onChange).toHaveBeenCalledWith(expect.stringMatching(/^.{24}$/))
147+
})
148+
149+
it('keeps a generated password visible when the field is visible', async () => {
150+
const fetchCurrentPassword = vi.fn().mockResolvedValue('saved-secret')
151+
const onChange = vi.fn()
152+
renderInput({ fetchCurrentPassword, onChange, showGenerate: true })
153+
154+
await act(async () => passwordButton('Show password').click())
155+
act(() => passwordButton('Generate password').click())
156+
145157
expect(passwordInput()).toHaveAttribute('type', 'text')
146158
expect(onChange).toHaveBeenCalledWith(expect.stringMatching(/^.{24}$/))
147159
})

apps/sim/components/ui/generated-password-input.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export function GeneratedPasswordInput({
6666

6767
const handleGeneratePassword = () => {
6868
handleChange(generatePassword(24))
69-
setShowPassword(true)
7069
}
7170

7271
const toggleShowPassword = async () => {

0 commit comments

Comments
 (0)