test(service-worker): add helper function remove individual cache (#36847)
This commit adds a helper method to remove individual cached items. PR Close #36847
This commit is contained in:
parent
0a7a5e3aff
commit
38d6596742
@ -1762,6 +1762,16 @@ describe('Driver', () => {
|
|||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
async function removeAssetFromCache(
|
||||||
|
scope: SwTestHarness, appVersionManifest: Manifest, assetPath: string) {
|
||||||
|
const assetGroupName =
|
||||||
|
appVersionManifest.assetGroups?.find(group => group.urls.includes(assetPath))?.name;
|
||||||
|
const cacheName = `${scope.cacheNamePrefix}:${sha1(JSON.stringify(appVersionManifest))}:assets:${
|
||||||
|
assetGroupName}:cache`;
|
||||||
|
const cache = await scope.caches.open(cacheName);
|
||||||
|
return cache.delete(assetPath);
|
||||||
|
}
|
||||||
|
|
||||||
async function makeRequest(
|
async function makeRequest(
|
||||||
scope: SwTestHarness, url: string, clientId: string|null = 'default',
|
scope: SwTestHarness, url: string, clientId: string|null = 'default',
|
||||||
init?: Object): Promise<string|null> {
|
init?: Object): Promise<string|null> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user