@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.
Files changed (260) hide show
  1. package/lib/telemetry/RedocTelemetry.js +1 -31
  2. package/package.json +4 -4
  3. package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +0 -1
  4. package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +0 -46
  5. package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +0 -1
  6. package/lib/components/Callbacks/__tests__/Callbacks.test.js +0 -46
  7. package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +0 -1
  8. package/lib/components/Content/__tests__/useAutoScroll.test.js +0 -88
  9. package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +0 -1
  10. package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +0 -123
  11. package/lib/components/ContentItems/__tests__/Items.test.d.ts +0 -1
  12. package/lib/components/ContentItems/__tests__/Items.test.js +0 -66
  13. package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +0 -1
  14. package/lib/components/ContentItems/__tests__/VirtualList.test.js +0 -135
  15. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +0 -1
  16. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +0 -63
  17. package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +0 -1
  18. package/lib/components/Download/__tests__/DownloadSpecification.test.js +0 -52
  19. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +0 -1
  20. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +0 -60
  21. package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +0 -1
  22. package/lib/components/ExpandAllButton/__tests__/helpers.test.js +0 -133
  23. package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +0 -1
  24. package/lib/components/Language/__tests__/LanguageDropdown.test.js +0 -23
  25. package/lib/components/Markdown/__tests__/Markdown.test.d.ts +0 -1
  26. package/lib/components/Markdown/__tests__/Markdown.test.js +0 -34
  27. package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +0 -1
  28. package/lib/components/McpOverview/__tests__/McpOverview.test.js +0 -66
  29. package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +0 -1
  30. package/lib/components/McpTool/__tests__/McpPrompt.test.js +0 -57
  31. package/lib/components/McpTool/__tests__/McpResource.test.d.ts +0 -1
  32. package/lib/components/McpTool/__tests__/McpResource.test.js +0 -81
  33. package/lib/components/McpTool/__tests__/McpTool.test.d.ts +0 -1
  34. package/lib/components/McpTool/__tests__/McpTool.test.js +0 -82
  35. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +0 -1
  36. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +0 -79
  37. package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +0 -1
  38. package/lib/components/OperationItem/__tests__/OperationItem.test.js +0 -70
  39. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +0 -16
  40. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +0 -42
  41. package/lib/components/Overview/__tests__/Overview.test.d.ts +0 -1
  42. package/lib/components/Overview/__tests__/Overview.test.js +0 -59
  43. package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +0 -1
  44. package/lib/components/PayloadSamples/__tests__/Example.test.js +0 -36
  45. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +0 -1
  46. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +0 -197
  47. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +0 -1
  48. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +0 -38
  49. package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +0 -1
  50. package/lib/components/PropertyDetails/__tests__/Extensions.test.js +0 -21
  51. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +0 -1
  52. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +0 -52
  53. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +0 -1
  54. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +0 -191
  55. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +0 -1
  56. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +0 -365
  57. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +0 -1
  58. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +0 -23
  59. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +0 -1
  60. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +0 -16
  61. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +0 -1
  62. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +0 -104
  63. package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +0 -1
  64. package/lib/components/RenderHook/__tests__/RenderHook.test.js +0 -15
  65. package/lib/components/Replay/__tests__/utils.test.d.ts +0 -1
  66. package/lib/components/Replay/__tests__/utils.test.js +0 -526
  67. package/lib/components/Request/__tests__/RequestDetails.test.d.ts +0 -1
  68. package/lib/components/Request/__tests__/RequestDetails.test.js +0 -98
  69. package/lib/components/RequestSamples/__tests__/Example.test.d.ts +0 -1
  70. package/lib/components/RequestSamples/__tests__/Example.test.js +0 -384
  71. package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +0 -1
  72. package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +0 -226
  73. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +0 -1
  74. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +0 -64
  75. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +0 -1
  76. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +0 -29
  77. package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +0 -1
  78. package/lib/components/Responses/__tests__/OperationResponseList.test.js +0 -89
  79. package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +0 -1
  80. package/lib/components/Responses/__tests__/ResponseDetails.test.js +0 -111
  81. package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +0 -1
  82. package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +0 -26
  83. package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +0 -1
  84. package/lib/components/Schema/__tests__/ArraySchema.test.js +0 -93
  85. package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +0 -1
  86. package/lib/components/Schema/__tests__/ObjectSchema.test.js +0 -115
  87. package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +0 -1
  88. package/lib/components/Schema/__tests__/OneOfSchema.test.js +0 -33
  89. package/lib/components/Schema/__tests__/Schema.test.d.ts +0 -1
  90. package/lib/components/Schema/__tests__/Schema.test.js +0 -67
  91. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +0 -1
  92. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +0 -22
  93. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +0 -1
  94. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +0 -95
  95. package/lib/components/Security/__tests__/Security.test.d.ts +0 -1
  96. package/lib/components/Security/__tests__/Security.test.js +0 -38
  97. package/lib/components/Security/__tests__/SecurityButton.test.d.ts +0 -1
  98. package/lib/components/Security/__tests__/SecurityButton.test.js +0 -92
  99. package/lib/components/Security/__tests__/SecurityModal.test.d.ts +0 -1
  100. package/lib/components/Security/__tests__/SecurityModal.test.js +0 -172
  101. package/lib/components/ServerList/__tests__/ServerList.test.d.ts +0 -1
  102. package/lib/components/ServerList/__tests__/ServerList.test.js +0 -83
  103. package/lib/components/Tabs/__tests__/Tabs.test.d.ts +0 -1
  104. package/lib/components/Tabs/__tests__/Tabs.test.js +0 -27
  105. package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +0 -1
  106. package/lib/components/ViewNested/__tests__/ViewNested.test.js +0 -42
  107. package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +0 -1
  108. package/lib/components/__tests__/Samples/ExampleSwitch.test.js +0 -45
  109. package/lib/components/__tests__/Samples/use-example-key.test.d.ts +0 -1
  110. package/lib/components/__tests__/Samples/use-example-key.test.js +0 -28
  111. package/lib/components/__tests__/common/ClearButton.test.d.ts +0 -1
  112. package/lib/components/__tests__/common/ClearButton.test.js +0 -18
  113. package/lib/components/__tests__/common/Dropdown.test.d.ts +0 -1
  114. package/lib/components/__tests__/common/Dropdown.test.js +0 -52
  115. package/lib/components/__tests__/mocks/examples.d.ts +0 -4
  116. package/lib/components/__tests__/mocks/examples.js +0 -115
  117. package/lib/components/common/__tests__/Dropdown.test.d.ts +0 -1
  118. package/lib/components/common/__tests__/Dropdown.test.js +0 -129
  119. package/lib/components/common/__tests__/LinkToField.test.d.ts +0 -1
  120. package/lib/components/common/__tests__/LinkToField.test.js +0 -39
  121. package/lib/jotai/__tests__/app.test.d.ts +0 -1
  122. package/lib/jotai/__tests__/app.test.js +0 -53
  123. package/lib/models/__tests__/Callback.test.d.ts +0 -1
  124. package/lib/models/__tests__/Callback.test.js +0 -15
  125. package/lib/models/__tests__/FieldModel.test.d.ts +0 -1
  126. package/lib/models/__tests__/FieldModel.test.js +0 -117
  127. package/lib/models/__tests__/MediaContent.test.d.ts +0 -1
  128. package/lib/models/__tests__/MediaContent.test.js +0 -105
  129. package/lib/models/__tests__/Operation.test.d.ts +0 -1
  130. package/lib/models/__tests__/Operation.test.js +0 -459
  131. package/lib/models/__tests__/Response.test.d.ts +0 -1
  132. package/lib/models/__tests__/Response.test.js +0 -221
  133. package/lib/models/__tests__/Schema.circular.test.d.ts +0 -1
  134. package/lib/models/__tests__/Schema.circular.test.js +0 -694
  135. package/lib/models/__tests__/Schema.test.d.ts +0 -1
  136. package/lib/models/__tests__/Schema.test.js +0 -1395
  137. package/lib/models/__tests__/example.test.d.ts +0 -1
  138. package/lib/models/__tests__/example.test.js +0 -90
  139. package/lib/models/__tests__/group.test.d.ts +0 -1
  140. package/lib/models/__tests__/group.test.js +0 -52
  141. package/lib/models/__tests__/helpers.d.ts +0 -5
  142. package/lib/models/__tests__/helpers.js +0 -62
  143. package/lib/models/__tests__/request.test.d.ts +0 -1
  144. package/lib/models/__tests__/request.test.js +0 -119
  145. package/lib/services/__tests__/OpenAPIParser.test.d.ts +0 -1
  146. package/lib/services/__tests__/OpenAPIParser.test.js +0 -80
  147. package/lib/services/__tests__/check.test.d.ts +0 -1
  148. package/lib/services/__tests__/check.test.js +0 -22
  149. package/lib/services/__tests__/utils.test.d.ts +0 -1
  150. package/lib/services/__tests__/utils.test.js +0 -42
  151. package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +0 -1
  152. package/lib/services/code-samples/__tests__/apply-environments.test.js +0 -64
  153. package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +0 -1
  154. package/lib/services/code-samples/__tests__/build-code-samples.test.js +0 -70
  155. package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +0 -1
  156. package/lib/services/code-samples/__tests__/convertSampleToString.test.js +0 -116
  157. package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +0 -1
  158. package/lib/services/code-samples/__tests__/generator-data-value.test.js +0 -277
  159. package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +0 -1
  160. package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +0 -258
  161. package/lib/services/code-samples/__tests__/generator-value.test.d.ts +0 -1
  162. package/lib/services/code-samples/__tests__/generator-value.test.js +0 -273
  163. package/lib/services/code-samples/__tests__/generator.test.d.ts +0 -249
  164. package/lib/services/code-samples/__tests__/generator.test.js +0 -1201
  165. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +0 -1
  166. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +0 -31
  167. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +0 -1
  168. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +0 -222
  169. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +0 -1
  170. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +0 -129
  171. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +0 -1
  172. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +0 -49
  173. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +0 -1
  174. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +0 -172
  175. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +0 -1
  176. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +0 -172
  177. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +0 -1
  178. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +0 -130
  179. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +0 -1
  180. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +0 -191
  181. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +0 -1
  182. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +0 -172
  183. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +0 -1
  184. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +0 -85
  185. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +0 -1
  186. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +0 -85
  187. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +0 -1
  188. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +0 -126
  189. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +0 -1
  190. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +0 -105
  191. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +0 -1
  192. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +0 -126
  193. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +0 -1
  194. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +0 -129
  195. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +0 -1
  196. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +0 -129
  197. package/lib/services/config-options/__tests__/helpers.test.d.ts +0 -1
  198. package/lib/services/config-options/__tests__/helpers.test.js +0 -234
  199. package/lib/services/history/__tests__/helpers.test.d.ts +0 -1
  200. package/lib/services/history/__tests__/helpers.test.js +0 -19
  201. package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +0 -1
  202. package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +0 -109
  203. package/lib/services/menu/__tests__/builder.test.d.ts +0 -1
  204. package/lib/services/menu/__tests__/builder.test.js +0 -307
  205. package/lib/services/menu/__tests__/operation.test.d.ts +0 -1
  206. package/lib/services/menu/__tests__/operation.test.js +0 -240
  207. package/lib/services/menu/__tests__/tags.test.d.ts +0 -1
  208. package/lib/services/menu/__tests__/tags.test.js +0 -71
  209. package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +0 -1
  210. package/lib/telemetry/__tests__/RedocTelemetry.test.js +0 -107
  211. package/lib/testProviders.d.ts +0 -6
  212. package/lib/testProviders.js +0 -14
  213. package/lib/utils/__tests__/areArraysEqual.test.d.ts +0 -1
  214. package/lib/utils/__tests__/areArraysEqual.test.js +0 -33
  215. package/lib/utils/__tests__/argValuesHelpers.d.ts +0 -1
  216. package/lib/utils/__tests__/argValuesHelpers.js +0 -56
  217. package/lib/utils/__tests__/calculateMaxLength.test.d.ts +0 -1
  218. package/lib/utils/__tests__/calculateMaxLength.test.js +0 -119
  219. package/lib/utils/__tests__/configure-helpers.test.d.ts +0 -1
  220. package/lib/utils/__tests__/configure-helpers.test.js +0 -356
  221. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +0 -1
  222. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +0 -392
  223. package/lib/utils/__tests__/debounce.test.d.ts +0 -1
  224. package/lib/utils/__tests__/debounce.test.js +0 -54
  225. package/lib/utils/__tests__/debug.test.d.ts +0 -1
  226. package/lib/utils/__tests__/debug.test.js +0 -23
  227. package/lib/utils/__tests__/dom.test.d.ts +0 -1
  228. package/lib/utils/__tests__/dom.test.js +0 -108
  229. package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +0 -1
  230. package/lib/utils/__tests__/getBreadcrumbs.test.js +0 -98
  231. package/lib/utils/__tests__/hasNestedFields.test.d.ts +0 -1
  232. package/lib/utils/__tests__/hasNestedFields.test.js +0 -147
  233. package/lib/utils/__tests__/helpers.test.d.ts +0 -1
  234. package/lib/utils/__tests__/helpers.test.js +0 -174
  235. package/lib/utils/__tests__/isMobile.test.d.ts +0 -1
  236. package/lib/utils/__tests__/isMobile.test.js +0 -28
  237. package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +0 -1
  238. package/lib/utils/__tests__/loadAndBundleSpec.test.js +0 -22
  239. package/lib/utils/__tests__/local-storage.test.d.ts +0 -1
  240. package/lib/utils/__tests__/local-storage.test.js +0 -48
  241. package/lib/utils/__tests__/object.test.d.ts +0 -1
  242. package/lib/utils/__tests__/object.test.js +0 -45
  243. package/lib/utils/__tests__/openapi.test.d.ts +0 -1
  244. package/lib/utils/__tests__/openapi.test.js +0 -1378
  245. package/lib/utils/__tests__/path.test.d.ts +0 -1
  246. package/lib/utils/__tests__/path.test.js +0 -16
  247. package/lib/utils/__tests__/queryString.test.d.ts +0 -1
  248. package/lib/utils/__tests__/queryString.test.js +0 -60
  249. package/lib/utils/__tests__/replaceVariables.test.d.ts +0 -1
  250. package/lib/utils/__tests__/replaceVariables.test.js +0 -46
  251. package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +0 -1
  252. package/lib/utils/__tests__/simplifyAstStructure.test.js +0 -26
  253. package/lib/utils/__tests__/sort.test.d.ts +0 -1
  254. package/lib/utils/__tests__/sort.test.js +0 -16
  255. package/lib/utils/__tests__/string.test.d.ts +0 -1
  256. package/lib/utils/__tests__/string.test.js +0 -16
  257. package/lib/utils/__tests__/theme-helpers.test.d.ts +0 -1
  258. package/lib/utils/__tests__/theme-helpers.test.js +0 -24
  259. package/lib/utils/__tests__/url.test.d.ts +0 -1
  260. package/lib/utils/__tests__/url.test.js +0 -134
