Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
0772d925
"backend/internal/vscode:/vscode.git/clone" did not exist on "b4fce470499d8e6e9d6e4a3c2251cc7f240dd678"
Commit
0772d925
authored
Mar 17, 2026
by
Wang Lvyuan
Browse files
fix(admin/accounts): reset edit modal state on reopen
parent
045cba78
Changes
2
Show whitespace changes
Inline
Side-by-side
frontend/src/components/account/EditAccountModal.vue
View file @
0772d925
...
...
@@ -1980,10 +1980,10 @@ const normalizePoolModeRetryCount = (value: number) => {
return
normalized
}
watch
(
()
=>
props
.
a
ccount
,
(
newAccount
)
=>
{
if
(
newAccount
)
{
const
syncFormFromAccount
=
(
newAccount
:
Account
|
null
)
=>
{
if
(
!
newA
ccount
)
{
return
}
antigravityMixedChannelConfirmed
.
value
=
false
showMixedChannelWarning
.
value
=
false
mixedChannelWarningDetails
.
value
=
null
...
...
@@ -2245,6 +2245,16 @@ watch(
selectedErrorCodes
.
value
=
[]
}
editApiKey
.
value
=
''
}
watch
(
[()
=>
props
.
show
,
()
=>
props
.
account
],
([
show
,
newAccount
],
[
wasShow
,
previousAccount
])
=>
{
if
(
!
show
||
!
newAccount
)
{
return
}
if
(
!
wasShow
||
newAccount
!==
previousAccount
)
{
syncFormFromAccount
(
newAccount
)
}
}
,
{
immediate
:
true
}
...
...
frontend/src/components/account/__tests__/EditAccountModal.spec.ts
0 → 100644
View file @
0772d925
import
{
describe
,
expect
,
it
,
vi
}
from
'
vitest
'
import
{
defineComponent
}
from
'
vue
'
import
{
mount
}
from
'
@vue/test-utils
'
const
{
updateAccountMock
,
checkMixedChannelRiskMock
}
=
vi
.
hoisted
(()
=>
({
updateAccountMock
:
vi
.
fn
(),
checkMixedChannelRiskMock
:
vi
.
fn
()
}))
vi
.
mock
(
'
@/stores/app
'
,
()
=>
({
useAppStore
:
()
=>
({
showError
:
vi
.
fn
(),
showSuccess
:
vi
.
fn
(),
showInfo
:
vi
.
fn
()
})
}))
vi
.
mock
(
'
@/stores/auth
'
,
()
=>
({
useAuthStore
:
()
=>
({
isSimpleMode
:
true
})
}))
vi
.
mock
(
'
@/api/admin
'
,
()
=>
({
adminAPI
:
{
accounts
:
{
update
:
updateAccountMock
,
checkMixedChannelRisk
:
checkMixedChannelRiskMock
}
}
}))
vi
.
mock
(
'
@/api/admin/accounts
'
,
()
=>
({
getAntigravityDefaultModelMapping
:
vi
.
fn
()
}))
vi
.
mock
(
'
vue-i18n
'
,
async
()
=>
{
const
actual
=
await
vi
.
importActual
<
typeof
import
(
'
vue-i18n
'
)
>
(
'
vue-i18n
'
)
return
{
...
actual
,
useI18n
:
()
=>
({
t
:
(
key
:
string
)
=>
key
})
}
})
import
EditAccountModal
from
'
../EditAccountModal.vue
'
const
BaseDialogStub
=
defineComponent
({
name
:
'
BaseDialog
'
,
props
:
{
show
:
{
type
:
Boolean
,
default
:
false
}
},
template
:
'
<div v-if="show"><slot /><slot name="footer" /></div>
'
})
const
ModelWhitelistSelectorStub
=
defineComponent
({
name
:
'
ModelWhitelistSelector
'
,
props
:
{
modelValue
:
{
type
:
Array
,
default
:
()
=>
[]
}
},
emits
:
[
'
update:modelValue
'
],
template
:
`
<div>
<button
type="button"
data-testid="rewrite-to-snapshot"
@click="$emit('update:modelValue', ['gpt-5.2-2025-12-11'])"
>
rewrite
</button>
<span data-testid="model-whitelist-value">
{{ Array.isArray(modelValue) ? modelValue.join(',') : '' }}
</span>
</div>
`
})
function
buildAccount
()
{
return
{
id
:
1
,
name
:
'
OpenAI Key
'
,
notes
:
''
,
platform
:
'
openai
'
,
type
:
'
apikey
'
,
credentials
:
{
api_key
:
'
sk-test
'
,
base_url
:
'
https://api.openai.com
'
,
model_mapping
:
{
'
gpt-5.2
'
:
'
gpt-5.2
'
}
},
extra
:
{},
proxy_id
:
null
,
concurrency
:
1
,
priority
:
1
,
rate_multiplier
:
1
,
status
:
'
active
'
,
group_ids
:
[],
expires_at
:
null
,
auto_pause_on_expired
:
false
}
as
any
}
function
mountModal
(
account
=
buildAccount
())
{
return
mount
(
EditAccountModal
,
{
props
:
{
show
:
true
,
account
,
proxies
:
[],
groups
:
[]
},
global
:
{
stubs
:
{
BaseDialog
:
BaseDialogStub
,
Select
:
true
,
Icon
:
true
,
ProxySelector
:
true
,
GroupSelector
:
true
,
ModelWhitelistSelector
:
ModelWhitelistSelectorStub
}
}
})
}
describe
(
'
EditAccountModal
'
,
()
=>
{
it
(
'
reopening the same account rehydrates the OpenAI whitelist from props
'
,
async
()
=>
{
const
account
=
buildAccount
()
updateAccountMock
.
mockReset
()
checkMixedChannelRiskMock
.
mockReset
()
checkMixedChannelRiskMock
.
mockResolvedValue
({
has_risk
:
false
})
updateAccountMock
.
mockResolvedValue
(
account
)
const
wrapper
=
mountModal
(
account
)
expect
(
wrapper
.
get
(
'
[data-testid="model-whitelist-value"]
'
).
text
()).
toBe
(
'
gpt-5.2
'
)
await
wrapper
.
get
(
'
[data-testid="rewrite-to-snapshot"]
'
).
trigger
(
'
click
'
)
expect
(
wrapper
.
get
(
'
[data-testid="model-whitelist-value"]
'
).
text
()).
toBe
(
'
gpt-5.2-2025-12-11
'
)
await
wrapper
.
setProps
({
show
:
false
})
await
wrapper
.
setProps
({
show
:
true
})
expect
(
wrapper
.
get
(
'
[data-testid="model-whitelist-value"]
'
).
text
()).
toBe
(
'
gpt-5.2
'
)
await
wrapper
.
get
(
'
form#edit-account-form
'
).
trigger
(
'
submit.prevent
'
)
expect
(
updateAccountMock
).
toHaveBeenCalledTimes
(
1
)
expect
(
updateAccountMock
.
mock
.
calls
[
0
]?.[
1
]?.
credentials
?.
model_mapping
).
toEqual
({
'
gpt-5.2
'
:
'
gpt-5.2
'
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment