@redocly/openapi-docs 3.24.0-next.9 → 3.24.1
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/dist/{redocly-openapi-docs.min.AiChatProvider-DcsGB2gP.js → redocly-openapi-docs.min.AiChatProvider-j-VDfFJ9.js} +3 -3
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-wCZA4usG.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-BBRBmffc.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-jo7fqtSt.js → redocly-openapi-docs.min.AiPanel-DTzHqAiI.js} +116 -116
- package/dist/redocly-openapi-docs.min.FileWatcher-DDoyaS7A.js +1 -0
- package/dist/redocly-openapi-docs.min.Observable-D6wKbFwB.js +1 -0
- package/dist/redocly-openapi-docs.min.SemanticSearchService-DNFOPBZK.js +1 -0
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-B_f6WR8o.js → redocly-openapi-docs.min.SqliteDBStorage-Dy40Vq04.js} +1 -1
- package/dist/redocly-openapi-docs.min.TauriFileSystemAdapter-CpViFqJQ.js +1 -0
- package/dist/redocly-openapi-docs.min.TauriRootStorage-TCUrp2uB.js +1 -0
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js +1 -0
- package/dist/redocly-openapi-docs.min.core-BYyFOtMX.js +1 -0
- package/dist/redocly-openapi-docs.min.external-resolver-BkceRyB4.js +2 -0
- package/dist/redocly-openapi-docs.min.index-BCcol5vU.js +1 -0
- package/dist/redocly-openapi-docs.min.index-C6uU_v-b.js +1 -0
- package/dist/redocly-openapi-docs.min.index-CmXZfuiZ.js +7730 -0
- package/dist/redocly-openapi-docs.min.index-DVWw0ICA.js +1 -0
- package/dist/redocly-openapi-docs.min.index-YnvLQkG_.js +1 -0
- package/dist/redocly-openapi-docs.min.index-xl_tBaHD.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-C-zlwxhp.js → redocly-openapi-docs.min.lint-2YpbCz3r.js} +69 -69
- package/dist/{redocly-openapi-docs.min.lint-graphql-qEh9cZHx.js → redocly-openapi-docs.min.lint-graphql-Bgfcu2tP.js} +1 -1
- package/dist/redocly-openapi-docs.min.periodic-revalidation-Dsp-n7ui.js +1 -0
- package/dist/redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js +1 -0
- package/dist/{redocly-openapi-docs.min.respect-run-hfNPYQ9x.js → redocly-openapi-docs.min.respect-run-Ct8taisL.js} +1 -1
- package/dist/redocly-openapi-docs.min.standalone-BPCdJgtH.js +11995 -0
- package/dist/redocly-openapi-docs.min.tauri-path-CmqBCxGb.js +1 -0
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-DgSsCKMW.js → redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js} +80 -80
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +1 -0
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +46 -0
- package/lib/components/Callbacks/CallbackOperation.js +1 -1
- package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +1 -0
- package/lib/components/Callbacks/__tests__/Callbacks.test.js +46 -0
- package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +1 -0
- package/lib/components/Content/__tests__/useAutoScroll.test.js +88 -0
- package/lib/components/Content/useAutoScroll.js +1 -1
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +1 -0
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +123 -0
- package/lib/components/ContentItem/useIsExpanded.js +1 -1
- package/lib/components/ContentItems/ContentItems.js +1 -1
- package/lib/components/ContentItems/VirtualList.js +1 -1
- package/lib/components/ContentItems/__tests__/Items.test.d.ts +1 -0
- package/lib/components/ContentItems/__tests__/Items.test.js +66 -0
- package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +1 -0
- package/lib/components/ContentItems/__tests__/VirtualList.test.js +135 -0
- package/lib/components/ContentItems/useScrollOnRender.js +1 -1
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +1 -0
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +63 -0
- package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +1 -0
- package/lib/components/Download/__tests__/DownloadSpecification.test.js +52 -0
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +1 -0
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +60 -0
- package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +1 -0
- package/lib/components/ExpandAllButton/__tests__/helpers.test.js +133 -0
- package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +1 -0
- package/lib/components/Language/__tests__/LanguageDropdown.test.js +23 -0
- package/lib/components/Markdown/__tests__/Markdown.test.d.ts +1 -0
- package/lib/components/Markdown/__tests__/Markdown.test.js +34 -0
- package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +1 -0
- package/lib/components/McpOverview/__tests__/McpOverview.test.js +66 -0
- package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpPrompt.test.js +57 -0
- package/lib/components/McpTool/__tests__/McpResource.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpResource.test.js +81 -0
- package/lib/components/McpTool/__tests__/McpTool.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpTool.test.js +82 -0
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +1 -0
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +79 -0
- package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +1 -0
- package/lib/components/OperationItem/__tests__/OperationItem.test.js +70 -0
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +16 -0
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +42 -0
- package/lib/components/Overview/__tests__/Overview.test.d.ts +1 -0
- package/lib/components/Overview/__tests__/Overview.test.js +59 -0
- package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/Example.test.js +36 -0
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +197 -0
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +38 -0
- package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/Extensions.test.js +21 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +52 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +191 -0
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +365 -0
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +23 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +1 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +16 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +1 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +104 -0
- package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +1 -0
- package/lib/components/RenderHook/__tests__/RenderHook.test.js +15 -0
- package/lib/components/Replay/__tests__/utils.test.d.ts +1 -0
- package/lib/components/Replay/__tests__/utils.test.js +526 -0
- package/lib/components/Request/__tests__/RequestDetails.test.d.ts +1 -0
- package/lib/components/Request/__tests__/RequestDetails.test.js +98 -0
- package/lib/components/RequestSamples/__tests__/Example.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/Example.test.js +384 -0
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +226 -0
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +64 -0
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +1 -0
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +29 -0
- package/lib/components/Responses/OperationResponseList.js +1 -1
- package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/OperationResponseList.test.js +89 -0
- package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/ResponseDetails.test.js +111 -0
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +26 -0
- package/lib/components/Schema/Schema.js +1 -1
- package/lib/components/Schema/SubSchema.js +1 -1
- package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/ArraySchema.test.js +93 -0
- package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/ObjectSchema.test.js +115 -0
- package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/OneOfSchema.test.js +33 -0
- package/lib/components/Schema/__tests__/Schema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/Schema.test.js +67 -0
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +22 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +1 -1
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +1 -0
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +95 -0
- package/lib/components/Security/__tests__/Security.test.d.ts +1 -0
- package/lib/components/Security/__tests__/Security.test.js +38 -0
- package/lib/components/Security/__tests__/SecurityButton.test.d.ts +1 -0
- package/lib/components/Security/__tests__/SecurityButton.test.js +92 -0
- package/lib/components/Security/__tests__/SecurityModal.test.d.ts +1 -0
- package/lib/components/Security/__tests__/SecurityModal.test.js +172 -0
- package/lib/components/ServerList/__tests__/ServerList.test.d.ts +1 -0
- package/lib/components/ServerList/__tests__/ServerList.test.js +83 -0
- package/lib/components/SideMenu/hooks/useMenuItems.js +1 -1
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +1 -1
- package/lib/components/Tabs/__tests__/Tabs.test.d.ts +1 -0
- package/lib/components/Tabs/__tests__/Tabs.test.js +27 -0
- package/lib/components/TagItem/OperationsNavigation.js +1 -1
- package/lib/components/TagItem/TagItem.js +1 -1
- package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +1 -0
- package/lib/components/ViewNested/__tests__/ViewNested.test.js +42 -0
- package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +1 -0
- package/lib/components/__tests__/Samples/ExampleSwitch.test.js +45 -0
- package/lib/components/__tests__/Samples/use-example-key.test.d.ts +1 -0
- package/lib/components/__tests__/Samples/use-example-key.test.js +28 -0
- package/lib/components/__tests__/common/ClearButton.test.d.ts +1 -0
- package/lib/components/__tests__/common/ClearButton.test.js +18 -0
- package/lib/components/__tests__/common/Dropdown.test.d.ts +1 -0
- package/lib/components/__tests__/common/Dropdown.test.js +52 -0
- package/lib/components/__tests__/mocks/examples.d.ts +4 -0
- package/lib/components/__tests__/mocks/examples.js +115 -0
- package/lib/components/common/LinkToField.js +1 -1
- package/lib/components/common/__tests__/Dropdown.test.d.ts +1 -0
- package/lib/components/common/__tests__/Dropdown.test.js +129 -0
- package/lib/components/common/__tests__/LinkToField.test.d.ts +1 -0
- package/lib/components/common/__tests__/LinkToField.test.js +39 -0
- package/lib/components/common/linkify.js +1 -1
- package/lib/hooks/useRouter.js +1 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +1 -1
- package/lib/jotai/__tests__/app.test.d.ts +1 -0
- package/lib/jotai/__tests__/app.test.js +53 -0
- package/lib/models/__tests__/Callback.test.d.ts +1 -0
- package/lib/models/__tests__/Callback.test.js +15 -0
- package/lib/models/__tests__/FieldModel.test.d.ts +1 -0
- package/lib/models/__tests__/FieldModel.test.js +117 -0
- package/lib/models/__tests__/MediaContent.test.d.ts +1 -0
- package/lib/models/__tests__/MediaContent.test.js +105 -0
- package/lib/models/__tests__/Operation.test.d.ts +1 -0
- package/lib/models/__tests__/Operation.test.js +459 -0
- package/lib/models/__tests__/Response.test.d.ts +1 -0
- package/lib/models/__tests__/Response.test.js +221 -0
- package/lib/models/__tests__/Schema.circular.test.d.ts +1 -0
- package/lib/models/__tests__/Schema.circular.test.js +694 -0
- package/lib/models/__tests__/Schema.test.d.ts +1 -0
- package/lib/models/__tests__/Schema.test.js +1395 -0
- package/lib/models/__tests__/example.test.d.ts +1 -0
- package/lib/models/__tests__/example.test.js +90 -0
- package/lib/models/__tests__/group.test.d.ts +1 -0
- package/lib/models/__tests__/group.test.js +52 -0
- package/lib/models/__tests__/helpers.d.ts +5 -0
- package/lib/models/__tests__/helpers.js +62 -0
- package/lib/models/__tests__/request.test.d.ts +1 -0
- package/lib/models/__tests__/request.test.js +119 -0
- package/lib/services/__tests__/OpenAPIParser.test.d.ts +1 -0
- package/lib/services/__tests__/OpenAPIParser.test.js +80 -0
- package/lib/services/__tests__/check.test.d.ts +1 -0
- package/lib/services/__tests__/check.test.js +22 -0
- package/lib/services/__tests__/utils.test.d.ts +1 -0
- package/lib/services/__tests__/utils.test.js +42 -0
- package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/apply-environments.test.js +64 -0
- package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/build-code-samples.test.js +70 -0
- package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/convertSampleToString.test.js +116 -0
- package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-data-value.test.js +277 -0
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +258 -0
- package/lib/services/code-samples/__tests__/generator-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-value.test.js +273 -0
- package/lib/services/code-samples/__tests__/generator.test.d.ts +249 -0
- package/lib/services/code-samples/__tests__/generator.test.js +1201 -0
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +31 -0
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +222 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +129 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +49 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +130 -0
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +191 -0
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +85 -0
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +85 -0
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +126 -0
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +105 -0
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +126 -0
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +129 -0
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +129 -0
- package/lib/services/config-options/__tests__/helpers.test.d.ts +1 -0
- package/lib/services/config-options/__tests__/helpers.test.js +234 -0
- package/lib/services/history/__tests__/helpers.test.d.ts +1 -0
- package/lib/services/history/__tests__/helpers.test.js +19 -0
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +1 -0
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +109 -0
- package/lib/services/menu/__tests__/builder.test.d.ts +1 -0
- package/lib/services/menu/__tests__/builder.test.js +307 -0
- package/lib/services/menu/__tests__/operation.test.d.ts +1 -0
- package/lib/services/menu/__tests__/operation.test.js +240 -0
- package/lib/services/menu/__tests__/tags.test.d.ts +1 -0
- package/lib/services/menu/__tests__/tags.test.js +71 -0
- package/lib/telemetry/RedocTelemetry.js +31 -1
- package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +1 -0
- package/lib/telemetry/__tests__/RedocTelemetry.test.js +107 -0
- package/lib/testProviders.d.ts +6 -0
- package/lib/testProviders.js +14 -0
- package/lib/utils/__tests__/areArraysEqual.test.d.ts +1 -0
- package/lib/utils/__tests__/areArraysEqual.test.js +33 -0
- package/lib/utils/__tests__/argValuesHelpers.d.ts +1 -0
- package/lib/utils/__tests__/argValuesHelpers.js +56 -0
- package/lib/utils/__tests__/calculateMaxLength.test.d.ts +1 -0
- package/lib/utils/__tests__/calculateMaxLength.test.js +119 -0
- package/lib/utils/__tests__/configure-helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/configure-helpers.test.js +356 -0
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +1 -0
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +392 -0
- package/lib/utils/__tests__/debounce.test.d.ts +1 -0
- package/lib/utils/__tests__/debounce.test.js +54 -0
- package/lib/utils/__tests__/debug.test.d.ts +1 -0
- package/lib/utils/__tests__/debug.test.js +23 -0
- package/lib/utils/__tests__/dom.test.d.ts +1 -0
- package/lib/utils/__tests__/dom.test.js +108 -0
- package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +1 -0
- package/lib/utils/__tests__/getBreadcrumbs.test.js +98 -0
- package/lib/utils/__tests__/hasNestedFields.test.d.ts +1 -0
- package/lib/utils/__tests__/hasNestedFields.test.js +147 -0
- package/lib/utils/__tests__/helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/helpers.test.js +174 -0
- package/lib/utils/__tests__/isMobile.test.d.ts +1 -0
- package/lib/utils/__tests__/isMobile.test.js +28 -0
- package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +1 -0
- package/lib/utils/__tests__/loadAndBundleSpec.test.js +22 -0
- package/lib/utils/__tests__/local-storage.test.d.ts +1 -0
- package/lib/utils/__tests__/local-storage.test.js +48 -0
- package/lib/utils/__tests__/object.test.d.ts +1 -0
- package/lib/utils/__tests__/object.test.js +45 -0
- package/lib/utils/__tests__/openapi.test.d.ts +1 -0
- package/lib/utils/__tests__/openapi.test.js +1378 -0
- package/lib/utils/__tests__/path.test.d.ts +1 -0
- package/lib/utils/__tests__/path.test.js +16 -0
- package/lib/utils/__tests__/queryString.test.d.ts +1 -0
- package/lib/utils/__tests__/queryString.test.js +60 -0
- package/lib/utils/__tests__/replaceVariables.test.d.ts +1 -0
- package/lib/utils/__tests__/replaceVariables.test.js +46 -0
- package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +1 -0
- package/lib/utils/__tests__/simplifyAstStructure.test.js +26 -0
- package/lib/utils/__tests__/sort.test.d.ts +1 -0
- package/lib/utils/__tests__/sort.test.js +16 -0
- package/lib/utils/__tests__/string.test.d.ts +1 -0
- package/lib/utils/__tests__/string.test.js +16 -0
- package/lib/utils/__tests__/theme-helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/theme-helpers.test.js +24 -0
- package/lib/utils/__tests__/url.test.d.ts +1 -0
- package/lib/utils/__tests__/url.test.js +134 -0
- package/lib/utils/path.d.ts +1 -1
- package/package.json +12 -12
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-MY79QAeW.js +0 -1
- package/dist/redocly-openapi-docs.min.external-resolver-3KMJv7SC.js +0 -2
- package/dist/redocly-openapi-docs.min.index-BYVMr_la.js +0 -1
- package/dist/redocly-openapi-docs.min.index-CsqzTi3Z.js +0 -7586
- package/dist/redocly-openapi-docs.min.index-D8F7x0S6.js +0 -1
- package/dist/redocly-openapi-docs.min.index-qqKTpI_q.js +0 -1
- package/dist/redocly-openapi-docs.min.standalone-Ci6886Cr.js +0 -12114
- package/dist/redocly-openapi-docs.min.tauri-path-Bs1-AQjc.js +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { RequestDetails } from '../RequestDetails.js';
|
|
4
|
+
import { getField, getMediaContent } from '../../../models/index.js';
|
|
5
|
+
import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
|
|
6
|
+
import { withTestProviders, TestMemoryRouter } from '../../../testProviders.js';
|
|
7
|
+
const OPERATION_POINTER = '#/paths/~1pets/get';
|
|
8
|
+
// Wide enough that 45 * 45 = 2025 rows blow the 2000-row budget one level after
|
|
9
|
+
// the schema's own properties.
|
|
10
|
+
const WIDTH = 45;
|
|
11
|
+
const SMALL_WIDTH = 44;
|
|
12
|
+
function makeWideProperties(prefix, value, width = WIDTH) {
|
|
13
|
+
return Object.fromEntries(Array.from({ length: width }, (_, i) => [`${prefix}_${i}`, { ...value }]));
|
|
14
|
+
}
|
|
15
|
+
const definition = {
|
|
16
|
+
openapi: '3.0.0',
|
|
17
|
+
info: { title: 'test', version: '0' },
|
|
18
|
+
paths: {},
|
|
19
|
+
components: {
|
|
20
|
+
schemas: {
|
|
21
|
+
Small: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: makeWideProperties('small', { $ref: '#/components/schemas/SmallLeaf' }, SMALL_WIDTH),
|
|
24
|
+
},
|
|
25
|
+
SmallLeaf: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: makeWideProperties('small_leaf', { type: 'string' }, SMALL_WIDTH),
|
|
28
|
+
},
|
|
29
|
+
Big: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: makeWideProperties('big', { $ref: '#/components/schemas/BigLeaf' }),
|
|
32
|
+
},
|
|
33
|
+
BigLeaf: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: makeWideProperties('leaf', { type: 'string' }),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// The probe replaces the parameters/body tree: it renders a real SubSchema at the
|
|
41
|
+
// level nested parameter nodes actually mount at (PropertyDetails defaults level
|
|
42
|
+
// to 1 and passes level + 1), so the test observes whether "Expand all" reaches
|
|
43
|
+
// parameter nesting.
|
|
44
|
+
vi.mock('../../RequestParameters/index.js', async () => {
|
|
45
|
+
const { SubSchema } = await import('../../Schema/SubSchema.js');
|
|
46
|
+
return {
|
|
47
|
+
RequestParameters: () => (_jsx(SubSchema, { expandByDefault: false, expandable: true, level: 2, propertyLength: WIDTH, deepLink: `${OPERATION_POINTER}/t=request`, operationPointer: OPERATION_POINTER, children: _jsx("div", { "data-testid": "nested-content" }) })),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
const options = normalizeOptions({});
|
|
51
|
+
const parser = new OpenAPIParser(definition, undefined, options);
|
|
52
|
+
const operationDeps = { operation: { pointer: OPERATION_POINTER } };
|
|
53
|
+
function makeOperation(overrides) {
|
|
54
|
+
return {
|
|
55
|
+
id: 'getPets',
|
|
56
|
+
pointer: OPERATION_POINTER,
|
|
57
|
+
description: undefined,
|
|
58
|
+
externalDocs: undefined,
|
|
59
|
+
extensions: {},
|
|
60
|
+
security: [],
|
|
61
|
+
parameters: [],
|
|
62
|
+
requestBody: undefined,
|
|
63
|
+
callbackId: '',
|
|
64
|
+
...overrides,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function renderRequestDetails(operation) {
|
|
68
|
+
return render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(RequestDetails, { operation: operation, translate: (_key, value) => value || _key }) }), { definition }));
|
|
69
|
+
}
|
|
70
|
+
describe('RequestDetails expand-all depth', () => {
|
|
71
|
+
it('expands parameter nesting one level when the parameter schema fits the budget', () => {
|
|
72
|
+
const parameter = getField(parser, { name: 'filter', in: 'query', schema: { $ref: '#/components/schemas/Small' } }, '', options, operationDeps);
|
|
73
|
+
renderRequestDetails(makeOperation({ parameters: [parameter] }));
|
|
74
|
+
expect(screen.queryByTestId('nested-content')).not.toBeInTheDocument();
|
|
75
|
+
// A parameter's own property rows render behind a level-2 node (the parameter
|
|
76
|
+
// row itself is level 1). Showing the 45 properties fits the budget, so
|
|
77
|
+
// "Expand all" must open the parameter node — not skip parameters entirely.
|
|
78
|
+
fireEvent.click(screen.getByRole('button', { name: /expand all/i }));
|
|
79
|
+
expect(screen.getByTestId('nested-content')).toBeInTheDocument();
|
|
80
|
+
});
|
|
81
|
+
it('keeps nested body nodes collapsed when their rows exceed the budget', () => {
|
|
82
|
+
const requestBody = {
|
|
83
|
+
content: getMediaContent({
|
|
84
|
+
parser,
|
|
85
|
+
info: { 'application/json': { schema: { $ref: '#/components/schemas/Big' } } },
|
|
86
|
+
isRequestType: true,
|
|
87
|
+
options,
|
|
88
|
+
data: operationDeps,
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
renderRequestDetails(makeOperation({ requestBody }));
|
|
92
|
+
// The body root's 45 property rows are always visible; expanding their nested
|
|
93
|
+
// level-2 nodes would add 2025 rows and blow the budget, so depth stays 1.
|
|
94
|
+
fireEvent.click(screen.getByRole('button', { name: /expand all/i }));
|
|
95
|
+
expect(screen.queryByTestId('nested-content')).not.toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=RequestDetails.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { Example } from '../Example.js';
|
|
5
|
+
import { withTestProviders } from '../../../testProviders.js';
|
|
6
|
+
// Mock the dependencies
|
|
7
|
+
vi.mock('../../Samples', () => ({
|
|
8
|
+
ExampleSwitch: ({ examples, exampleKey, onChange, }) => (_jsx("div", { "data-testid": "example-switch", children: _jsx("select", { "data-testid": "example-selector", value: exampleKey, onChange: (e) => onChange(e.target.value), children: Object.keys(examples).map((key) => (_jsx("option", { value: key, children: key }, key))) }) })),
|
|
9
|
+
useExampleKey: vi.fn(() => ({ exampleKey: 'bee' })),
|
|
10
|
+
}));
|
|
11
|
+
import { useTelemetry, useActivateExample } from '../../../hooks/index.js';
|
|
12
|
+
import { useExampleKey } from '../../Samples/index.js';
|
|
13
|
+
vi.mock('../../../hooks', async () => ({
|
|
14
|
+
...(await vi.importActual('../../../hooks')),
|
|
15
|
+
useActivateExample: vi.fn(() => vi.fn()),
|
|
16
|
+
useTelemetry: vi.fn(() => ({
|
|
17
|
+
sendExamplesSwitcherClickedMessage: vi.fn(),
|
|
18
|
+
})),
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('../../../jotai/operation', () => ({
|
|
21
|
+
operationStore: vi.fn(() => ({
|
|
22
|
+
toString: () => 'operationStore',
|
|
23
|
+
})),
|
|
24
|
+
}));
|
|
25
|
+
import { useAtom } from 'jotai';
|
|
26
|
+
const mockUseTelemetry = vi.mocked(useTelemetry);
|
|
27
|
+
const mockUseActivateExample = vi.mocked(useActivateExample);
|
|
28
|
+
const mockUseExampleKey = vi.mocked(useExampleKey);
|
|
29
|
+
// Mock jotai at module level
|
|
30
|
+
vi.mock('jotai', async () => {
|
|
31
|
+
const actual = await vi.importActual('jotai');
|
|
32
|
+
return {
|
|
33
|
+
...actual,
|
|
34
|
+
useAtom: vi.fn(),
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const mockUseAtom = vi.mocked(useAtom);
|
|
38
|
+
describe('Example component', () => {
|
|
39
|
+
const mockMediaType = {
|
|
40
|
+
name: 'application/json',
|
|
41
|
+
examples: {
|
|
42
|
+
bee: {
|
|
43
|
+
mime: 'application/json',
|
|
44
|
+
value: {
|
|
45
|
+
petType: 'bee',
|
|
46
|
+
honeyPerDay: 3.14,
|
|
47
|
+
},
|
|
48
|
+
rawValue: {
|
|
49
|
+
petType: 'bee',
|
|
50
|
+
honeyPerDay: 3.14,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
schema: undefined,
|
|
55
|
+
isRequestType: true,
|
|
56
|
+
onlyRequiredInSamples: false,
|
|
57
|
+
operation: {
|
|
58
|
+
pointer: '/paths/~1pet/post',
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const mockMediaContent = {
|
|
62
|
+
mediaTypes: [mockMediaType],
|
|
63
|
+
};
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
vi.clearAllMocks();
|
|
66
|
+
vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
67
|
+
mockUseAtom.mockReturnValue([
|
|
68
|
+
{
|
|
69
|
+
activeExampleName: 'bee',
|
|
70
|
+
activeOneOf: {},
|
|
71
|
+
requestValues: { body: null },
|
|
72
|
+
},
|
|
73
|
+
vi.fn(),
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
vi.restoreAllMocks();
|
|
78
|
+
});
|
|
79
|
+
it('should render component with single example without ExampleSwitch', () => {
|
|
80
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
81
|
+
render(withTestProviders(_jsx(Example, { mediaType: mockMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
82
|
+
expect(renderSample).toHaveBeenCalledWith();
|
|
83
|
+
expect(screen.queryByTestId('example-switch')).not.toBeInTheDocument();
|
|
84
|
+
expect(screen.getByTestId('sample')).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
it('should render component without examples', () => {
|
|
87
|
+
const noExamplesMediaType = {
|
|
88
|
+
...mockMediaType,
|
|
89
|
+
examples: undefined,
|
|
90
|
+
formExamples: undefined,
|
|
91
|
+
};
|
|
92
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
93
|
+
render(withTestProviders(_jsx(Example, { mediaType: noExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
94
|
+
expect(renderSample).toHaveBeenCalledWith();
|
|
95
|
+
expect(screen.queryByTestId('example-switch')).not.toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
it('should render component with multiple examples and ExampleSwitch', () => {
|
|
98
|
+
const multipleExamplesMediaType = {
|
|
99
|
+
...mockMediaType,
|
|
100
|
+
examples: {
|
|
101
|
+
bee: {
|
|
102
|
+
mime: 'application/json',
|
|
103
|
+
value: { petType: 'bee' },
|
|
104
|
+
rawValue: { petType: 'bee' },
|
|
105
|
+
},
|
|
106
|
+
cat: {
|
|
107
|
+
mime: 'application/json',
|
|
108
|
+
value: { petType: 'cat' },
|
|
109
|
+
rawValue: { petType: 'cat' },
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
114
|
+
render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
115
|
+
expect(screen.getByTestId('example-switch')).toBeInTheDocument();
|
|
116
|
+
expect(renderSample).toHaveBeenCalledWith('bee');
|
|
117
|
+
});
|
|
118
|
+
it('should handle example change correctly', async () => {
|
|
119
|
+
const user = userEvent.setup();
|
|
120
|
+
const setOperation = vi.fn();
|
|
121
|
+
const sendTelemetry = vi.fn();
|
|
122
|
+
const setActivateExampleName = vi.fn();
|
|
123
|
+
mockUseAtom.mockReturnValue([
|
|
124
|
+
{
|
|
125
|
+
activeExampleName: 'bee',
|
|
126
|
+
activeOneOf: {},
|
|
127
|
+
requestValues: { body: null },
|
|
128
|
+
},
|
|
129
|
+
setOperation,
|
|
130
|
+
]);
|
|
131
|
+
mockUseTelemetry.mockReturnValue({
|
|
132
|
+
sendExamplesSwitcherClickedMessage: sendTelemetry,
|
|
133
|
+
});
|
|
134
|
+
mockUseActivateExample.mockReturnValue(setActivateExampleName);
|
|
135
|
+
const multipleExamplesMediaType = {
|
|
136
|
+
...mockMediaType,
|
|
137
|
+
examples: {
|
|
138
|
+
bee: {
|
|
139
|
+
mime: 'application/json',
|
|
140
|
+
value: { petType: 'bee' },
|
|
141
|
+
rawValue: { petType: 'bee' },
|
|
142
|
+
},
|
|
143
|
+
cat: {
|
|
144
|
+
mime: 'application/json',
|
|
145
|
+
value: { petType: 'cat' },
|
|
146
|
+
rawValue: { petType: 'cat' },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
151
|
+
render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
152
|
+
const selector = screen.getByTestId('example-selector');
|
|
153
|
+
await user.selectOptions(selector, 'cat');
|
|
154
|
+
await waitFor(() => {
|
|
155
|
+
expect(sendTelemetry).toHaveBeenCalledWith([
|
|
156
|
+
{
|
|
157
|
+
object: 'button',
|
|
158
|
+
exampleNumber: 1,
|
|
159
|
+
totalExamples: 2,
|
|
160
|
+
id: 'examplesSwitcherButton',
|
|
161
|
+
uri: 'urn:redocly:redoc:ui:button:examplesSwitcherButton',
|
|
162
|
+
},
|
|
163
|
+
]);
|
|
164
|
+
expect(setOperation).toHaveBeenCalledWith(expect.objectContaining({
|
|
165
|
+
activeExampleName: 'cat',
|
|
166
|
+
activeOneOf: expect.any(Object),
|
|
167
|
+
requestValues: { body: null },
|
|
168
|
+
}));
|
|
169
|
+
expect(setActivateExampleName).toHaveBeenCalledWith('cat');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
it('should use formExamples when examples is undefined', () => {
|
|
173
|
+
const formExamplesMediaType = {
|
|
174
|
+
...mockMediaType,
|
|
175
|
+
examples: undefined,
|
|
176
|
+
formExamples: {
|
|
177
|
+
example1: {
|
|
178
|
+
mime: 'application/x-www-form-urlencoded',
|
|
179
|
+
value: { field: 'value1' },
|
|
180
|
+
rawValue: { field: 'value1' },
|
|
181
|
+
},
|
|
182
|
+
example2: {
|
|
183
|
+
mime: 'application/x-www-form-urlencoded',
|
|
184
|
+
value: { field: 'value2' },
|
|
185
|
+
rawValue: { field: 'value2' },
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
190
|
+
render(withTestProviders(_jsx(Example, { mediaType: formExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
191
|
+
expect(screen.getByTestId('example-switch')).toBeInTheDocument();
|
|
192
|
+
expect(renderSample).toHaveBeenCalledWith('bee');
|
|
193
|
+
});
|
|
194
|
+
it('should memoize the component correctly', () => {
|
|
195
|
+
const multipleExamplesMediaType = {
|
|
196
|
+
...mockMediaType,
|
|
197
|
+
examples: {
|
|
198
|
+
bee: {
|
|
199
|
+
mime: 'application/json',
|
|
200
|
+
value: { petType: 'bee' },
|
|
201
|
+
rawValue: { petType: 'bee' },
|
|
202
|
+
},
|
|
203
|
+
cat: {
|
|
204
|
+
mime: 'application/json',
|
|
205
|
+
value: { petType: 'cat' },
|
|
206
|
+
rawValue: { petType: 'cat' },
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
211
|
+
const { rerender } = render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
212
|
+
const initialCallCount = renderSample.mock.calls.length;
|
|
213
|
+
// Rerender with the same props
|
|
214
|
+
rerender(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
215
|
+
// The renderSample should not be called again due to memoization
|
|
216
|
+
expect(renderSample.mock.calls.length).toBe(initialCallCount);
|
|
217
|
+
});
|
|
218
|
+
it('should use examplesPointer when provided for activeOneOf', () => {
|
|
219
|
+
const customPointer = '/paths/~1pet/post/requestBody/content/application~1json';
|
|
220
|
+
const multipleExamplesMediaType = {
|
|
221
|
+
...mockMediaType,
|
|
222
|
+
examplesPointer: customPointer,
|
|
223
|
+
examples: {
|
|
224
|
+
bee: {
|
|
225
|
+
mime: 'application/json',
|
|
226
|
+
value: { petType: 'bee' },
|
|
227
|
+
rawValue: { petType: 'bee' },
|
|
228
|
+
},
|
|
229
|
+
cat: {
|
|
230
|
+
mime: 'application/json',
|
|
231
|
+
value: { petType: 'cat' },
|
|
232
|
+
rawValue: { petType: 'cat' },
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
mockUseAtom.mockReturnValue([
|
|
237
|
+
{
|
|
238
|
+
activeExampleName: 'cat',
|
|
239
|
+
activeOneOf: { [customPointer]: 1 },
|
|
240
|
+
requestValues: { body: null },
|
|
241
|
+
},
|
|
242
|
+
vi.fn(),
|
|
243
|
+
]);
|
|
244
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
245
|
+
render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
246
|
+
expect(screen.getByTestId('example-switch')).toBeInTheDocument();
|
|
247
|
+
// Should render with 'cat' example since activeOneOf[customPointer] = 1
|
|
248
|
+
expect(renderSample).toHaveBeenCalledWith('cat');
|
|
249
|
+
});
|
|
250
|
+
it('should use examplesPointer in handleExampleChange when it starts with operation pointer', async () => {
|
|
251
|
+
const user = userEvent.setup();
|
|
252
|
+
const setOperation = vi.fn();
|
|
253
|
+
const setActivateExampleName = vi.fn();
|
|
254
|
+
const sendTelemetry = vi.fn();
|
|
255
|
+
const operationPointer = '/paths/~1pet/post';
|
|
256
|
+
const examplesPointer = '/paths/~1pet/post/requestBody/content/application~1json';
|
|
257
|
+
const multipleExamplesMediaType = {
|
|
258
|
+
...mockMediaType,
|
|
259
|
+
operation: {
|
|
260
|
+
...mockMediaType.operation,
|
|
261
|
+
pointer: operationPointer,
|
|
262
|
+
},
|
|
263
|
+
examplesPointer,
|
|
264
|
+
examples: {
|
|
265
|
+
bee: {
|
|
266
|
+
mime: 'application/json',
|
|
267
|
+
value: { petType: 'bee' },
|
|
268
|
+
rawValue: { petType: 'bee' },
|
|
269
|
+
},
|
|
270
|
+
cat: {
|
|
271
|
+
mime: 'application/json',
|
|
272
|
+
value: { petType: 'cat' },
|
|
273
|
+
rawValue: { petType: 'cat' },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
mockUseAtom.mockReturnValue([
|
|
278
|
+
{
|
|
279
|
+
activeExampleName: 'bee',
|
|
280
|
+
activeOneOf: {},
|
|
281
|
+
requestValues: { body: null },
|
|
282
|
+
},
|
|
283
|
+
setOperation,
|
|
284
|
+
]);
|
|
285
|
+
mockUseTelemetry.mockReturnValue({
|
|
286
|
+
sendExamplesSwitcherClickedMessage: sendTelemetry,
|
|
287
|
+
});
|
|
288
|
+
mockUseActivateExample.mockReturnValue(setActivateExampleName);
|
|
289
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
290
|
+
render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
291
|
+
const selector = screen.getByTestId('example-selector');
|
|
292
|
+
await user.selectOptions(selector, 'cat');
|
|
293
|
+
await waitFor(() => {
|
|
294
|
+
expect(setOperation).toHaveBeenCalledWith(expect.objectContaining({
|
|
295
|
+
activeExampleName: 'cat',
|
|
296
|
+
activeOneOf: { [examplesPointer]: 1 },
|
|
297
|
+
requestValues: { body: null },
|
|
298
|
+
}));
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
it('should use operation pointer in handleExampleChange when examplesPointer does not start with operation pointer', async () => {
|
|
302
|
+
const user = userEvent.setup();
|
|
303
|
+
const setOperation = vi.fn();
|
|
304
|
+
const setActivateExampleName = vi.fn();
|
|
305
|
+
const sendTelemetry = vi.fn();
|
|
306
|
+
const operationPointer = '/paths/~1pet/post';
|
|
307
|
+
const examplesPointer = '/different/pointer';
|
|
308
|
+
const multipleExamplesMediaType = {
|
|
309
|
+
...mockMediaType,
|
|
310
|
+
operation: {
|
|
311
|
+
...mockMediaType.operation,
|
|
312
|
+
pointer: operationPointer,
|
|
313
|
+
},
|
|
314
|
+
examplesPointer,
|
|
315
|
+
examples: {
|
|
316
|
+
bee: {
|
|
317
|
+
mime: 'application/json',
|
|
318
|
+
value: { petType: 'bee' },
|
|
319
|
+
rawValue: { petType: 'bee' },
|
|
320
|
+
},
|
|
321
|
+
cat: {
|
|
322
|
+
mime: 'application/json',
|
|
323
|
+
value: { petType: 'cat' },
|
|
324
|
+
rawValue: { petType: 'cat' },
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
mockUseAtom.mockReturnValue([
|
|
329
|
+
{
|
|
330
|
+
activeExampleName: 'bee',
|
|
331
|
+
activeOneOf: {},
|
|
332
|
+
requestValues: { body: null },
|
|
333
|
+
},
|
|
334
|
+
setOperation,
|
|
335
|
+
]);
|
|
336
|
+
mockUseTelemetry.mockReturnValue({
|
|
337
|
+
sendExamplesSwitcherClickedMessage: sendTelemetry,
|
|
338
|
+
});
|
|
339
|
+
mockUseActivateExample.mockReturnValue(setActivateExampleName);
|
|
340
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
341
|
+
render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
342
|
+
const selector = screen.getByTestId('example-selector');
|
|
343
|
+
await user.selectOptions(selector, 'cat');
|
|
344
|
+
await waitFor(() => {
|
|
345
|
+
// Should use operation pointer instead of examplesPointer
|
|
346
|
+
expect(setOperation).toHaveBeenCalledWith(expect.objectContaining({
|
|
347
|
+
activeExampleName: 'cat',
|
|
348
|
+
activeOneOf: { [operationPointer]: 1 },
|
|
349
|
+
requestValues: { body: null },
|
|
350
|
+
}));
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
it('should fallback to activeExampleKey from useExampleKey when activeOneOf is empty', () => {
|
|
354
|
+
mockUseExampleKey.mockReturnValue({ exampleKey: 'cat' });
|
|
355
|
+
const multipleExamplesMediaType = {
|
|
356
|
+
...mockMediaType,
|
|
357
|
+
examples: {
|
|
358
|
+
bee: {
|
|
359
|
+
mime: 'application/json',
|
|
360
|
+
value: { petType: 'bee' },
|
|
361
|
+
rawValue: { petType: 'bee' },
|
|
362
|
+
},
|
|
363
|
+
cat: {
|
|
364
|
+
mime: 'application/json',
|
|
365
|
+
value: { petType: 'cat' },
|
|
366
|
+
rawValue: { petType: 'cat' },
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
mockUseAtom.mockReturnValue([
|
|
371
|
+
{
|
|
372
|
+
activeExampleName: undefined,
|
|
373
|
+
activeOneOf: {},
|
|
374
|
+
requestValues: { body: null },
|
|
375
|
+
},
|
|
376
|
+
vi.fn(),
|
|
377
|
+
]);
|
|
378
|
+
const renderSample = vi.fn(() => _jsx("div", { "data-testid": "sample", children: "Sample" }));
|
|
379
|
+
render(withTestProviders(_jsx(Example, { mediaType: multipleExamplesMediaType, mediaContent: mockMediaContent, renderSample: renderSample })));
|
|
380
|
+
// Should use 'cat' from useExampleKey
|
|
381
|
+
expect(renderSample).toHaveBeenCalledWith('cat');
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
//# sourceMappingURL=Example.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|