1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

[PM-8847] Delay browser local storage operations during reseed (#9536)

* Define matchers to test promise fulfillment

These are useful for validating that promises depend on other events prior to fulfilling.

* Expose custom matchers to jest projects

Team-specific projects are not touched here to try and reduce review burden.

* Block browser local operations awaiting reseed

This should closes a narrow race condition resulting from storage operations during a reseed event.

* Import from barrel file

This might fix the failing test, but I'm not sure _why_

* Document helper methods

* Validate as few properties as possible per test

* Simplify expected value representation

* Allow waiting in promise matchers

* Specify resolution times in promise orchestration tests.

* Test behavior triggering multiple reseeds.

* Fix typo

* Avoid testing implementation details

* Clear reseed on startup

in case a previous process was aborted in the middle of a reseed.

* Correct formatting
This commit is contained in:
Matt Gibson
2024-07-19 13:12:29 -07:00
committed by GitHub
parent 1320d96cb4
commit 5b5c165e10
11 changed files with 485 additions and 96 deletions

View File

@@ -1,4 +1,7 @@
import "jest-preset-angular/setup-jest";
import { addCustomMatchers } from "@bitwarden/common/spec";
addCustomMatchers();
// Add chrome storage api
const QUOTA_BYTES = 10;
@@ -10,6 +13,10 @@ const storage = {
QUOTA_BYTES,
getBytesInUse: jest.fn(),
clear: jest.fn(),
onChanged: {
addListener: jest.fn(),
removeListener: jest.fn(),
},
},
session: {
set: jest.fn(),