Skip to content

Commit c4ff021

Browse files
committed
Fix tests
1 parent 77f4d00 commit c4ff021

File tree

7 files changed

+44
-30
lines changed

7 files changed

+44
-30
lines changed

apps/browser/src/vault/popup/services/vault-popup-list-filters.service.spec.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
1414
import { ProductTierType } from "@bitwarden/common/billing/enums";
1515
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
1616
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
17+
import { asUuid } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
1718
import { StateProvider } from "@bitwarden/common/platform/state";
1819
import { mockAccountServiceWith } from "@bitwarden/common/spec";
1920
import { UserId } from "@bitwarden/common/types/guid";
@@ -514,8 +515,17 @@ describe("VaultPopupListFiltersService", () => {
514515
describe("filterFunction$", () => {
515516
const ciphers = [
516517
{ type: CipherType.Login, collectionIds: [], organizationId: null },
517-
{ type: CipherType.Card, collectionIds: ["1234"], organizationId: "8978" },
518-
{ type: CipherType.Identity, collectionIds: [], folderId: "5432", organizationId: null },
518+
{
519+
type: CipherType.Card,
520+
collectionIds: [asUuid("cbcae898-9f9a-48eb-863e-edf92e3ad7e0")],
521+
organizationId: "8978" as any,
522+
},
523+
{
524+
type: CipherType.Identity,
525+
collectionIds: [],
526+
folderId: "5432" as any,
527+
organizationId: null,
528+
},
519529
{ type: CipherType.SecureNote, collectionIds: [], organizationId: null },
520530
] as CipherView[];
521531

@@ -529,7 +539,7 @@ describe("VaultPopupListFiltersService", () => {
529539
});
530540

531541
it("filters by collection", (done) => {
532-
const collection = { id: "1234" } as CollectionView;
542+
const collection = { id: "cbcae898-9f9a-48eb-863e-edf92e3ad7e0" } as CollectionView;
533543

534544
service.filterFunction$.subscribe((filterFunction) => {
535545
expect(filterFunction(ciphers)).toEqual([ciphers[1]]);

libs/angular/src/vault/vault-filter/models/vault-filter.model.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,18 @@ describe("VaultFilter", () => {
118118
});
119119

120120
describe("given an organizational cipher (with organization and collections)", () => {
121+
const collection1 = "e9652fc0-1fe4-48d5-a3d8-d821e32fbd98";
122+
const collection2 = "42a971a5-8c16-48a3-a725-4be27cd99bc9";
123+
121124
const cipher = createCipher({
122125
organizationId: "organizationId",
123-
collectionIds: ["collectionId", "anotherId"],
126+
collectionIds: [collection1, collection2],
124127
});
125128

126129
it("should return true when filter matches collection id", () => {
127130
const filterFunction = createFilterFunction({
128131
selectedCollection: true,
129-
selectedCollectionId: "collectionId",
132+
selectedCollectionId: collection1,
130133
});
131134

132135
const result = filterFunction(cipher);
@@ -137,7 +140,7 @@ describe("VaultFilter", () => {
137140
it("should return false when filter does not match collection id", () => {
138141
const filterFunction = createFilterFunction({
139142
selectedCollection: true,
140-
selectedCollectionId: "nonMatchingId",
143+
selectedCollectionId: "1ea7ad96-3fc1-4567-8fe5-91aa9f697fd1",
141144
});
142145

143146
const result = filterFunction(cipher);

libs/common/src/platform/services/sdk/default-sdk.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe("DefaultSdkService", () => {
6262
});
6363

6464
describe("given the user is logged in", () => {
65-
const userId = "user-id" as UserId;
65+
const userId = "0da62ebd-98bb-4f42-a846-64e8555087d7" as UserId;
6666
beforeEach(() => {
6767
environmentService.getEnvironment$
6868
.calledWith(userId)

libs/common/src/vault/models/domain/cipher.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,9 @@ describe("Cipher DTO", () => {
849849
const lastLaunched = new Date("2025-04-15T12:00:00.000Z").getTime();
850850

851851
const cipherData: CipherData = {
852-
id: "id",
853-
organizationId: "orgId",
854-
folderId: "folderId",
852+
id: "2afb03fd-0d8e-4c08-a316-18b2f0efa618",
853+
organizationId: "4748ad12-212e-4bc8-82b7-a75f6709d033",
854+
folderId: "b4dac811-e44a-495a-9334-9e53b7aaf54c",
855855
edit: true,
856856
permissions: new CipherPermissionsApi(),
857857
viewPassword: true,
@@ -920,9 +920,9 @@ describe("Cipher DTO", () => {
920920
const sdkCipher = cipher.toSdkCipher();
921921

922922
expect(sdkCipher).toEqual({
923-
id: "id",
924-
organizationId: "orgId",
925-
folderId: "folderId",
923+
id: "2afb03fd-0d8e-4c08-a316-18b2f0efa618",
924+
organizationId: "4748ad12-212e-4bc8-82b7-a75f6709d033",
925+
folderId: "b4dac811-e44a-495a-9334-9e53b7aaf54c",
926926
collectionIds: [],
927927
key: "EncryptedString",
928928
name: "EncryptedString",
@@ -1007,9 +1007,9 @@ describe("Cipher DTO", () => {
10071007
it("should map from SDK Cipher", () => {
10081008
jest.restoreAllMocks();
10091009
const sdkCipher: SdkCipher = {
1010-
id: "id",
1011-
organizationId: "orgId",
1012-
folderId: "folderId",
1010+
id: "id" as any,
1011+
organizationId: "orgId" as any,
1012+
folderId: "folderId" as any,
10131013
collectionIds: [],
10141014
key: "EncryptedString" as SdkEncString,
10151015
name: "EncryptedString" as SdkEncString,

libs/common/src/vault/models/view/cipher.view.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "@bitwarden/sdk-internal";
1515

1616
import { mockFromJson, mockFromSdk } from "../../../../spec";
17+
import { asUuid } from "../../../platform/abstractions/sdk/sdk.service";
1718
import { CipherRepromptType } from "../../enums";
1819
import { CipherType } from "../../enums/cipher-type";
1920

@@ -260,11 +261,11 @@ describe("CipherView", () => {
260261
const sdkCipherView = cipherView.toSdkCipherView();
261262

262263
expect(sdkCipherView).toMatchObject({
263-
id: "0a54d80c-14aa-4ef8-8c3a-7ea99ce5b602",
264-
organizationId: "000f2a6e-da5e-4726-87ed-1c5c77322c3c",
265-
folderId: "41b22db4-8e2a-4ed2-b568-f1186c72922f",
266-
collectionIds: ["b0473506-3c3c-4260-a734-dfaaf833ab6f"],
267-
key: "some-key",
264+
id: asUuid("0a54d80c-14aa-4ef8-8c3a-7ea99ce5b602"),
265+
organizationId: asUuid("000f2a6e-da5e-4726-87ed-1c5c77322c3c"),
266+
folderId: asUuid("41b22db4-8e2a-4ed2-b568-f1186c72922f"),
267+
collectionIds: [asUuid("b0473506-3c3c-4260-a734-dfaaf833ab6f")],
268+
key: "some-key" as any,
268269
name: "name",
269270
notes: "notes",
270271
type: SdkCipherType.Login,

libs/common/src/vault/services/default-cipher-encryption.service.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ describe("DefaultCipherEncryptionService", () => {
124124
cipherViewObj = new CipherView(cipherObj);
125125

126126
jest.spyOn(cipherObj, "toSdkCipher").mockImplementation(() => {
127-
return { id: cipherData.id } as SdkCipher;
127+
return { id: cipherData.id as any } as SdkCipher;
128128
});
129129

130130
jest.spyOn(cipherViewObj, "toSdkCipherView").mockImplementation(() => {
131-
return { id: cipherData.id } as SdkCipherView;
131+
return { id: cipherData.id as any } as SdkCipherView;
132132
});
133133

134134
sdkCipherView = {
135-
id: cipherId as string,
135+
id: cipherId as any,
136136
type: SdkCipherType.Login,
137137
name: "test-name",
138138
login: {
@@ -334,7 +334,7 @@ describe("DefaultCipherEncryptionService", () => {
334334
.vault()
335335
.ciphers()
336336
.set_fido2_credentials.mockReturnValue({
337-
id: cipherId as string,
337+
id: cipherId as any,
338338
login: {
339339
fido2Credentials: [mockSdkCredentialView],
340340
},
@@ -519,8 +519,8 @@ describe("DefaultCipherEncryptionService", () => {
519519
const ciphers = [new Cipher(cipherData), new Cipher(cipherData)];
520520

521521
const expectedListViews = [
522-
{ id: "list1", name: "List 1" } as CipherListView,
523-
{ id: "list2", name: "List 2" } as CipherListView,
522+
{ id: "list1" as any, name: "List 1" } as CipherListView,
523+
{ id: "list2" as any, name: "List 2" } as CipherListView,
524524
];
525525

526526
mockSdkClient.vault().ciphers().decrypt_list.mockReturnValue(expectedListViews);
@@ -554,7 +554,7 @@ describe("DefaultCipherEncryptionService", () => {
554554
const encryptedContent = new Uint8Array([1, 2, 3, 4]);
555555
const expectedDecryptedContent = new Uint8Array([5, 6, 7, 8]);
556556

557-
jest.spyOn(cipher, "toSdkCipher").mockReturnValue({ id: "id" } as SdkCipher);
557+
jest.spyOn(cipher, "toSdkCipher").mockReturnValue({ id: "id" as any } as SdkCipher);
558558
jest
559559
.spyOn(attachment, "toSdkAttachmentView")
560560
.mockReturnValue({ id: "a1" } as SdkAttachmentView);

libs/common/src/vault/utils/cipher-view-like-utils.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ describe("CipherViewLikeUtils", () => {
175175
});
176176

177177
it("returns false when the cipher is assigned to an organization and cannot be edited", () => {
178-
cipherListView.organizationId = "org-id";
178+
cipherListView.organizationId = "org-id" as any;
179179

180180
expect(CipherViewLikeUtils.canAssignToCollections(cipherListView)).toBe(false);
181181
});
182182

183183
it("returns true when the cipher is assigned to an organization and can be edited", () => {
184-
cipherListView.organizationId = "org-id";
184+
cipherListView.organizationId = "org-id" as any;
185185
cipherListView.edit = true;
186186
cipherListView.viewPassword = true;
187187

0 commit comments

Comments
 (0)