1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

PS-1133 Feature/mv3 browser observable memory caching (#3245)

* Create sessions sync structure

* Add observing to session-syncer

* Do not run syncer logic in decorator tests

* Extract test constants

* Change Observables to BehaviorSubject

* Move sendMessage to static method in BrowserApi

* Implement session sync

* only watch in manifest v3

* Use session sync on folder service

* Add array observable sync

* Bypass cache on update from message

* Create feature and dev flags for browser

* Protect development-only methods with decorator

* Improve todo comments for long-term residency

* Use class properties in init

* Do not reuse mocks

* Use json (de)serialization patterns

* Fix failing session storage in dev environment

* Split up complex EncString constructor

* Default false for decrypted session storage

* Try removing hydrate EncString method

* PR review

* PR test review
This commit is contained in:
Matt Gibson
2022-08-16 06:05:03 -06:00
committed by GitHub
parent 9d0dd613fb
commit 5339344630
37 changed files with 1018 additions and 163 deletions

View File

@@ -1,4 +1,5 @@
import { FolderData } from "@bitwarden/common/models/data/folderData";
import { EncString } from "@bitwarden/common/models/domain/encString";
import { Folder } from "@bitwarden/common/models/domain/folder";
import { mockEnc } from "../../utils";
@@ -38,4 +39,27 @@ describe("Folder", () => {
revisionDate: new Date("2022-01-31T12:00:00.000Z"),
});
});
describe("fromJSON", () => {
jest.mock("@bitwarden/common/models/domain/encString");
const mockFromJson = (stub: any) => (stub + "_fromJSON") as any;
jest.spyOn(EncString, "fromJSON").mockImplementation(mockFromJson);
it("initializes nested objects", () => {
const revisionDate = new Date("2022-08-04T01:06:40.441Z");
const actual = Folder.fromJSON({
revisionDate: revisionDate.toISOString(),
name: "name",
id: "id",
});
const expected = {
revisionDate: revisionDate,
name: "name_fromJSON",
id: "id",
};
expect(actual).toMatchObject(expected);
});
});
});