@redocly/openapi-docs 3.24.1 → 3.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/telemetry/RedocTelemetry.js +1 -31
- package/package.json +4 -4
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +0 -1
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +0 -46
- package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +0 -1
- package/lib/components/Callbacks/__tests__/Callbacks.test.js +0 -46
- package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +0 -1
- package/lib/components/Content/__tests__/useAutoScroll.test.js +0 -88
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +0 -1
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +0 -123
- package/lib/components/ContentItems/__tests__/Items.test.d.ts +0 -1
- package/lib/components/ContentItems/__tests__/Items.test.js +0 -66
- package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +0 -1
- package/lib/components/ContentItems/__tests__/VirtualList.test.js +0 -135
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +0 -1
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +0 -63
- package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +0 -1
- package/lib/components/Download/__tests__/DownloadSpecification.test.js +0 -52
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +0 -1
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +0 -60
- package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +0 -1
- package/lib/components/ExpandAllButton/__tests__/helpers.test.js +0 -133
- package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +0 -1
- package/lib/components/Language/__tests__/LanguageDropdown.test.js +0 -23
- package/lib/components/Markdown/__tests__/Markdown.test.d.ts +0 -1
- package/lib/components/Markdown/__tests__/Markdown.test.js +0 -34
- package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +0 -1
- package/lib/components/McpOverview/__tests__/McpOverview.test.js +0 -66
- package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +0 -1
- package/lib/components/McpTool/__tests__/McpPrompt.test.js +0 -57
- package/lib/components/McpTool/__tests__/McpResource.test.d.ts +0 -1
- package/lib/components/McpTool/__tests__/McpResource.test.js +0 -81
- package/lib/components/McpTool/__tests__/McpTool.test.d.ts +0 -1
- package/lib/components/McpTool/__tests__/McpTool.test.js +0 -82
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +0 -1
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +0 -79
- package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +0 -1
- package/lib/components/OperationItem/__tests__/OperationItem.test.js +0 -70
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +0 -16
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +0 -42
- package/lib/components/Overview/__tests__/Overview.test.d.ts +0 -1
- package/lib/components/Overview/__tests__/Overview.test.js +0 -59
- package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +0 -1
- package/lib/components/PayloadSamples/__tests__/Example.test.js +0 -36
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +0 -1
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +0 -197
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +0 -1
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +0 -38
- package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/Extensions.test.js +0 -21
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +0 -52
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +0 -191
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +0 -365
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +0 -23
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +0 -1
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +0 -16
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +0 -1
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +0 -104
- package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +0 -1
- package/lib/components/RenderHook/__tests__/RenderHook.test.js +0 -15
- package/lib/components/Replay/__tests__/utils.test.d.ts +0 -1
- package/lib/components/Replay/__tests__/utils.test.js +0 -526
- package/lib/components/Request/__tests__/RequestDetails.test.d.ts +0 -1
- package/lib/components/Request/__tests__/RequestDetails.test.js +0 -98
- package/lib/components/RequestSamples/__tests__/Example.test.d.ts +0 -1
- package/lib/components/RequestSamples/__tests__/Example.test.js +0 -384
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +0 -1
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +0 -226
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +0 -1
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +0 -64
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +0 -1
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +0 -29
- package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +0 -1
- package/lib/components/Responses/__tests__/OperationResponseList.test.js +0 -89
- package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +0 -1
- package/lib/components/Responses/__tests__/ResponseDetails.test.js +0 -111
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +0 -1
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +0 -26
- package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/ArraySchema.test.js +0 -93
- package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/ObjectSchema.test.js +0 -115
- package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/OneOfSchema.test.js +0 -33
- package/lib/components/Schema/__tests__/Schema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/Schema.test.js +0 -67
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +0 -22
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +0 -1
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +0 -95
- package/lib/components/Security/__tests__/Security.test.d.ts +0 -1
- package/lib/components/Security/__tests__/Security.test.js +0 -38
- package/lib/components/Security/__tests__/SecurityButton.test.d.ts +0 -1
- package/lib/components/Security/__tests__/SecurityButton.test.js +0 -92
- package/lib/components/Security/__tests__/SecurityModal.test.d.ts +0 -1
- package/lib/components/Security/__tests__/SecurityModal.test.js +0 -172
- package/lib/components/ServerList/__tests__/ServerList.test.d.ts +0 -1
- package/lib/components/ServerList/__tests__/ServerList.test.js +0 -83
- package/lib/components/Tabs/__tests__/Tabs.test.d.ts +0 -1
- package/lib/components/Tabs/__tests__/Tabs.test.js +0 -27
- package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +0 -1
- package/lib/components/ViewNested/__tests__/ViewNested.test.js +0 -42
- package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +0 -1
- package/lib/components/__tests__/Samples/ExampleSwitch.test.js +0 -45
- package/lib/components/__tests__/Samples/use-example-key.test.d.ts +0 -1
- package/lib/components/__tests__/Samples/use-example-key.test.js +0 -28
- package/lib/components/__tests__/common/ClearButton.test.d.ts +0 -1
- package/lib/components/__tests__/common/ClearButton.test.js +0 -18
- package/lib/components/__tests__/common/Dropdown.test.d.ts +0 -1
- package/lib/components/__tests__/common/Dropdown.test.js +0 -52
- package/lib/components/__tests__/mocks/examples.d.ts +0 -4
- package/lib/components/__tests__/mocks/examples.js +0 -115
- package/lib/components/common/__tests__/Dropdown.test.d.ts +0 -1
- package/lib/components/common/__tests__/Dropdown.test.js +0 -129
- package/lib/components/common/__tests__/LinkToField.test.d.ts +0 -1
- package/lib/components/common/__tests__/LinkToField.test.js +0 -39
- package/lib/jotai/__tests__/app.test.d.ts +0 -1
- package/lib/jotai/__tests__/app.test.js +0 -53
- package/lib/models/__tests__/Callback.test.d.ts +0 -1
- package/lib/models/__tests__/Callback.test.js +0 -15
- package/lib/models/__tests__/FieldModel.test.d.ts +0 -1
- package/lib/models/__tests__/FieldModel.test.js +0 -117
- package/lib/models/__tests__/MediaContent.test.d.ts +0 -1
- package/lib/models/__tests__/MediaContent.test.js +0 -105
- package/lib/models/__tests__/Operation.test.d.ts +0 -1
- package/lib/models/__tests__/Operation.test.js +0 -459
- package/lib/models/__tests__/Response.test.d.ts +0 -1
- package/lib/models/__tests__/Response.test.js +0 -221
- package/lib/models/__tests__/Schema.circular.test.d.ts +0 -1
- package/lib/models/__tests__/Schema.circular.test.js +0 -694
- package/lib/models/__tests__/Schema.test.d.ts +0 -1
- package/lib/models/__tests__/Schema.test.js +0 -1395
- package/lib/models/__tests__/example.test.d.ts +0 -1
- package/lib/models/__tests__/example.test.js +0 -90
- package/lib/models/__tests__/group.test.d.ts +0 -1
- package/lib/models/__tests__/group.test.js +0 -52
- package/lib/models/__tests__/helpers.d.ts +0 -5
- package/lib/models/__tests__/helpers.js +0 -62
- package/lib/models/__tests__/request.test.d.ts +0 -1
- package/lib/models/__tests__/request.test.js +0 -119
- package/lib/services/__tests__/OpenAPIParser.test.d.ts +0 -1
- package/lib/services/__tests__/OpenAPIParser.test.js +0 -80
- package/lib/services/__tests__/check.test.d.ts +0 -1
- package/lib/services/__tests__/check.test.js +0 -22
- package/lib/services/__tests__/utils.test.d.ts +0 -1
- package/lib/services/__tests__/utils.test.js +0 -42
- package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/apply-environments.test.js +0 -64
- package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/build-code-samples.test.js +0 -70
- package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/convertSampleToString.test.js +0 -116
- package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/generator-data-value.test.js +0 -277
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +0 -258
- package/lib/services/code-samples/__tests__/generator-value.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/generator-value.test.js +0 -273
- package/lib/services/code-samples/__tests__/generator.test.d.ts +0 -249
- package/lib/services/code-samples/__tests__/generator.test.js +0 -1201
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +0 -31
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +0 -222
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +0 -129
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +0 -49
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +0 -172
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +0 -172
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +0 -130
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +0 -191
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +0 -172
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +0 -85
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +0 -85
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +0 -126
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +0 -105
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +0 -126
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +0 -129
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +0 -129
- package/lib/services/config-options/__tests__/helpers.test.d.ts +0 -1
- package/lib/services/config-options/__tests__/helpers.test.js +0 -234
- package/lib/services/history/__tests__/helpers.test.d.ts +0 -1
- package/lib/services/history/__tests__/helpers.test.js +0 -19
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +0 -1
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +0 -109
- package/lib/services/menu/__tests__/builder.test.d.ts +0 -1
- package/lib/services/menu/__tests__/builder.test.js +0 -307
- package/lib/services/menu/__tests__/operation.test.d.ts +0 -1
- package/lib/services/menu/__tests__/operation.test.js +0 -240
- package/lib/services/menu/__tests__/tags.test.d.ts +0 -1
- package/lib/services/menu/__tests__/tags.test.js +0 -71
- package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +0 -1
- package/lib/telemetry/__tests__/RedocTelemetry.test.js +0 -107
- package/lib/testProviders.d.ts +0 -6
- package/lib/testProviders.js +0 -14
- package/lib/utils/__tests__/areArraysEqual.test.d.ts +0 -1
- package/lib/utils/__tests__/areArraysEqual.test.js +0 -33
- package/lib/utils/__tests__/argValuesHelpers.d.ts +0 -1
- package/lib/utils/__tests__/argValuesHelpers.js +0 -56
- package/lib/utils/__tests__/calculateMaxLength.test.d.ts +0 -1
- package/lib/utils/__tests__/calculateMaxLength.test.js +0 -119
- package/lib/utils/__tests__/configure-helpers.test.d.ts +0 -1
- package/lib/utils/__tests__/configure-helpers.test.js +0 -356
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +0 -1
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +0 -392
- package/lib/utils/__tests__/debounce.test.d.ts +0 -1
- package/lib/utils/__tests__/debounce.test.js +0 -54
- package/lib/utils/__tests__/debug.test.d.ts +0 -1
- package/lib/utils/__tests__/debug.test.js +0 -23
- package/lib/utils/__tests__/dom.test.d.ts +0 -1
- package/lib/utils/__tests__/dom.test.js +0 -108
- package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +0 -1
- package/lib/utils/__tests__/getBreadcrumbs.test.js +0 -98
- package/lib/utils/__tests__/hasNestedFields.test.d.ts +0 -1
- package/lib/utils/__tests__/hasNestedFields.test.js +0 -147
- package/lib/utils/__tests__/helpers.test.d.ts +0 -1
- package/lib/utils/__tests__/helpers.test.js +0 -174
- package/lib/utils/__tests__/isMobile.test.d.ts +0 -1
- package/lib/utils/__tests__/isMobile.test.js +0 -28
- package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +0 -1
- package/lib/utils/__tests__/loadAndBundleSpec.test.js +0 -22
- package/lib/utils/__tests__/local-storage.test.d.ts +0 -1
- package/lib/utils/__tests__/local-storage.test.js +0 -48
- package/lib/utils/__tests__/object.test.d.ts +0 -1
- package/lib/utils/__tests__/object.test.js +0 -45
- package/lib/utils/__tests__/openapi.test.d.ts +0 -1
- package/lib/utils/__tests__/openapi.test.js +0 -1378
- package/lib/utils/__tests__/path.test.d.ts +0 -1
- package/lib/utils/__tests__/path.test.js +0 -16
- package/lib/utils/__tests__/queryString.test.d.ts +0 -1
- package/lib/utils/__tests__/queryString.test.js +0 -60
- package/lib/utils/__tests__/replaceVariables.test.d.ts +0 -1
- package/lib/utils/__tests__/replaceVariables.test.js +0 -46
- package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +0 -1
- package/lib/utils/__tests__/simplifyAstStructure.test.js +0 -26
- package/lib/utils/__tests__/sort.test.d.ts +0 -1
- package/lib/utils/__tests__/sort.test.js +0 -16
- package/lib/utils/__tests__/string.test.d.ts +0 -1
- package/lib/utils/__tests__/string.test.js +0 -16
- package/lib/utils/__tests__/theme-helpers.test.d.ts +0 -1
- package/lib/utils/__tests__/theme-helpers.test.js +0 -24
- package/lib/utils/__tests__/url.test.d.ts +0 -1
- package/lib/utils/__tests__/url.test.js +0 -134
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, renderHook } from '@testing-library/react';
|
|
3
|
-
import util from 'util';
|
|
4
|
-
import { DownloadSpecification } from '../DownloadSpecification.js';
|
|
5
|
-
import { useDownloadInfo } from '../useDownloadInfo.js';
|
|
6
|
-
Object.defineProperty(global, 'TextEncoder', {
|
|
7
|
-
value: util.TextEncoder,
|
|
8
|
-
});
|
|
9
|
-
describe('DownloadSpecification', () => {
|
|
10
|
-
it('DownloadButton renders correctly without title', () => {
|
|
11
|
-
const downloadUrls = [
|
|
12
|
-
{
|
|
13
|
-
url: 'downloadDefinitionUrlValue.json',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
url: 'downloadDefinitionUrlValue.yaml',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
url: 'downloadDefinitionUrlValue.txt',
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
const { result } = renderHook(() => useDownloadInfo({
|
|
23
|
-
downloadUrls,
|
|
24
|
-
}));
|
|
25
|
-
const downloadObjects = result?.current ?? [];
|
|
26
|
-
const { container } = render(_jsx(DownloadSpecification, { downloadObjects: downloadObjects }));
|
|
27
|
-
expect(container).toMatchSnapshot();
|
|
28
|
-
});
|
|
29
|
-
it('DownloadButton renders correctly with title', () => {
|
|
30
|
-
const downloadUrls = [
|
|
31
|
-
{
|
|
32
|
-
title: 'OpenAPI Description json format',
|
|
33
|
-
url: 'downloadDefinitionUrlValue.json',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
title: 'OpenAPI Description yaml format',
|
|
37
|
-
url: 'downloadDefinitionUrlValue.yaml',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
title: 'OpenAPI Description text format',
|
|
41
|
-
url: 'downloadDefinitionUrlValue.txt',
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
const { result } = renderHook(() => useDownloadInfo({
|
|
45
|
-
downloadUrls,
|
|
46
|
-
}));
|
|
47
|
-
const downloadObjects = result?.current ?? [];
|
|
48
|
-
const { container } = render(_jsx(DownloadSpecification, { downloadObjects: downloadObjects }));
|
|
49
|
-
expect(container).toMatchSnapshot();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
//# sourceMappingURL=DownloadSpecification.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useAtom } from 'jotai/index';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
|
-
import { ExpandAllButton } from '../ExpandAllButton.js';
|
|
5
|
-
import { useTranslate, useTelemetry } from '../../../hooks/index.js';
|
|
6
|
-
// Mock the dependencies
|
|
7
|
-
vi.mock('jotai/index', () => ({
|
|
8
|
-
useAtom: vi.fn(),
|
|
9
|
-
useAtomValue: vi.fn(),
|
|
10
|
-
atom: vi.fn(),
|
|
11
|
-
}));
|
|
12
|
-
vi.mock('../../../hooks', () => ({
|
|
13
|
-
useTranslate: vi.fn(),
|
|
14
|
-
useTelemetry: vi.fn(), // Add mock for useTelemetry
|
|
15
|
-
}));
|
|
16
|
-
vi.mock('@redocly/theme', () => ({
|
|
17
|
-
Button: ({ children, ...props }) => _jsx("button", { ...props, children: children }),
|
|
18
|
-
MaximizeIcon: () => _jsx("span", { "data-testid": "maximize-icon" }),
|
|
19
|
-
}));
|
|
20
|
-
describe('ExpandAllButton', () => {
|
|
21
|
-
const mockSetOperationState = vi.fn();
|
|
22
|
-
const mockTranslate = vi.fn((_key, defaultValue) => defaultValue);
|
|
23
|
-
const mockTelemetrySend = vi.fn();
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
vi.clearAllMocks();
|
|
26
|
-
useAtom.mockReturnValue([
|
|
27
|
-
{ request: { expandedAll: false }, response: { expandedAll: false } },
|
|
28
|
-
mockSetOperationState,
|
|
29
|
-
]);
|
|
30
|
-
useTranslate.mockReturnValue(mockTranslate);
|
|
31
|
-
useTelemetry.mockReturnValue({
|
|
32
|
-
sendExpandCollapseAllClickedMessage: mockTelemetrySend,
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
it('renders correctly with initial state', () => {
|
|
36
|
-
render(_jsx(ExpandAllButton, { operationPointer: "test", type: "request" }));
|
|
37
|
-
expect(screen.getByRole('button')).toHaveTextContent('Expand all');
|
|
38
|
-
});
|
|
39
|
-
it('toggles state when clicked', () => {
|
|
40
|
-
render(_jsx(ExpandAllButton, { operationPointer: "test", type: "request" }));
|
|
41
|
-
fireEvent.click(screen.getByRole('button'));
|
|
42
|
-
expect(mockSetOperationState).toHaveBeenCalledTimes(1);
|
|
43
|
-
expect(mockSetOperationState).toHaveBeenCalledWith(expect.any(Object));
|
|
44
|
-
const updateObject = mockSetOperationState.mock.calls[0][0];
|
|
45
|
-
expect(updateObject).toEqual({ request: { expandedAll: true } });
|
|
46
|
-
});
|
|
47
|
-
it('displays correct text based on expanded state', () => {
|
|
48
|
-
useAtom.mockReturnValue([
|
|
49
|
-
{ request: { expandedAll: true }, response: { expandedAll: false } },
|
|
50
|
-
mockSetOperationState,
|
|
51
|
-
]);
|
|
52
|
-
render(_jsx(ExpandAllButton, { operationPointer: "test", type: "request" }));
|
|
53
|
-
expect(screen.getByRole('button')).toHaveTextContent('Collapse all');
|
|
54
|
-
});
|
|
55
|
-
it('uses translate function for button text', () => {
|
|
56
|
-
render(_jsx(ExpandAllButton, { operationPointer: "test", type: "request" }));
|
|
57
|
-
expect(mockTranslate).toHaveBeenCalledWith('openapi.expandAll', 'Expand all');
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=ExpandAllButton.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { parseYaml } from '@redocly/openapi-core';
|
|
2
|
-
import { outdent } from 'outdent';
|
|
3
|
-
import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
|
|
4
|
-
import { computeExpandAllDepth, MAX_EXPAND_ALL_DEPTH } from '../helpers.js';
|
|
5
|
-
const options = normalizeOptions({});
|
|
6
|
-
function makeParser(spec) {
|
|
7
|
-
return new OpenAPIParser(spec, undefined, options);
|
|
8
|
-
}
|
|
9
|
-
function asModel(rawSchema) {
|
|
10
|
-
return { schema: rawSchema, rawSchema };
|
|
11
|
-
}
|
|
12
|
-
describe('computeExpandAllDepth', () => {
|
|
13
|
-
test('returns the ceiling for small schemas', () => {
|
|
14
|
-
const spec = parseYaml(outdent `
|
|
15
|
-
openapi: 3.0.0
|
|
16
|
-
components:
|
|
17
|
-
schemas:
|
|
18
|
-
User:
|
|
19
|
-
type: object
|
|
20
|
-
properties:
|
|
21
|
-
name:
|
|
22
|
-
type: string
|
|
23
|
-
address:
|
|
24
|
-
type: object
|
|
25
|
-
properties:
|
|
26
|
-
city:
|
|
27
|
-
type: string
|
|
28
|
-
`);
|
|
29
|
-
const parser = makeParser(spec);
|
|
30
|
-
expect(computeExpandAllDepth(parser, [asModel(spec.components.schemas.User)])).toBe(MAX_EXPAND_ALL_DEPTH);
|
|
31
|
-
});
|
|
32
|
-
test('clamps the depth for schemas that unfold exponentially', () => {
|
|
33
|
-
// Each level references the same node 5 times -> 5^level rows.
|
|
34
|
-
const spec = parseYaml(outdent `
|
|
35
|
-
openapi: 3.0.0
|
|
36
|
-
components:
|
|
37
|
-
schemas:
|
|
38
|
-
Node:
|
|
39
|
-
type: object
|
|
40
|
-
properties:
|
|
41
|
-
a:
|
|
42
|
-
$ref: '#/components/schemas/Node'
|
|
43
|
-
b:
|
|
44
|
-
$ref: '#/components/schemas/Node'
|
|
45
|
-
c:
|
|
46
|
-
$ref: '#/components/schemas/Node'
|
|
47
|
-
d:
|
|
48
|
-
$ref: '#/components/schemas/Node'
|
|
49
|
-
e:
|
|
50
|
-
$ref: '#/components/schemas/Node'
|
|
51
|
-
`);
|
|
52
|
-
const parser = makeParser(spec);
|
|
53
|
-
const depth = computeExpandAllDepth(parser, [asModel(spec.components.schemas.Node)], 100);
|
|
54
|
-
// 5 + 25 + 125 = 155 > 100 -> depth 2
|
|
55
|
-
expect(depth).toBe(2);
|
|
56
|
-
});
|
|
57
|
-
test('expands at least one level even when the first level exceeds the budget', () => {
|
|
58
|
-
const properties = Object.fromEntries(Array.from({ length: 50 }, (_, i) => [`p${i}`, { type: 'object' }]));
|
|
59
|
-
const parser = makeParser({ openapi: '3.0.0', components: {} });
|
|
60
|
-
expect(computeExpandAllDepth(parser, [asModel({ type: 'object', properties })], 10)).toBe(1);
|
|
61
|
-
});
|
|
62
|
-
test('counts rows through allOf, oneOf active variant, and array items', () => {
|
|
63
|
-
const spec = parseYaml(outdent `
|
|
64
|
-
openapi: 3.0.0
|
|
65
|
-
components:
|
|
66
|
-
schemas:
|
|
67
|
-
Wrapped:
|
|
68
|
-
type: object
|
|
69
|
-
properties:
|
|
70
|
-
list:
|
|
71
|
-
type: array
|
|
72
|
-
items:
|
|
73
|
-
allOf:
|
|
74
|
-
- type: object
|
|
75
|
-
properties:
|
|
76
|
-
first:
|
|
77
|
-
type: string
|
|
78
|
-
- type: object
|
|
79
|
-
properties:
|
|
80
|
-
second:
|
|
81
|
-
oneOf:
|
|
82
|
-
- type: object
|
|
83
|
-
properties:
|
|
84
|
-
variantField:
|
|
85
|
-
type: string
|
|
86
|
-
- type: object
|
|
87
|
-
properties:
|
|
88
|
-
otherA:
|
|
89
|
-
type: string
|
|
90
|
-
otherB:
|
|
91
|
-
type: string
|
|
92
|
-
`);
|
|
93
|
-
const parser = makeParser(spec);
|
|
94
|
-
const root = asModel(spec.components.schemas.Wrapped);
|
|
95
|
-
// level 1: list (1 row); level 2: first + second (cum 3); level 3: variantField (oneOf[0] only, cum 4)
|
|
96
|
-
expect(computeExpandAllDepth(parser, [root], 4)).toBe(MAX_EXPAND_ALL_DEPTH);
|
|
97
|
-
expect(computeExpandAllDepth(parser, [root], 3)).toBe(2);
|
|
98
|
-
expect(computeExpandAllDepth(parser, [root], 2)).toBe(1);
|
|
99
|
-
});
|
|
100
|
-
test('counts additionalProperties and unevaluatedProperties as rows (mirrors buildFields)', () => {
|
|
101
|
-
const parser = makeParser({ openapi: '3.0.0', components: {} });
|
|
102
|
-
// 9 named properties + 1 `additionalProperties: true` row = 10 rows > budget 9
|
|
103
|
-
const properties = Object.fromEntries(Array.from({ length: 9 }, (_, i) => [`p${i}`, { type: 'string' }]));
|
|
104
|
-
expect(computeExpandAllDepth(parser, [asModel({ type: 'object', properties, additionalProperties: true })], 9)).toBe(1);
|
|
105
|
-
expect(computeExpandAllDepth(parser, [asModel({ type: 'object', properties, unevaluatedProperties: { type: 'string' } })], 9)).toBe(1);
|
|
106
|
-
// Without them the 9 properties fit the budget.
|
|
107
|
-
expect(computeExpandAllDepth(parser, [asModel({ type: 'object', properties })], 9)).toBe(MAX_EXPAND_ALL_DEPTH);
|
|
108
|
-
});
|
|
109
|
-
test('is resilient to missing parser or schemas', () => {
|
|
110
|
-
expect(computeExpandAllDepth(undefined, [])).toBe(MAX_EXPAND_ALL_DEPTH);
|
|
111
|
-
expect(computeExpandAllDepth({}, [])).toBe(MAX_EXPAND_ALL_DEPTH);
|
|
112
|
-
expect(computeExpandAllDepth(makeParser({ openapi: '3.0.0' }), [undefined])).toBe(MAX_EXPAND_ALL_DEPTH);
|
|
113
|
-
});
|
|
114
|
-
test('does not hang on self-referencing (cyclic) schemas', () => {
|
|
115
|
-
const spec = parseYaml(outdent `
|
|
116
|
-
openapi: 3.0.0
|
|
117
|
-
components:
|
|
118
|
-
schemas:
|
|
119
|
-
Cyclic:
|
|
120
|
-
type: object
|
|
121
|
-
properties:
|
|
122
|
-
self:
|
|
123
|
-
$ref: '#/components/schemas/Cyclic'
|
|
124
|
-
name:
|
|
125
|
-
type: string
|
|
126
|
-
`);
|
|
127
|
-
const parser = makeParser(spec);
|
|
128
|
-
const depth = computeExpandAllDepth(parser, [asModel(spec.components.schemas.Cyclic)]);
|
|
129
|
-
expect(depth).toBeGreaterThanOrEqual(1);
|
|
130
|
-
expect(depth).toBeLessThanOrEqual(MAX_EXPAND_ALL_DEPTH);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
//# sourceMappingURL=helpers.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
|
-
import { LanguageDropdown } from '../LanguageDropdown.js';
|
|
4
|
-
const mockSamples = [
|
|
5
|
-
{ key: 'js', title: 'JS', lang: 'js' },
|
|
6
|
-
{ key: 'node.js', title: 'Node.JS', lang: 'nodejs' },
|
|
7
|
-
];
|
|
8
|
-
const mockActiveTab = mockSamples[0].key;
|
|
9
|
-
const mockOnChange = vi.fn();
|
|
10
|
-
describe('LanguageDropdown', () => {
|
|
11
|
-
test('LanguageDropdown renders correctly', () => {
|
|
12
|
-
const { getAllByText } = render(_jsx(LanguageDropdown, { samples: mockSamples, activeTab: mockActiveTab, onChange: mockOnChange }));
|
|
13
|
-
expect(getAllByText(mockSamples[0].title)[0]).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
test('LanguageDropdown handles onChange correctly', () => {
|
|
16
|
-
const { getAllByText } = render(_jsx(LanguageDropdown, { samples: mockSamples, activeTab: mockActiveTab, onChange: mockOnChange }));
|
|
17
|
-
fireEvent.click(screen.getAllByText(mockSamples[0].title)[0]);
|
|
18
|
-
const otherLanguage = mockSamples[1];
|
|
19
|
-
fireEvent.click(getAllByText(otherLanguage.title)[0]);
|
|
20
|
-
expect(mockOnChange).toHaveBeenCalledWith(otherLanguage.key);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=LanguageDropdown.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import * as Jotai from 'jotai/index';
|
|
4
|
-
import { normalizeOptions } from '../../../services/index.js';
|
|
5
|
-
import { Markdown } from '../Markdown.js';
|
|
6
|
-
import { withTestProviders } from '../../../testProviders.js';
|
|
7
|
-
vi.mock('jotai', async () => ({
|
|
8
|
-
...(await vi.importActual('jotai')),
|
|
9
|
-
useAtomValue: vi.fn(),
|
|
10
|
-
}));
|
|
11
|
-
describe('Components', () => {
|
|
12
|
-
describe('Markdown', () => {
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
vi.clearAllMocks();
|
|
15
|
-
});
|
|
16
|
-
test('Markdown renders correctly', () => {
|
|
17
|
-
const { getByText } = render(withTestProviders(_jsx(Markdown, { source: `# Heading 1\n\n[link](https://google.com)` })));
|
|
18
|
-
expect(getByText('Heading 1')).toBeInTheDocument();
|
|
19
|
-
expect(getByText('link')).toBeInTheDocument();
|
|
20
|
-
expect(getByText('link').closest('a')).toHaveAttribute('href', 'https://google.com');
|
|
21
|
-
});
|
|
22
|
-
test('Markdown custom sanitize works', () => {
|
|
23
|
-
const options = normalizeOptions({
|
|
24
|
-
unstable_hooks: { sanitize: (str) => str.replace('bad word', '**') },
|
|
25
|
-
});
|
|
26
|
-
vi.spyOn(Jotai, 'useAtomValue').mockImplementation(() => {
|
|
27
|
-
return options;
|
|
28
|
-
});
|
|
29
|
-
const { getByText } = render(withTestProviders(_jsx(Markdown, { source: `# Heading 1\n\n[link](https://google.com)\nbad word` })));
|
|
30
|
-
expect(getByText(/\*\*/)).toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=Markdown.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { act, fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { vi } from 'vitest';
|
|
4
|
-
import { McpOverview } from '../McpOverview.js';
|
|
5
|
-
import { withTestProviders, TestMemoryRouter } from '../../../testProviders.js';
|
|
6
|
-
import mcpInfo from './fixtures/mcp-info.json';
|
|
7
|
-
describe('McpOverview', () => {
|
|
8
|
-
it('should render mcp overview', () => {
|
|
9
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpOverview, { mcpInfo: mcpInfo, mcpServers: [{ url: 'https://api.example.com/mcp' }] }) })));
|
|
10
|
-
expect(screen.getByText('Protocol version')).toBeInTheDocument();
|
|
11
|
-
expect(screen.getByText('1.0.0')).toBeInTheDocument();
|
|
12
|
-
expect(screen.getByText('Capabilities')).toBeInTheDocument();
|
|
13
|
-
expect(screen.queryByText('tool_code_interpreter')).not.toBeInTheDocument();
|
|
14
|
-
expect(screen.queryByText('tool_image_generation')).not.toBeInTheDocument();
|
|
15
|
-
expect(screen.getByText('Endpoint')).toBeInTheDocument();
|
|
16
|
-
expect(screen.getByText('https://api.example.com/mcp')).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
it('should render experimental capabilities', () => {
|
|
19
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpOverview, { mcpInfo: mcpInfo, mcpServers: [{ url: 'https://api.example.com/mcp' }] }) })));
|
|
20
|
-
expect(screen.getByText('Experimental capabilities')).toBeInTheDocument();
|
|
21
|
-
expect(screen.getByText('a:')).toBeInTheDocument();
|
|
22
|
-
expect(screen.getByText('true')).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
it('should keep endpoint variables visible while resolving the Cursor deeplink url', async () => {
|
|
25
|
-
const openSpy = vi.spyOn(window, 'open').mockImplementation(() => null);
|
|
26
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpOverview, { mcpInfo: mcpInfo, mcpServers: [
|
|
27
|
-
{
|
|
28
|
-
url: 'https://{projectHost}/mcp',
|
|
29
|
-
variables: {
|
|
30
|
-
projectHost: {
|
|
31
|
-
default: 'redocly.com',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
] }) })));
|
|
36
|
-
expect(screen.getByText('https://{projectHost}/mcp')).toBeInTheDocument();
|
|
37
|
-
await act(async () => {
|
|
38
|
-
fireEvent.click(screen.getByRole('button', { name: 'Connect to Cursor' }));
|
|
39
|
-
});
|
|
40
|
-
expect(openSpy).toHaveBeenCalledWith(expect.any(String), '_blank');
|
|
41
|
-
const deeplink = String(openSpy.mock.calls[0][0]);
|
|
42
|
-
const cursorUrl = new URL(deeplink);
|
|
43
|
-
const encodedConfig = cursorUrl.searchParams.get('config');
|
|
44
|
-
const decodedConfig = JSON.parse(Buffer.from(encodedConfig || '', 'base64').toString('utf-8'));
|
|
45
|
-
expect(decodedConfig).toEqual({
|
|
46
|
-
url: 'https://redocly.com/mcp',
|
|
47
|
-
description: 'MCP Server',
|
|
48
|
-
});
|
|
49
|
-
openSpy.mockRestore();
|
|
50
|
-
});
|
|
51
|
-
it('should render capabilities with listChanged and subscribe', () => {
|
|
52
|
-
const mcpInfoWithExtras = {
|
|
53
|
-
...mcpInfo,
|
|
54
|
-
capabilities: {
|
|
55
|
-
...mcpInfo.capabilities,
|
|
56
|
-
tools: {
|
|
57
|
-
listChanged: true,
|
|
58
|
-
subscribe: true,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpOverview, { mcpInfo: mcpInfoWithExtras, mcpServers: [{ url: 'https://api.example.com/mcp' }] }) })));
|
|
63
|
-
expect(screen.getByText(/tools \(list changed\) \(subscribe\)/)).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=McpOverview.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { McpPrompt } from '../McpPrompt.js';
|
|
4
|
-
import { withTestProviders, TestMemoryRouter } from '../../../testProviders.js';
|
|
5
|
-
const spec = {
|
|
6
|
-
openapi: '3.0.0',
|
|
7
|
-
'x-mcp': {
|
|
8
|
-
prompts: [
|
|
9
|
-
{
|
|
10
|
-
name: 'test-prompt',
|
|
11
|
-
description: 'A test prompt',
|
|
12
|
-
arguments: [
|
|
13
|
-
{
|
|
14
|
-
name: 'arg1',
|
|
15
|
-
description: 'First argument',
|
|
16
|
-
required: true,
|
|
17
|
-
example: 'value1',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
security: [
|
|
21
|
-
{
|
|
22
|
-
apiKey: [],
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
components: {
|
|
29
|
-
securitySchemes: {
|
|
30
|
-
apiKey: {
|
|
31
|
-
type: 'apiKey',
|
|
32
|
-
in: 'header',
|
|
33
|
-
name: 'X-API-Key',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
describe('McpPrompt', () => {
|
|
39
|
-
it('should render mcp prompt with arguments', () => {
|
|
40
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpPrompt, { name: "test-prompt", id: "test-prompt" }) }), {
|
|
41
|
-
definition: spec,
|
|
42
|
-
options: {},
|
|
43
|
-
}));
|
|
44
|
-
expect(screen.getByText('Arguments')).toBeInTheDocument();
|
|
45
|
-
expect(screen.getByText('arg1')).toBeInTheDocument();
|
|
46
|
-
expect(screen.getByText('Security')).toBeInTheDocument();
|
|
47
|
-
expect(screen.getByText('apiKey')).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
it('should return null if prompt not found', () => {
|
|
50
|
-
const { container } = render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpPrompt, { name: "not-found", id: "not-found" }) }), {
|
|
51
|
-
definition: spec,
|
|
52
|
-
options: {},
|
|
53
|
-
}));
|
|
54
|
-
expect(container.firstChild).toBeNull();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=McpPrompt.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
-
import { vi } from 'vitest';
|
|
4
|
-
import { McpResource } from '../McpResource.js';
|
|
5
|
-
import { withTestProviders, TestMemoryRouter } from '../../../testProviders.js';
|
|
6
|
-
const spec = {
|
|
7
|
-
openapi: '3.0.0',
|
|
8
|
-
'x-mcp': {
|
|
9
|
-
resources: [
|
|
10
|
-
{
|
|
11
|
-
name: 'test-resource',
|
|
12
|
-
uri: 'mcp://test-resource',
|
|
13
|
-
mimeType: 'application/json',
|
|
14
|
-
text: '{"key": "value"}',
|
|
15
|
-
security: [
|
|
16
|
-
{
|
|
17
|
-
apiKey: [],
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
components: {
|
|
24
|
-
securitySchemes: {
|
|
25
|
-
apiKey: {
|
|
26
|
-
type: 'apiKey',
|
|
27
|
-
in: 'header',
|
|
28
|
-
name: 'X-API-Key',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
// Mock navigator.clipboard
|
|
34
|
-
const mockClipboard = {
|
|
35
|
-
writeText: vi.fn(),
|
|
36
|
-
};
|
|
37
|
-
Object.assign(navigator, {
|
|
38
|
-
clipboard: mockClipboard,
|
|
39
|
-
});
|
|
40
|
-
describe('McpResource', () => {
|
|
41
|
-
beforeAll(() => {
|
|
42
|
-
mockClipboard.writeText.mockImplementation(() => Promise.resolve());
|
|
43
|
-
});
|
|
44
|
-
afterEach(() => {
|
|
45
|
-
vi.clearAllMocks();
|
|
46
|
-
});
|
|
47
|
-
it('should render mcp resource with content', () => {
|
|
48
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpResource, { name: "test-resource", id: "test-resource" }) }), {
|
|
49
|
-
definition: spec,
|
|
50
|
-
options: {},
|
|
51
|
-
}));
|
|
52
|
-
expect(screen.getByText('Resource URI:')).toBeInTheDocument();
|
|
53
|
-
expect(screen.getByText('mcp://test-resource')).toBeInTheDocument();
|
|
54
|
-
expect(screen.getByText('Resource MIME type:')).toBeInTheDocument();
|
|
55
|
-
expect(screen.getAllByText('application/json').length).toBeGreaterThanOrEqual(1);
|
|
56
|
-
expect(screen.getByText('Resource content')).toBeInTheDocument();
|
|
57
|
-
expect(screen.getByText(/"key": "value"/)).toBeInTheDocument();
|
|
58
|
-
expect(screen.getByText('Security')).toBeInTheDocument();
|
|
59
|
-
expect(screen.getByText('apiKey')).toBeInTheDocument();
|
|
60
|
-
});
|
|
61
|
-
it('should render a message if resource not found', () => {
|
|
62
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpResource, { name: "not-found", id: "not-found" }) }), {
|
|
63
|
-
definition: spec,
|
|
64
|
-
options: {},
|
|
65
|
-
}));
|
|
66
|
-
expect(screen.getByText('Resource not found: not-found')).toBeInTheDocument();
|
|
67
|
-
});
|
|
68
|
-
it('should copy URI to clipboard when clicked', async () => {
|
|
69
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpResource, { name: "test-resource", id: "test-resource" }) }), {
|
|
70
|
-
definition: spec,
|
|
71
|
-
options: {},
|
|
72
|
-
}));
|
|
73
|
-
const uriElement = screen.getByText('mcp://test-resource');
|
|
74
|
-
fireEvent.click(uriElement);
|
|
75
|
-
expect(mockClipboard.writeText).toHaveBeenCalledWith('mcp://test-resource');
|
|
76
|
-
await waitFor(() => {
|
|
77
|
-
expect(screen.getByText('✓ Copied!')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=McpResource.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { McpTool } from '../McpTool.js';
|
|
4
|
-
import { withTestProviders, TestMemoryRouter } from '../../../testProviders.js';
|
|
5
|
-
import mcpData from './fixtures/mcp-tools.json';
|
|
6
|
-
const spec = {
|
|
7
|
-
openapi: '3.0.0',
|
|
8
|
-
'x-mcp': mcpData,
|
|
9
|
-
components: {
|
|
10
|
-
securitySchemes: {
|
|
11
|
-
apiKey: {
|
|
12
|
-
type: 'apiKey',
|
|
13
|
-
in: 'header',
|
|
14
|
-
name: 'X-API-Key',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
describe('McpTool', () => {
|
|
20
|
-
it('should render mcp tool with input and output schema', () => {
|
|
21
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpTool, { name: "test-tool", id: "test-tool" }) }), {
|
|
22
|
-
definition: spec,
|
|
23
|
-
options: {},
|
|
24
|
-
}));
|
|
25
|
-
expect(screen.getByText('Input schema')).toBeInTheDocument();
|
|
26
|
-
expect(screen.getByText('inputProperty')).toBeInTheDocument();
|
|
27
|
-
expect(screen.getByText('Output schema')).toBeInTheDocument();
|
|
28
|
-
expect(screen.getByText('outputProperty')).toBeInTheDocument();
|
|
29
|
-
expect(screen.getByText('Security')).toBeInTheDocument();
|
|
30
|
-
expect(screen.getByText('apiKey')).toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
it('should render a message if tool not found', () => {
|
|
33
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpTool, { name: "not-found", id: "not-found" }) }), {
|
|
34
|
-
definition: spec,
|
|
35
|
-
options: {},
|
|
36
|
-
}));
|
|
37
|
-
expect(screen.getByText('Tool not found: not-found')).toBeInTheDocument();
|
|
38
|
-
});
|
|
39
|
-
it('should render without output schema', () => {
|
|
40
|
-
const specWithoutOutput = {
|
|
41
|
-
...spec,
|
|
42
|
-
'x-mcp': {
|
|
43
|
-
...spec['x-mcp'],
|
|
44
|
-
tools: [
|
|
45
|
-
{
|
|
46
|
-
name: 'test-tool-no-output',
|
|
47
|
-
description: 'A test tool without output schema',
|
|
48
|
-
inputSchema: {
|
|
49
|
-
type: 'object',
|
|
50
|
-
properties: {
|
|
51
|
-
inputProperty: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpTool, { name: "test-tool-no-output", id: "test-tool-no-output" }) }), {
|
|
61
|
-
definition: specWithoutOutput,
|
|
62
|
-
options: {},
|
|
63
|
-
}));
|
|
64
|
-
expect(screen.getByText('Input schema')).toBeInTheDocument();
|
|
65
|
-
expect(screen.queryByText('Output schema')).not.toBeInTheDocument();
|
|
66
|
-
});
|
|
67
|
-
it('should apply middle panel horizontal padding overrides', () => {
|
|
68
|
-
const { container } = render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(McpTool, { name: "test-tool", id: "test-tool" }) }), {
|
|
69
|
-
definition: spec,
|
|
70
|
-
options: {},
|
|
71
|
-
}));
|
|
72
|
-
const middlePanel = container.querySelector('.mcp-tool > div > div');
|
|
73
|
-
expect(middlePanel).toBeTruthy();
|
|
74
|
-
expect(middlePanel).toHaveStyle({ paddingLeft: '0px' });
|
|
75
|
-
const styles = Array.from(document.querySelectorAll('style'))
|
|
76
|
-
.map((tag) => tag.textContent ?? '')
|
|
77
|
-
.join('\n');
|
|
78
|
-
expect(styles).toMatch(/padding-left:\s*0/);
|
|
79
|
-
expect(styles).toMatch(/padding-right:\s*var\(--panel-gap-horizontal\)/);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
//# sourceMappingURL=McpTool.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|