fix(mail-webui): constrain focused profile updates
This commit is contained in:
@@ -18,7 +18,9 @@ import {
|
||||
mailProfileEditTargetPanelMode,
|
||||
mailProfileEditTargetShowsProfileFields,
|
||||
mailProfileEditTargetShowsSettingsPanel,
|
||||
mailProfileEditTargetVisibleSections
|
||||
mailProfileEditTargetVisibleSections,
|
||||
mailProfileCreateCredentialsPayload,
|
||||
mailProfileTargetedUpdatePayload
|
||||
} from "../src/features/mail/mailProfileEditorModel";
|
||||
|
||||
const smtpOnlyChildren = mailProfileChildDescriptors({ id: "profile-1", imap: null });
|
||||
@@ -46,3 +48,42 @@ assertEqual(mailProfileEditTargetShowsProfileFields({ kind: "profile" }), true);
|
||||
assertEqual(mailProfileEditTargetShowsProfileFields({ kind: "server", protocol: "smtp" }), false);
|
||||
assertEqual(mailProfileEditTargetShowsSettingsPanel({ kind: "profile" }), false);
|
||||
assertEqual(mailProfileEditTargetShowsSettingsPanel({ kind: "create" }), true);
|
||||
|
||||
const updateParts = {
|
||||
profile: { name: "Renamed" },
|
||||
smtp: { host: "smtp.example.org" },
|
||||
imap: { host: "imap.example.org" },
|
||||
credentials: {
|
||||
smtp: { username: "smtp-user", password: "smtp-secret" },
|
||||
imap: { username: "imap-user", password: "imap-secret" }
|
||||
},
|
||||
clearImap: false
|
||||
};
|
||||
assertDeepEqual(
|
||||
mailProfileTargetedUpdatePayload({ kind: "profile" }, updateParts),
|
||||
{ name: "Renamed" },
|
||||
"profile edits do not replay transport or credential fields"
|
||||
);
|
||||
assertDeepEqual(
|
||||
mailProfileTargetedUpdatePayload({ kind: "server", protocol: "smtp" }, updateParts),
|
||||
{ smtp: { host: "smtp.example.org" } },
|
||||
"server edits do not replay credential fields"
|
||||
);
|
||||
assertDeepEqual(
|
||||
mailProfileTargetedUpdatePayload({ kind: "credentials", protocol: "imap" }, updateParts),
|
||||
{ credentials: { imap: { username: "imap-user", password: "imap-secret" } } },
|
||||
"credential edits send only the selected protocol"
|
||||
);
|
||||
assertEqual(
|
||||
mailProfileCreateCredentialsPayload({ username: null }, { password: "" }),
|
||||
undefined,
|
||||
"credential-free creates omit the credential object"
|
||||
);
|
||||
assertDeepEqual(
|
||||
mailProfileCreateCredentialsPayload(
|
||||
{ username: "smtp-user", password: null },
|
||||
{ username: null, password: "imap-secret" }
|
||||
),
|
||||
{ smtp: { username: "smtp-user" }, imap: { password: "imap-secret" } },
|
||||
"create payloads retain only explicitly populated credential fields"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user