From 557b89d12cf84983c813b1cfeec4a4f13ff365f2 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 23 Sep 2022 10:55:34 +0200 Subject: [PATCH] Add api handler --- .../domains/published-status.handlers.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/mocks/domains/published-status.handlers.ts diff --git a/src/Umbraco.Web.UI.Client/src/mocks/domains/published-status.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/domains/published-status.handlers.ts new file mode 100644 index 0000000000..1cef7b9433 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/mocks/domains/published-status.handlers.ts @@ -0,0 +1,24 @@ +import { rest } from 'msw'; + +import umbracoPath from '../../core/helpers/umbraco-path'; + +export const handlers = [ + rest.get(umbracoPath('/published-cache/status'), (_req, res, ctx) => { + return res( + // Respond with a 200 status code + ctx.status(200), + ctx.json( + 'Database cache is ok. ContentStore contains 1 item and has 1 generation and 0 snapshot. MediaStore contains 5 items and has 1 generation and 0 snapshot.' + ) + ); + }), + + rest.post(umbracoPath('/published-cache/reload'), async (_req, res, ctx) => { + await new Promise((resolve) => setTimeout(resolve, (Math.random() + 1) * 1000)); // simulate a delay of 1-2 seconds + + return res( + // Respond with a 200 status code + ctx.status(201) + ); + }), +];