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
21f349c0
Unverified
Commit
21f349c0
authored
Mar 18, 2026
by
Wesley Liddick
Committed by
GitHub
Mar 18, 2026
Browse files
Merge pull request #1095 from LvyuanW/lvyuan/dev
fix(admin/accounts): reset edit modal state on reopen
parents
28e36f79
0772d925
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/account/EditAccountModal.vue
View file @
21f349c0
This diff is collapsed.
Click to expand it.
frontend/src/components/account/__tests__/EditAccountModal.spec.ts
0 → 100644
View file @
21f349c0
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