修复编辑服务器时已保存密码仍被要求重填

This commit is contained in:
xuans 2026-09-25 23:21:34 +08:00
parent c3170291db
commit b920a6a132
2 changed files with 15 additions and 0 deletions

View File

@ -572,6 +572,7 @@ export function useDashboard() {
serverEditingId.value = item.id;
serverForm.value = {
...item,
passwordConfigured: item.password_configured === true,
password: "",
validation_command: (item.validation_command || []).join("\n"),
reload_command: (item.reload_command || []).join("\n"),

View File

@ -135,6 +135,20 @@ async function setup(t, request) {
return mounted;
}
test("编辑服务器正确保留已有密码状态,新建和未配置密码仍要求输入", async (t) => {
const { state } = await setup(t, () => verifiedResponse());
state.openServerEdit({ id: "configured", auth_method: "password", password_configured: true });
assert.equal(state.serverForm.value.passwordConfigured, true);
assert.equal(state.serverForm.value.password, "");
for (const password_configured of [false, undefined]) {
state.openServerEdit({ id: "missing", auth_method: "password", password_configured });
assert.equal(state.serverForm.value.passwordConfigured, false);
}
state.openServerCreate();
assert.equal(state.serverForm.value.passwordConfigured, false);
assert.equal(state.serverEditingId.value, "");
});
async function fill(state) {
state.settingsForm.value.dns.credentials = { access_key_id: "fake-key" };
state.settingsForm.value.dns.test_domain = "example.test";