Skip to content

Commit

Permalink
Merge pull request #11 from pepfar-datim/DAT_3177_clear_cache
Browse files Browse the repository at this point in the history
[DAT-3177] adds clear cache after put
  • Loading branch information
maggiedemeke authored Sep 27, 2023
2 parents fdfc9f2 + 75a2627 commit a4df673
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/modules/shared/services/content.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ export function fetchContent():Promise<string>{
export function saveContent(content) {
return putJson(getContentUrl(), { body: content }).catch(async () => {
await postJson(getContentUrl(), { body: content });
await postEmpty('/maintenance/cache');
let widgetId = getWidgetId();
let widgetUid = await getKeyUid(widgetId);
return shareKey(widgetUid, 'r-------');
});
}).then(async (resp) => { await postEmpty('/maintenance/cache')});
}

export function checkNestedMenusValid(content:string):boolean{
Expand Down
5 changes: 5 additions & 0 deletions src/test/03.edit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ test(`Edit & Save`, async ()=>{
mockNoContent();
await gotoEdit();
await setEditorValue('hello world');
const clearCacheResponse = {"httpStatus":"OK","httpStatusCode":204,"status":"OK"};
let putData = registerSendMock('/dataStore/dashboard-information/testDashboardId1',{"httpStatus":"Created","httpStatusCode":201,"status":"OK"});
let clearCache = registerSendMock('/maintenance/cache',clearCacheResponse).then((request)=>{
expect(request).toStrictEqual(null);
})
click('save-button');
await putData.then((data)=>{
expect(data).toStrictEqual({body:"<p>hello world</p>"})
})
await clearCache;
mockContent("<p>hello world</p>")
await textsWait(["Content saved","hello world"])
})

0 comments on commit a4df673

Please # to comment.