From 5dfadbafba16ead0adcebd8cd75afd0b4bab5064 Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Mon, 3 Jun 2024 17:15:34 -0500 Subject: [PATCH] [PM-8027] Working through jest tests for the InlineMenuFieldQualificationService --- ...e-menu-field-qualification.service.spec.ts | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/apps/browser/src/autofill/services/inline-menu-field-qualification.service.spec.ts b/apps/browser/src/autofill/services/inline-menu-field-qualification.service.spec.ts index c0b2b9c8a3..52dc6e124a 100644 --- a/apps/browser/src/autofill/services/inline-menu-field-qualification.service.spec.ts +++ b/apps/browser/src/autofill/services/inline-menu-field-qualification.service.spec.ts @@ -19,27 +19,55 @@ describe("InlineMenuFieldQualificationService", () => { describe("validating a password field for a login form", () => { describe("an invalid password field", () => { it("has a `new-password` autoCompleteType", () => { - const newPasswordField = mock({ + const field = mock({ type: "password", autoCompleteType: "new-password", }); - expect( - inlineMenuFieldQualificationService.isFieldForLoginForm(newPasswordField, pageDetails), - ).toBe(false); + expect(inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails)).toBe( + false, + ); }); it("has a type that is an excluded type", () => { AutoFillConstants.ExcludedAutofillLoginTypes.forEach((excludedType) => { - const excludedField = mock({ + const field = mock({ type: excludedType, }); expect( - inlineMenuFieldQualificationService.isFieldForLoginForm(excludedField, pageDetails), + inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails), ).toBe(false); }); }); + + it("has an attribute present on the FieldIgnoreList, indicating that the field is a captcha", () => { + AutoFillConstants.FieldIgnoreList.forEach((attribute, index) => { + const field = mock({ + type: "password", + htmlID: index === 0 ? attribute : "", + htmlName: index === 1 ? attribute : "", + placeholder: index > 1 ? attribute : "", + }); + + expect( + inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails), + ).toBe(false); + }); + }); + + it("has a type other than `password` or `text`", () => { + const field = mock({ + type: "number", + htmlID: "not-password", + htmlName: "not-password", + placeholder: "not-password", + }); + + expect(inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails)).toBe( + false, + ); + }); }); describe("a valid password field", () => {});