diff --git a/src/modules/main/services/setupNamespace.service.tsx b/src/modules/main/services/setupNamespace.service.tsx index 0cf7c3a..838d408 100644 --- a/src/modules/main/services/setupNamespace.service.tsx +++ b/src/modules/main/services/setupNamespace.service.tsx @@ -1,4 +1,4 @@ -import {getJson, postJson } from "@pepfar-react-lib/datim-api"; +import {getJson, postJson, postEmpty } from "@pepfar-react-lib/datim-api"; import {getKeyUid, shareKey} from "../../shared/services/shareKey.service"; const config = require('../../../config/config.json'); @@ -6,6 +6,7 @@ const config = require('../../../config/config.json'); async function addNamespaceConfig(datastoreNamespace, onlyOpenToSuperUsersKey) { const data = { [onlyOpenToSuperUsersKey]: false }; await postJson(`/dataStore/${datastoreNamespace}/configuration`, data); + await postEmpty('/maintenance/cache'); const configKeyUid = await getKeyUid('configuration'); await shareKey(configKeyUid, 'r-------'); } @@ -21,5 +22,5 @@ async function checkDataStore(){ export async function connectToDataStore(){ if(await checkDataStore()) return; const {datastoreNamespace, onlyOpenToSuperUsersKey} = config; - await addNamespaceConfig(datastoreNamespace, onlyOpenToSuperUsersKey); + await addNamespaceConfig(datastoreNamespace, onlyOpenToSuperUsersKey); } \ No newline at end of file diff --git a/src/test/01.dataStoreInit.test.tsx b/src/test/01.dataStoreInit.test.tsx index 21c727c..089bdf8 100644 --- a/src/test/01.dataStoreInit.test.tsx +++ b/src/test/01.dataStoreInit.test.tsx @@ -6,6 +6,7 @@ const dataStoreCreateResponse = {"httpStatus":"Created","httpStatusCode":201,"st const metaDataResponse = {"id":"metadataId1"}; const keyShareStatus = {"object": {publicAccess: "rw------"}} const keyShareResponse = {"httpStatus":"OK","httpStatusCode":200,"status":"OK","message":"Access control set"}; +const clearCacheResponse = {"httpStatus":"OK","httpStatusCode":204,"status":"OK"}; test(`DataStoreInit > Empty`, async ()=>{ dataStoreExists(false); @@ -17,7 +18,11 @@ test(`DataStoreInit > Empty`, async ()=>{ let sharing = registerSendMock('/sharing?type=dataStore&id=metadataId1',keyShareResponse).then((response)=>{ expect(response).toStrictEqual({"object":{"id":"metadataId1","publicAccess":"r-------"}}); }) + let clearCache = registerSendMock('/maintenance/cache',clearCacheResponse).then((request)=>{ + expect(request).toStrictEqual(null); + }) await connectToDataStore(); await dataStore; await sharing; + await clearCache; }) \ No newline at end of file