mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
change equality checks to account for null and undefined (#16971)
This commit is contained in:
@@ -135,7 +135,7 @@ describe("ItemDetailsSectionComponent", () => {
|
||||
tick();
|
||||
|
||||
expect(cipherFormProvider.patchCipher).toHaveBeenCalled();
|
||||
const patchFn = cipherFormProvider.patchCipher.mock.lastCall[0];
|
||||
const patchFn = cipherFormProvider.patchCipher.mock.lastCall![0];
|
||||
|
||||
const updatedCipher = patchFn(new CipherView());
|
||||
|
||||
@@ -165,7 +165,7 @@ describe("ItemDetailsSectionComponent", () => {
|
||||
tick();
|
||||
|
||||
expect(cipherFormProvider.patchCipher).toHaveBeenCalled();
|
||||
const patchFn = cipherFormProvider.patchCipher.mock.lastCall[0];
|
||||
const patchFn = cipherFormProvider.patchCipher.mock.lastCall![0];
|
||||
|
||||
const updatedCipher = patchFn(new CipherView());
|
||||
|
||||
@@ -440,7 +440,7 @@ describe("ItemDetailsSectionComponent", () => {
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(cipherFormProvider.patchCipher).toHaveBeenCalled();
|
||||
const patchFn = cipherFormProvider.patchCipher.mock.lastCall[0];
|
||||
const patchFn = cipherFormProvider.patchCipher.mock.lastCall![0];
|
||||
|
||||
const updatedCipher = patchFn(new CipherView());
|
||||
|
||||
@@ -691,6 +691,35 @@ describe("ItemDetailsSectionComponent", () => {
|
||||
expect(enableFormFields).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("setFormState behavior with null/undefined", () => {
|
||||
it("calls disableFormFields when organizationId value is null", async () => {
|
||||
component.originalCipherView.organizationId = null as any;
|
||||
getInitialCipherView.mockReturnValue(component.originalCipherView);
|
||||
|
||||
await component.ngOnInit();
|
||||
|
||||
expect(disableFormFields).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls disableFormFields when organizationId value is undefined", async () => {
|
||||
component.originalCipherView.organizationId = undefined;
|
||||
getInitialCipherView.mockReturnValue(component.originalCipherView);
|
||||
|
||||
await component.ngOnInit();
|
||||
|
||||
expect(disableFormFields).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls enableFormFields when organizationId has a string value", async () => {
|
||||
component.originalCipherView.organizationId = "org-id" as any;
|
||||
getInitialCipherView.mockReturnValue(component.originalCipherView);
|
||||
|
||||
await component.ngOnInit();
|
||||
|
||||
expect(enableFormFields).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when an ownership change is not allowed", () => {
|
||||
|
||||
@@ -125,7 +125,7 @@ export class ItemDetailsSectionComponent implements OnInit {
|
||||
this.itemDetailsForm.controls.organizationId.disabled ||
|
||||
(!this.allowPersonalOwnership &&
|
||||
this.config.originalCipher &&
|
||||
this.itemDetailsForm.controls.organizationId.value === null)
|
||||
this.itemDetailsForm.controls.organizationId.value == null)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ export class ItemDetailsSectionComponent implements OnInit {
|
||||
// When editing a cipher and the user cannot have personal ownership
|
||||
// and the cipher is is not within the organization - force the user to
|
||||
// move the cipher within the organization first before editing any other field
|
||||
if (this.itemDetailsForm.controls.organizationId.value === null) {
|
||||
if (this.itemDetailsForm.controls.organizationId.value == null) {
|
||||
this.cipherFormContainer.disableFormFields();
|
||||
this.itemDetailsForm.controls.organizationId.enable();
|
||||
this.favoriteButtonDisabled = true;
|
||||
|
||||
Reference in New Issue
Block a user