@@ -1,115 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import * as Jotai from 'jotai';
4
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
5
- import { getSchema } from '../../../models/index.js';
6
- import schemasExpansionLevel from './fixtures/schemaExpansionLevel.json';
7
- import requiredField from './fixtures/requiredField.json';
8
- import { Schema } from '../Schema.js';
9
- import { TestBrowserRouter } from '../../../testProviders.js';
10
- const options = normalizeOptions({});
11
- vi.mock('jotai', async () => ({
12
- ...(await vi.importActual('jotai')),
13
- useAtomValue: vi.fn(),
14
- }));
15
- describe('ObjectSchema', () => {
16
- it("should render Schema when schemasExpansionLevel is 'all'", async () => {
17
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({ schemasExpansionLevel: 'all' }));
18
- const parser = new OpenAPIParser(schemasExpansionLevel, undefined, options);
19
- const schema = getSchema({
20
- parser,
21
- schemaOrRef: schemasExpansionLevel.components.schemas.Pet,
22
- pointer: '',
23
- options,
24
- deps: {
25
- operation: {
26
- pointer: 'schemasExpansionLevel',
27
- },
28
- },
29
- });
30
- const { getByText } = render(_jsx(Schema, { schema: schema }), {
31
- wrapper: TestBrowserRouter,
32
- });
33
- expect(getByText('Dumb Property 6')).toBeInTheDocument();
34
- });
35
- it("should render Schema when schemasExpansionLevel is '3'", async () => {
36
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({ schemasExpansionLevel: '3' }));
37
- const parser = new OpenAPIParser(schemasExpansionLevel, undefined, options);
38
- const schema = getSchema({
39
- parser,
40
- schemaOrRef: schemasExpansionLevel.components.schemas.Pet,
41
- pointer: '',
42
- options,
43
- deps: {
44
- operation: {
45
- pointer: 'schemasExpansionLevel',
46
- },
47
- },
48
- });
49
- const { getByText, queryByText } = render(_jsx(Schema, { schema: schema }), {
50
- wrapper: TestBrowserRouter,
51
- });
52
- expect(getByText('Dumb Property 3')).toBeInTheDocument();
53
- expect(queryByText('Dumb Property 4')).toBeNull();
54
- });
55
- it("should not render inner Schema when schemasExpansionLevel is '0'", async () => {
56
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({ schemasExpansionLevel: '0' }));
57
- const parser = new OpenAPIParser(schemasExpansionLevel, undefined, options);
58
- const schema = getSchema({
59
- parser,
60
- schemaOrRef: schemasExpansionLevel.components.schemas.Pet,
61
- pointer: '',
62
- options,
63
- deps: {
64
- operation: {
65
- pointer: 'schemasExpansionLevel',
66
- },
67
- },
68
- });
69
- const { queryByText } = render(_jsx(Schema, { schema: schema }), {
70
- wrapper: TestBrowserRouter,
71
- });
72
- expect(queryByText('Test Sub Category')).toBeNull();
73
- });
74
- it("should render Schema when required is 'category' -> 'sub'", async () => {
75
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({}));
76
- const parser = new OpenAPIParser(requiredField, undefined, options);
77
- const schema = getSchema({
78
- parser,
79
- schemaOrRef: requiredField.components.schemas.Pet,
80
- pointer: '',
81
- options,
82
- deps: {
83
- operation: {
84
- pointer: 'schemasExpansionLevel',
85
- },
86
- },
87
- });
88
- const { getByText, queryByText } = render(_jsx(Schema, { schema: schema }), {
89
- wrapper: TestBrowserRouter,
90
- });
91
- expect(getByText('Dumb Property 2')).toBeInTheDocument();
92
- expect(queryByText('Dumb Property 3')).toBeNull();
93
- });
94
- it("should render Schema when required is 'tags' -> 'sub' at Array schema", async () => {
95
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({}));
96
- const parser = new OpenAPIParser(requiredField, undefined, options);
97
- const schema = getSchema({
98
- parser,
99
- schemaOrRef: requiredField.components.schemas.User,
100
- pointer: '',
101
- options,
102
- deps: {
103
- operation: {
104
- pointer: 'schemasExpansionLevel',
105
- },
106
- },
107
- });
108
- const { getByText, queryByText } = render(_jsx(Schema, { schema: schema }), {
109
- wrapper: TestBrowserRouter,
110
- });
111
- expect(getByText('Dumb Property 1')).toBeInTheDocument();
112
- expect(queryByText('Dumb Property 2')).toBeNull();
113
- });
114
- });
115
- //# sourceMappingURL=ObjectSchema.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
4
- import { getSchema } from '../../../models/index.js';
5
- import oneOfWithDiscriminator from './fixtures/oneOfWithDiscriminator.json';
6
- import { Schema } from '../Schema.js';
7
- import { TestBrowserRouter } from '../../../testProviders.js';
8
- const options = normalizeOptions({});
9
- describe('OneOfSchema', () => {
10
- it('should render correct oneOf and discriminator based on deep link', () => {
11
- const parser = new OpenAPIParser(oneOfWithDiscriminator, undefined, options);
12
- const schema = getSchema({
13
- parser,
14
- schemaOrRef: { $ref: '#/components/schemas/OneOfSchema' },
15
- pointer: '',
16
- options,
17
- deps: {
18
- operation: {
19
- pointer: '/paths/schema',
20
- },
21
- },
22
- absolutePointer: '/paths/schema',
23
- });
24
- history.pushState({}, '', 'user/createuser#user/createuser/t=request&path=pet&oneof=1&d=1&oneof=0');
25
- const { getByText } = render(_jsx(Schema, { schema: schema }), {
26
- wrapper: TestBrowserRouter,
27
- });
28
- expect(getByText('Type of the shape - Shape')).toBeInTheDocument();
29
- expect(getByText('Whether or not the triangle is equilateral')).toBeInTheDocument();
30
- expect(getByText('Perimeter of the Equilateral')).toBeInTheDocument();
31
- });
32
- });
33
- //# sourceMappingURL=OneOfSchema.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { act, fireEvent, render } from '@testing-library/react';
3
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
4
- import { getSchema } from '../../../models/index.js';
5
- import oneOfWithDiscriminator from './fixtures/oneOfWithDiscriminator.json';
6
- import singleOneOf from './fixtures/singleOneOf.json';
7
- import { Schema } from '../Schema.js';
8
- import { TestBrowserRouter } from '../../../testProviders.js';
9
- const options = normalizeOptions({});
10
- describe('SchemaView', () => {
11
- describe('OneOf', () => {
12
- it('should render oneOf with a single item and display its schema fields', () => {
13
- const parser = new OpenAPIParser(singleOneOf, undefined, options);
14
- const schema = getSchema({
15
- parser,
16
- schemaOrRef: singleOneOf.paths['/example'].get.responses['200'].content['application/json'].schema,
17
- pointer: '',
18
- options,
19
- deps: {
20
- operation: {
21
- pointer: '/paths/example',
22
- },
23
- },
24
- absolutePointer: '/paths/example',
25
- });
26
- const { getByText } = render(_jsx(Schema, { schema: schema }), {
27
- wrapper: TestBrowserRouter,
28
- });
29
- expect(getByText('One of:')).toBeInTheDocument();
30
- expect(getByText('UserResponse')).toBeInTheDocument();
31
- expect(getByText('type')).toBeInTheDocument();
32
- expect(getByText('data')).toBeInTheDocument();
33
- });
34
- it('should render oneOf with a discriminator without affecting each other', () => {
35
- const parser = new OpenAPIParser(oneOfWithDiscriminator, undefined, options);
36
- const schema = getSchema({
37
- parser,
38
- schemaOrRef: { $ref: '#/components/schemas/OneOfSchema' },
39
- pointer: '',
40
- options,
41
- deps: {
42
- operation: {
43
- pointer: '/paths/schema',
44
- },
45
- },
46
- absolutePointer: '/paths/schema',
47
- });
48
- const { getByText } = render(_jsx(Schema, { schema: schema }), {
49
- wrapper: TestBrowserRouter,
50
- });
51
- expect(getByText('Shape')).toBeInTheDocument();
52
- act(() => {
53
- fireEvent.click(getByText('Shape'));
54
- });
55
- expect(getByText('Discriminator')).toBeInTheDocument();
56
- expect(getByText('square')).toBeInTheDocument();
57
- expect(getByText('triangle')).toBeInTheDocument();
58
- expect(getByText('sideLength')).toBeInTheDocument();
59
- act(() => {
60
- fireEvent.click(getByText('triangle'));
61
- });
62
- expect(getByText('equilateral')).toBeInTheDocument();
63
- expect(getByText('Whether or not the triangle is equilateral')).toBeInTheDocument();
64
- });
65
- });
66
- });
67
- //# sourceMappingURL=Schema.test.js.map
@@ -1,22 +0,0 @@
1
- import { renderHook } from '@testing-library/react';
2
- import { useOneOfLocationIdx } from '../useOneOfLocationIdx.js';
3
- vi.mock('react-router', () => ({
4
- useLocation: vi.fn().mockReturnValue({
5
- hash: '#plans/postplan/t=request&path=&oneof=1/trial&oneof=0/period',
6
- }),
7
- }));
8
- describe('useOneOfLocationIdx', () => {
9
- it('should return the index of the oneOf item in the hash', () => {
10
- const oneOf = [{}, {}, {}];
11
- const level = 1;
12
- const { result } = renderHook(() => useOneOfLocationIdx(oneOf, level));
13
- expect(result.current).toBe(1);
14
- });
15
- it('should return -1 if the oneOf item is not found in the hash', () => {
16
- const oneOf = [{}, {}, {}];
17
- const level = 3;
18
- const { result } = renderHook(() => useOneOfLocationIdx(oneOf, level));
19
- expect(result.current).toBe(-1);
20
- });
21
- });
22
- //# sourceMappingURL=useOneOfLocationIdx.test.js.map
@@ -1,95 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render, fireEvent } from '@testing-library/react';
3
- import * as Jotai from 'jotai';
4
- import { ClipboardService } from '@redocly/theme/core/openapi';
5
- import { SchemaCatalogLink } from '../SchemaCatalogLink.js';
6
- vi.mock('jotai', async () => ({
7
- ...(await vi.importActual('jotai')),
8
- useAtomValue: vi.fn(),
9
- }));
10
- vi.mock('../../../utils/dom', async () => ({
11
- ...(await vi.importActual('../../../utils/dom')),
12
- IS_BROWSER: true,
13
- }));
14
- vi.mock('@redocly/theme/core/openapi', async () => {
15
- const actual = await vi.importActual('@redocly/theme/core/openapi');
16
- const actualClipboard = actual.ClipboardService;
17
- return {
18
- ...actual,
19
- ClipboardService: {
20
- ...actualClipboard,
21
- copyCustom: vi.fn(),
22
- },
23
- };
24
- });
25
- describe('SchemaCatalogLink', () => {
26
- beforeEach(() => {
27
- vi.clearAllMocks();
28
- vi.useFakeTimers();
29
- Object.defineProperty(global, 'navigator', {
30
- value: {
31
- clipboard: {
32
- writeText: vi.fn(),
33
- },
34
- },
35
- writable: true,
36
- });
37
- });
38
- afterEach(() => {
39
- vi.useRealTimers();
40
- });
41
- it('should render correctly', () => {
42
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue({
43
- parser: {
44
- definition: {
45
- 'x-schema-catalog-link': '/_bundle/test.yaml',
46
- },
47
- },
48
- });
49
- const result = render(_jsx(SchemaCatalogLink, { schemaRef: "#/components/schemas/test" }));
50
- expect(result.baseElement).toMatchSnapshot();
51
- });
52
- it('should not render if x-schema-catalog-link is not defined', () => {
53
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue({
54
- parser: {
55
- definition: {},
56
- },
57
- });
58
- const result = render(_jsx(SchemaCatalogLink, { schemaRef: "#/components/schemas/test" }));
59
- expect(result.baseElement).toMatchSnapshot();
60
- });
61
- it('should render correctly on server', async () => {
62
- vi.doMock('../../../utils/dom', async () => ({
63
- ...(await vi.importActual('../../../utils/dom')),
64
- IS_BROWSER: vi.fn().mockReturnValue(false),
65
- }));
66
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue({
67
- parser: {
68
- definition: {
69
- 'x-schema-catalog-link': '/_bundle/test.yaml',
70
- },
71
- },
72
- });
73
- const result = render(_jsx(SchemaCatalogLink, { schemaRef: "#/components/schemas/test" }));
74
- expect(result.baseElement).toMatchSnapshot();
75
- });
76
- it('should copy link to clipboard when copy button is clicked', async () => {
77
- vi.doMock('../../../utils/dom', async () => ({
78
- ...(await vi.importActual('../../../utils/dom')),
79
- IS_BROWSER: vi.fn().mockReturnValue(true),
80
- }));
81
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue({
82
- parser: {
83
- definition: {
84
- 'x-schema-catalog-link': '/_bundle/test.yaml',
85
- },
86
- },
87
- });
88
- const result = render(_jsx(SchemaCatalogLink, { schemaRef: "#/components/schemas/test" }));
89
- // Find the copy button by role
90
- const copyButton = result.getByRole('button');
91
- fireEvent.click(copyButton);
92
- expect(ClipboardService.copyCustom).toHaveBeenCalled();
93
- });
94
- });
95
- //# sourceMappingURL=SchemaCatalogLink.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,38 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { act, fireEvent, render } from '@testing-library/react';
3
- import { Security } from '../Security.js';
4
- vi.mock('jotai', async () => ({
5
- ...(await vi.importActual('jotai')),
6
- useAtomValue: vi.fn(() => ({ options: { hideSecuritySection: false } })),
7
- }));
8
- vi.mock('../SecurityModal', async () => ({
9
- SecurityModal: vi.fn(() => _jsx("div", { children: "Mocked SecurityModal" })),
10
- }));
11
- describe('Security Component', () => {
12
- it('should not renders SecurityButton initially when securities is empty', () => {
13
- const { queryByText } = render(_jsx(Security, { securities: [] }));
14
- expect(queryByText('Security')).not.toBeInTheDocument();
15
- });
16
- it('renders SecurityModal when SecurityButton is clicked', async () => {
17
- const securities = [
18
- {
19
- schemes: [
20
- {
21
- description: 'For this sample, you can use the api key `special-key` to test the authorization filters.\n',
22
- type: 'apiKey',
23
- name: 'api_key',
24
- in: 'header',
25
- id: 'api_key',
26
- sectionId: 'api_key',
27
- scopes: ['write:pets', 'read:pets'],
28
- },
29
- ],
30
- },
31
- ];
32
- const { getByRole, getByText } = render(_jsx(Security, { securities: securities }));
33
- fireEvent.click(getByRole('button', { name: 'View details' }));
34
- await act(async () => { });
35
- expect(getByText('Mocked SecurityModal')).toBeInTheDocument();
36
- });
37
- });
38
- //# sourceMappingURL=Security.test.js.map
@@ -1,92 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { fireEvent, render } from '@testing-library/react';
3
- import { SecurityButton } from '../SecurityButton.js';
4
- describe('SecurityButton Component', () => {
5
- const securities = [
6
- { schemes: [{ id: 'scheme1' }] },
7
- { schemes: [{ id: 'scheme2' }, { id: 'scheme3' }] },
8
- ];
9
- it('should render the button with `View details` text', () => {
10
- const { getByRole } = render(_jsx(SecurityButton, { securities: [securities[0]], onClick: () => { } }));
11
- expect(getByRole('button', { name: 'View details' })).toBeInTheDocument();
12
- });
13
- it('should render the panel with correct text for a single security scheme', () => {
14
- const { getByTestId } = render(_jsx(SecurityButton, { securities: [securities[0]], onClick: () => { } }));
15
- expect(getByTestId('panel-body')).toHaveTextContent('scheme1');
16
- });
17
- it('should render the panel with correct text for multiple Authentication Types', () => {
18
- const schemas = [
19
- [{ schemes: [{ id: 'A' }] }, { schemes: [{ id: 'B' }] }], // Should render "A or B"
20
- [{ schemes: [{ id: 'A' }, { id: 'B' }] }], // Should render "A and B"
21
- [{ schemes: [{ id: 'A' }, { id: 'B' }] }, { schemes: [{ id: 'C' }, { id: 'D' }] }], // Should render "(A and B) or (C and D)"
22
- ];
23
- const { getAllByTestId } = render(_jsxs(_Fragment, { children: [_jsx(SecurityButton, { securities: schemas[0], onClick: () => { } }), _jsx(SecurityButton, { securities: schemas[1], onClick: () => { } }), _jsx(SecurityButton, { securities: schemas[2], onClick: () => { } })] }));
24
- const panelBodies = getAllByTestId('panel-body');
25
- expect(panelBodies[0]).toHaveTextContent('A or B');
26
- expect(panelBodies[1]).toHaveTextContent('A and B');
27
- expect(panelBodies[2]).toHaveTextContent('(A and B) or (C and D)');
28
- });
29
- it('shows required scopes for oauth2 schemes (truncated with +N)', () => {
30
- const securities = [
31
- {
32
- schemes: [
33
- {
34
- id: 'OAuth2',
35
- type: 'oauth2',
36
- scopes: ['read:users', 'write:users', 'admin:users', 'delete:users', 'sudo:users'],
37
- },
38
- ],
39
- },
40
- ];
41
- const { getByTestId } = render(_jsx(SecurityButton, { securities: securities, onClick: () => { } }));
42
- const body = getByTestId('panel-body');
43
- expect(body).toHaveTextContent('OAuth2');
44
- expect(body).toHaveTextContent('Required scopes');
45
- expect(body).toHaveTextContent('read:users');
46
- expect(body).toHaveTextContent('write:users');
47
- expect(body).toHaveTextContent('admin:users');
48
- expect(body).toHaveTextContent('delete:users');
49
- expect(body).toHaveTextContent('+1');
50
- });
51
- it('allows focusing the +N scope tag with keyboard', () => {
52
- const securities = [
53
- {
54
- schemes: [
55
- {
56
- id: 'OAuth2',
57
- type: 'oauth2',
58
- scopes: ['read:users', 'write:users', 'admin:users', 'delete:users', 'sudo:users'],
59
- },
60
- ],
61
- },
62
- ];
63
- const { getByText } = render(_jsx(SecurityButton, { securities: securities, onClick: () => { } }));
64
- const plusOne = getByText('+1');
65
- const focusable = plusOne.closest('[role="button"]');
66
- expect(focusable).not.toBeNull();
67
- expect(focusable).toHaveAttribute('tabindex', '0');
68
- });
69
- it('show truncated scope names for oauth2 schemes', () => {
70
- const securities = [
71
- {
72
- schemes: [
73
- {
74
- id: 'OAuth2',
75
- type: 'oauth2',
76
- scopes: ['scope:verylongscopenameforoauthsecurityscheme'],
77
- },
78
- ],
79
- },
80
- ];
81
- const { getByTestId } = render(_jsx(SecurityButton, { securities: securities, onClick: () => { } }));
82
- const body = getByTestId('panel-body');
83
- expect(body).toHaveTextContent('scope:verylongscopenameforoauths..');
84
- });
85
- it('calls the onClick callback when the button is clicked', () => {
86
- const onClickMock = vi.fn();
87
- const { getByRole } = render(_jsx(SecurityButton, { securities: securities, onClick: onClickMock }));
88
- fireEvent.click(getByRole('button', { name: 'View details' }));
89
- expect(onClickMock).toHaveBeenCalled();
90
- });
91
- });
92
- //# sourceMappingURL=SecurityButton.test.js.map
@@ -1,172 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render, fireEvent, act } from '@testing-library/react';
3
- import { SecurityModal } from '../SecurityModal.js';
4
- describe('SecurityModal Component', () => {
5
- const securities = [
6
- {
7
- schemes: [
8
- {
9
- id: 'B',
10
- description: 'Test description scheme B',
11
- type: 'http',
12
- bearerFormat: 'password',
13
- scopes: [],
14
- },
15
- {
16
- id: 'C',
17
- description: 'Test description scheme C',
18
- type: 'http',
19
- bearerFormat: 'password',
20
- scopes: [],
21
- },
22
- ],
23
- },
24
- {
25
- schemes: [
26
- {
27
- id: 'A',
28
- description: 'Test description scheme A',
29
- type: 'apiKey',
30
- in: 'header',
31
- name: 'api_key',
32
- scopes: [],
33
- },
34
- ],
35
- },
36
- {
37
- schemes: [
38
- {
39
- id: 'D',
40
- description: 'Test description scheme D',
41
- type: 'oauth2',
42
- flows: {
43
- authorizationCode: {
44
- authorizationUrl: 'https://example.com/authorization',
45
- tokenUrl: 'https://example.com/token',
46
- scopes: {
47
- 'read:pets': 'read your pets',
48
- 'write:pets': 'modify pets in your account',
49
- },
50
- },
51
- },
52
- scopes: ['read:pets'],
53
- },
54
- ],
55
- },
56
- ];
57
- it('renders the SecurityModal with the correct number of SegmentedItems', () => {
58
- const { getByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
59
- expect(getByText('A')).toBeInTheDocument();
60
- expect(getByText('B and C')).toBeInTheDocument();
61
- });
62
- it('renders the SecurityModal with the correct number of SecurityFlows and Dividers', () => {
63
- const { getByText, getAllByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
64
- expect(getByText('Test description scheme B')).toBeInTheDocument();
65
- expect(getByText('Test description scheme C')).toBeInTheDocument();
66
- expect(getByText('and')).toBeInTheDocument();
67
- expect(getAllByText('HTTP Authorization Scheme').length).toEqual(2);
68
- expect(getAllByText('http').length).toEqual(2);
69
- });
70
- it('should update active security scheme on click and display relevant information', async () => {
71
- const { getByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
72
- fireEvent.click(getByText('A'));
73
- await act(async () => { });
74
- expect(getByText('Test description scheme A')).toBeInTheDocument();
75
- expect(getByText('Header parameter name:')).toBeInTheDocument();
76
- expect(getByText('api_key')).toBeInTheDocument();
77
- });
78
- it('should display details for OAuth2 scheme D including initial optional scopes toggle', async () => {
79
- const { getByText, getAllByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
80
- fireEvent.click(getByText('D'));
81
- await act(async () => { });
82
- expect(getByText('Test description scheme D')).toBeInTheDocument();
83
- expect(getByText('Required scopes')).toBeInTheDocument();
84
- expect(getByText('Show optional scopes')).toBeInTheDocument();
85
- const readPetsScopes = getAllByText('read:pets');
86
- expect(readPetsScopes.length).toBe(1);
87
- const writePetsScopes = getAllByText('write:pets');
88
- expect(writePetsScopes.length).toBe(1);
89
- });
90
- it('should toggle optional scopes visibility for OAuth2 scheme D', async () => {
91
- const { getByText, queryByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
92
- fireEvent.click(getByText('D'));
93
- await act(async () => { });
94
- fireEvent.click(getByText('Show optional scopes'));
95
- await act(async () => { });
96
- expect(getByText('Hide optional scopes')).toBeInTheDocument();
97
- expect(queryByText('Show optional scopes')).toBeNull();
98
- });
99
- it('calls onClose callback when the Close button is clicked', () => {
100
- const onCloseMock = vi.fn();
101
- const { getByTestId } = render(_jsx(SecurityModal, { securities: securities, onClose: onCloseMock }));
102
- fireEvent.click(getByTestId('close'));
103
- expect(onCloseMock).toHaveBeenCalled();
104
- });
105
- it('should display required scopes from scopes array if there are no flows', () => {
106
- const securities = [
107
- {
108
- schemes: [
109
- {
110
- id: 'D',
111
- description: 'Test description scheme D',
112
- type: 'oauth2',
113
- flows: {},
114
- scopes: ['read:pets'],
115
- },
116
- ],
117
- },
118
- ];
119
- const { getByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
120
- expect(getByText('read:pets')).toBeInTheDocument();
121
- });
122
- it('should exlcude required scopes from optional scopes', async () => {
123
- const { getByText, getAllByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
124
- fireEvent.click(getByText('D'));
125
- await act(async () => { });
126
- fireEvent.click(getByText('Show optional scopes'));
127
- await act(async () => { });
128
- expect(getAllByText('read:pets').length).toBe(1);
129
- expect(getAllByText('write:pets').length).toBe(1);
130
- });
131
- it('should render required scopes once per scheme and optional scopes per flow when there are multiple flows', async () => {
132
- const securities = [
133
- {
134
- schemes: [
135
- {
136
- id: 'D',
137
- description: 'Test description scheme D',
138
- type: 'oauth2',
139
- flows: {
140
- authorizationCode: {
141
- authorizationUrl: 'https://example.com/authorization',
142
- tokenUrl: 'https://example.com/token',
143
- scopes: {
144
- 'read:pets': 'read your pets',
145
- 'write:pets': 'modify pets in your account',
146
- },
147
- },
148
- clientCredentials: {
149
- tokenUrl: 'https://example.com/token',
150
- scopes: {
151
- 'read:pets': 'read your pets',
152
- 'write:pets': 'modify pets in your account',
153
- },
154
- },
155
- },
156
- scopes: ['read:pets'],
157
- },
158
- ],
159
- },
160
- ];
161
- const { getByText, getAllByText } = render(_jsx(SecurityModal, { securities: securities, onClose: () => { } }));
162
- // Required is per scheme
163
- expect(getAllByText('Required scopes').length).toBe(1);
164
- expect(getAllByText('read:pets').length).toBe(1);
165
- // Each flow gets its own optional scopes block
166
- expect(getByText('authorizationCode')).toBeInTheDocument();
167
- expect(getByText('clientCredentials')).toBeInTheDocument();
168
- expect(getAllByText('Show optional scopes').length).toBe(2);
169
- expect(getAllByText('write:pets').length).toBe(2);
170
- });
171
- });
172
- //# sourceMappingURL=SecurityModal.test.js.map