From e10ef80ffccdae1a6a81086a61ca1e8b6df00b2e Mon Sep 17 00:00:00 2001 From: Amir Allayarov Date: Wed, 24 Jan 2024 18:06:33 +0400 Subject: [PATCH] add custom tutorials msw handler --- redisinsight/ui/src/mocks/handlers/index.ts | 2 ++ .../ui/src/mocks/handlers/tutorials/index.ts | 7 +++++++ .../mocks/handlers/tutorials/tutorialsHandlers.ts | 13 +++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 redisinsight/ui/src/mocks/handlers/tutorials/index.ts create mode 100644 redisinsight/ui/src/mocks/handlers/tutorials/tutorialsHandlers.ts diff --git a/redisinsight/ui/src/mocks/handlers/index.ts b/redisinsight/ui/src/mocks/handlers/index.ts index 4fbf6d0bb8..478f70f0fc 100644 --- a/redisinsight/ui/src/mocks/handlers/index.ts +++ b/redisinsight/ui/src/mocks/handlers/index.ts @@ -7,6 +7,7 @@ import browser from './browser' import recommendations from './recommendations' import triggeredFunctions from './triggeredFunctions' import cloud from './oauth' +import tutorials from './tutorials' // @ts-ignore export const handlers: RestHandler[] = [].concat( @@ -18,4 +19,5 @@ export const handlers: RestHandler[] = [].concat( recommendations, triggeredFunctions, cloud, + tutorials, ) diff --git a/redisinsight/ui/src/mocks/handlers/tutorials/index.ts b/redisinsight/ui/src/mocks/handlers/tutorials/index.ts new file mode 100644 index 0000000000..4ea9e73b94 --- /dev/null +++ b/redisinsight/ui/src/mocks/handlers/tutorials/index.ts @@ -0,0 +1,7 @@ +import { DefaultBodyType, MockedRequest, RestHandler } from 'msw' + +import tutorials from './tutorialsHandlers' + +// @ts-ignore +const handlers: RestHandler>[] = [].concat(tutorials) +export default handlers diff --git a/redisinsight/ui/src/mocks/handlers/tutorials/tutorialsHandlers.ts b/redisinsight/ui/src/mocks/handlers/tutorials/tutorialsHandlers.ts new file mode 100644 index 0000000000..16ae75f43e --- /dev/null +++ b/redisinsight/ui/src/mocks/handlers/tutorials/tutorialsHandlers.ts @@ -0,0 +1,13 @@ +import { DefaultBodyType, MockedRequest, rest, RestHandler } from 'msw' +import { ApiEndpoints } from 'uiSrc/constants' +import { getMswURL } from 'uiSrc/utils/test-utils' + +const handlers: RestHandler>[] = [ + rest.post(getMswURL(ApiEndpoints.CUSTOM_TUTORIALS), (_, res, ctx) => res( + ctx.json({ + id: 'f79e82e8-c34a-4dc7-a49e-9fadc0979fda', + }), + )), +] + +export default handlers