Add IndexedDB integration tests for Planet CacheManager.js#5906
Merged
omsuneri merged 1 commit intosugarlabs:masterfrom Feb 26, 2026
Merged
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
88319a0 to
90e3747
Compare
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
|
@omsuneri @walterbender Ready for review |
7se7en72025
approved these changes
Feb 26, 2026
Contributor
7se7en72025
left a comment
There was a problem hiding this comment.
LGTM !! @walterbender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
planet/js/CacheManager.js, covering IndexedDB initialization, all cache operations (metadata, project data, thumbnail), expiry logic, LRU cache removal, cache stats, and cleanup, using in-memory IndexedDB fromfake-indexeddb.npm run test).Changes
1. Added
fake-indexeddbpackage for testing IndexedDB operationsfake-indexeddbis an in-memory implementation of the IndexedDB API for Node.js environments.CacheManager.jscannot be tested.IDBFactoryandIDBKeyRangefromfake-indexeddbPackage are used in theIndexedDB CacheManager integrationtest suite. This allows to open a in-memory IndexedDB database, and execute all DB operations as they would in a browser.2. Added 38 IndexedDB integration tests using
fake-indexeddbforCacheManager.jsTest Additions
init()trueon success and setsisInitializedclearExpiredautomaticallyfalsewhenindexedDBis missingcacheMetadata / getMetadatanullnullcacheProject / getProjectnullnullmetadataExpirybut withinprojectExpirycacheThumbnail / getThumbnailcacheThumbnailreturns valuenullnullgetThumbnaildoes not updatelastAccessedclearExpired0when nothing expired0afterclearAll()clearAlltruetrueboth timesgetStatsclearAll()enforceMaxSizemaxCacheSizeafter insertion beyond maxlastAccessedentry is removed first on overflowupdateLastAccessedgetMetadataupdateslastAccessedgetProjectupdateslastAccessedTotal tests added: 38
Steps to Test PR
Install dependencies:
npm install(Ensures
fake-indexeddbpackage is added)Run the test suite:
npm run testAll test should pass
Coverage
Before
After
Verification
All
CacheManager.jstests pass