[PM-33459] fix(autofill): exclude username-only scenario from new cipher save notification (#19733)

* [pm-33459] fix: exclude username-only input from new cipher notification trigger in triggerCipherNotification

Signed-off-by: Ben Brooks <bbrooks@bitwarden.com>
This commit is contained in:
Ben Brooks 2026-03-27 07:38:48 -07:00 committed by GitHub
parent 50cf5bde99
commit 190997c4a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 11 deletions

View File

@ -1642,7 +1642,7 @@ describe("NotificationBackground", () => {
expect(pushAddLoginToQueueSpy).not.toHaveBeenCalled();
});
it("and no cipher update candidates match `username`, trigger a new cipher notification", async () => {
it("and no cipher update candidates match `username`, do not trigger a notification (username alone is insufficient signal)", async () => {
const storedCiphersForURL = [
mock<CipherView>({
id: "cipher-id-1",
@ -1660,15 +1660,7 @@ describe("NotificationBackground", () => {
await notificationBackground.triggerCipherNotification(formEntryData, tab);
expect(pushChangePasswordToQueueSpy).not.toHaveBeenCalled();
expect(pushAddLoginToQueueSpy).toHaveBeenCalledWith(
mockFormattedURI,
{
password: "",
url: formEntryData.uri,
username: formEntryData.username,
},
sender.tab,
);
expect(pushAddLoginToQueueSpy).not.toHaveBeenCalled();
});
it("and no cipher update candidates match `username`, do not trigger a new cipher notification if the new cipher notification setting is disabled", async () => {

View File

@ -1018,13 +1018,15 @@ export default class NotificationBackground {
// involves all ciphers, making it mutually exclusive from any other scenario)
if (noFieldMatches.length === ciphersForURL.length) {
// trigger a new cipher notification in these input scenarios
// Note: username-only is excluded because a username with no password is insufficient
// signal to assume a new login is being created. Multistep login forms accumulate
// username + password across steps, so the combined data will trigger on form submission.
if (
(
[
inputScenarios.usernamePasswordNewPassword,
inputScenarios.usernameNewPassword,
inputScenarios.usernamePassword,
inputScenarios.username,
inputScenarios.passwordNewPassword,
] as InputScenario[]
).includes(inputScenario) &&