@api-client/ui 0.5.39 → 0.5.40

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 (281) hide show
  1. package/build/tsconfig.tsbuildinfo +1 -0
  2. package/package.json +1 -1
  3. package/.aiexclude +0 -3
  4. package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
  5. package/.cursor/rules/lit-best-practices.mdc +0 -89
  6. package/.editorconfig +0 -29
  7. package/.github/CONTRIBUTING.md +0 -24
  8. package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
  9. package/.github/instructions/lit-best-practices.instructions.md +0 -90
  10. package/.github/release.yml +0 -14
  11. package/.github/stale.yml +0 -23
  12. package/.github/workflows/auto-release.yml +0 -182
  13. package/.github/workflows/release.yml +0 -82
  14. package/.prettierrc.js +0 -14
  15. package/.vscode/settings.json +0 -18
  16. package/RELEASE.md +0 -163
  17. package/RELEASE_SETUP.md +0 -235
  18. package/build/src/demo/DemoPage.d.ts +0 -81
  19. package/build/src/demo/DemoPage.d.ts.map +0 -1
  20. package/build/src/demo/DemoPage.js +0 -175
  21. package/build/src/demo/DemoPage.js.map +0 -1
  22. package/build/src/demo/DemoStyles.d.ts +0 -3
  23. package/build/src/demo/DemoStyles.d.ts.map +0 -1
  24. package/build/src/demo/DemoStyles.js +0 -60
  25. package/build/src/demo/DemoStyles.js.map +0 -1
  26. package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
  27. package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
  28. package/build/test/elements/navigation/Navigation.test.js +0 -113
  29. package/build/test/elements/navigation/Navigation.test.js.map +0 -1
  30. package/commitlint.config.cjs +0 -2
  31. package/demo/elements/authorization/AuthPlugin.js +0 -57
  32. package/demo/elements/authorization/AuthProxy.js +0 -215
  33. package/demo/elements/authorization/api-key.html +0 -27
  34. package/demo/elements/authorization/api-key.ts +0 -44
  35. package/demo/elements/authorization/basic.html +0 -27
  36. package/demo/elements/authorization/basic.ts +0 -43
  37. package/demo/elements/authorization/bearer.html +0 -27
  38. package/demo/elements/authorization/bearer.ts +0 -43
  39. package/demo/elements/authorization/env.js +0 -8
  40. package/demo/elements/authorization/index.html +0 -44
  41. package/demo/elements/authorization/ntlm.html +0 -27
  42. package/demo/elements/authorization/ntlm.ts +0 -43
  43. package/demo/elements/authorization/oauth-authorize.html +0 -75
  44. package/demo/elements/authorization/oauth-authorize.ts +0 -40
  45. package/demo/elements/authorization/oauth-error.html +0 -18
  46. package/demo/elements/authorization/oauth-error.ts +0 -10
  47. package/demo/elements/authorization/oauth-popup.html +0 -36
  48. package/demo/elements/authorization/oauth2.html +0 -27
  49. package/demo/elements/authorization/oauth2.ts +0 -100
  50. package/demo/elements/authorization/oidc.html +0 -27
  51. package/demo/elements/authorization/oidc.ts +0 -139
  52. package/demo/elements/authorization/private.crt +0 -31
  53. package/demo/elements/authorization/private.csr +0 -28
  54. package/demo/elements/authorization/private.key +0 -51
  55. package/demo/elements/authorization/private.pem +0 -31
  56. package/demo/elements/authorization/redirect.html +0 -20
  57. package/demo/elements/authorization/ssl-commands.sh +0 -30
  58. package/demo/elements/authorization/ssl.conf +0 -24
  59. package/demo/elements/autocomplete/index.html +0 -64
  60. package/demo/elements/autocomplete/index.ts +0 -171
  61. package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
  62. package/demo/elements/code-editor/index.html +0 -19
  63. package/demo/elements/context-menu/DemoIcons.ts +0 -21
  64. package/demo/elements/context-menu/basic.html +0 -25
  65. package/demo/elements/context-menu/basic.ts +0 -119
  66. package/demo/elements/context-menu/custom-data.html +0 -25
  67. package/demo/elements/context-menu/custom-data.ts +0 -62
  68. package/demo/elements/context-menu/demo.css +0 -28
  69. package/demo/elements/context-menu/enabled-state.html +0 -25
  70. package/demo/elements/context-menu/enabled-state.ts +0 -73
  71. package/demo/elements/context-menu/icons.html +0 -25
  72. package/demo/elements/context-menu/icons.ts +0 -64
  73. package/demo/elements/context-menu/index.html +0 -43
  74. package/demo/elements/context-menu/nested.html +0 -25
  75. package/demo/elements/context-menu/nestedt.ts +0 -152
  76. package/demo/elements/context-menu/no-execute.html +0 -25
  77. package/demo/elements/context-menu/no-execute.ts +0 -134
  78. package/demo/elements/context-menu/radio-menu.html +0 -25
  79. package/demo/elements/context-menu/radio-menu.ts +0 -83
  80. package/demo/elements/context-menu/separators.html +0 -25
  81. package/demo/elements/context-menu/separators.ts +0 -172
  82. package/demo/elements/currency/index.html +0 -91
  83. package/demo/elements/currency/index.ts +0 -352
  84. package/demo/elements/environment/environment-editor.html +0 -20
  85. package/demo/elements/environment/environment-editor.ts +0 -49
  86. package/demo/elements/environment/index.html +0 -33
  87. package/demo/elements/environment/server-editor.html +0 -20
  88. package/demo/elements/environment/server-editor.ts +0 -67
  89. package/demo/elements/environment/variables-editor.html +0 -20
  90. package/demo/elements/environment/variables-editor.ts +0 -94
  91. package/demo/elements/har/har-viewer.html +0 -20
  92. package/demo/elements/har/har-viewer.ts +0 -76
  93. package/demo/elements/har/har1.har +0 -3044
  94. package/demo/elements/har/har2.json +0 -439
  95. package/demo/elements/har/index.html +0 -26
  96. package/demo/elements/highlight/example.md +0 -27
  97. package/demo/elements/highlight/index.html +0 -31
  98. package/demo/elements/highlight/marked-highlight.html +0 -132
  99. package/demo/elements/highlight/marked-highlight.ts +0 -22
  100. package/demo/elements/highlight/prism-highlight.html +0 -62
  101. package/demo/elements/highlight/prism-highlight.ts +0 -17
  102. package/demo/elements/http/body-editor.html +0 -17
  103. package/demo/elements/http/body-editor.ts +0 -115
  104. package/demo/elements/http/headers.html +0 -17
  105. package/demo/elements/http/headers.ts +0 -59
  106. package/demo/elements/http/http-assertions.html +0 -20
  107. package/demo/elements/http/http-assertions.ts +0 -89
  108. package/demo/elements/http/http-flows.html +0 -23
  109. package/demo/elements/http/http-flows.ts +0 -89
  110. package/demo/elements/http/index.html +0 -45
  111. package/demo/elements/http/request-editor.html +0 -26
  112. package/demo/elements/http/request-editor.ts +0 -197
  113. package/demo/elements/http/request-log.html +0 -16
  114. package/demo/elements/http/request-log.ts +0 -136
  115. package/demo/elements/http/url-editing.html +0 -17
  116. package/demo/elements/http/url-editing.ts +0 -112
  117. package/demo/elements/icons/index.html +0 -81
  118. package/demo/elements/icons/index.ts +0 -52
  119. package/demo/elements/index.html +0 -72
  120. package/demo/elements/mention-textarea/index.html +0 -19
  121. package/demo/elements/mention-textarea/index.ts +0 -205
  122. package/demo/elements/navigation/navigation-item.html +0 -49
  123. package/demo/elements/navigation/navigation-item.ts +0 -131
  124. package/demo/elements/navigation/navigation.html +0 -20
  125. package/demo/elements/navigation/navigation.ts +0 -45
  126. package/demo/elements/project/index.html +0 -29
  127. package/demo/elements/project/project-run-report.html +0 -20
  128. package/demo/elements/project/project-run-report.ts +0 -132
  129. package/demo/elements/project/request-editor.html +0 -23
  130. package/demo/elements/project/request-editor.ts +0 -232
  131. package/demo/elements/user/user-avatar.html +0 -17
  132. package/demo/elements/user/user-avatar.ts +0 -60
  133. package/demo/env.js +0 -4
  134. package/demo/index.html +0 -34
  135. package/demo/layout/index.html +0 -94
  136. package/demo/layout/index.ts +0 -190
  137. package/demo/md/DemoStyles.ts +0 -61
  138. package/demo/md/UiDemoPage.ts +0 -6
  139. package/demo/md/buttons/button.html +0 -121
  140. package/demo/md/buttons/button.ts +0 -246
  141. package/demo/md/buttons/group.html +0 -36
  142. package/demo/md/buttons/group.ts +0 -171
  143. package/demo/md/checkbox/index.html +0 -39
  144. package/demo/md/checkbox/index.ts +0 -220
  145. package/demo/md/chip/chip.html +0 -70
  146. package/demo/md/chip/chip.ts +0 -219
  147. package/demo/md/chip/pawel6c9a.jpg +0 -0
  148. package/demo/md/collapse/CustomDetail.ts +0 -89
  149. package/demo/md/collapse/collapse.html +0 -21
  150. package/demo/md/collapse/collapse.ts +0 -78
  151. package/demo/md/date-picker/date-picker.ts +0 -336
  152. package/demo/md/date-picker/index.html +0 -171
  153. package/demo/md/dialog/confirm-dialog.html +0 -49
  154. package/demo/md/dialog/confirm-dialog.ts +0 -121
  155. package/demo/md/dialog/dialog.html +0 -25
  156. package/demo/md/dialog/dialog.ts +0 -468
  157. package/demo/md/dropdown-list/index.html +0 -31
  158. package/demo/md/dropdown-list/index.ts +0 -158
  159. package/demo/md/icon-button/index.html +0 -122
  160. package/demo/md/icon-button/index.ts +0 -132
  161. package/demo/md/index.html +0 -73
  162. package/demo/md/inputs/input.html +0 -73
  163. package/demo/md/inputs/input.ts +0 -278
  164. package/demo/md/inputs/radio.html +0 -39
  165. package/demo/md/inputs/radio.ts +0 -156
  166. package/demo/md/inputs/switch.html +0 -45
  167. package/demo/md/inputs/switch.ts +0 -144
  168. package/demo/md/list/list.html +0 -65
  169. package/demo/md/list/list.ts +0 -204
  170. package/demo/md/listbox/listbox.html +0 -31
  171. package/demo/md/listbox/listbox.ts +0 -27
  172. package/demo/md/menu/index.html +0 -19
  173. package/demo/md/menu/index.ts +0 -514
  174. package/demo/md/notification/snack.html +0 -21
  175. package/demo/md/notification/snack.ts +0 -70
  176. package/demo/md/progress/progress.html +0 -46
  177. package/demo/md/progress/progress.ts +0 -161
  178. package/demo/md/segmented-button/index.html +0 -21
  179. package/demo/md/segmented-button/index.ts +0 -55
  180. package/demo/md/select/index.html +0 -16
  181. package/demo/md/select/index.ts +0 -217
  182. package/demo/md/tabs/tabs.html +0 -40
  183. package/demo/md/tabs/tabs.ts +0 -214
  184. package/demo/oauth-popup.html +0 -36
  185. package/demo/page.css +0 -8
  186. package/demo/resources/calendar-month.png +0 -0
  187. package/demo/resources/favorite.png +0 -0
  188. package/demo/resources/fingerprint.png +0 -0
  189. package/demo/resources/home-work.png +0 -0
  190. package/demo/resources/mood.png +0 -0
  191. package/demo/resources/print.png +0 -0
  192. package/demo/resources/stars.png +0 -0
  193. package/demo/resources/theaters.png +0 -0
  194. package/demo/tsconfig.json +0 -4
  195. package/eslint.config.js +0 -97
  196. package/scripts/copy-assets.js +0 -21
  197. package/scripts/release.js +0 -66
  198. package/src/demo/DemoPage.ts +0 -169
  199. package/src/demo/DemoStyles.ts +0 -60
  200. package/test/README.md +0 -375
  201. package/test/contextual-menu/ContextMenu.test.ts +0 -760
  202. package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
  203. package/test/core/activity.spec.ts +0 -413
  204. package/test/core/activity_manager.spec.ts +0 -544
  205. package/test/core/application.spec.ts +0 -218
  206. package/test/core/fragment.spec.ts +0 -565
  207. package/test/core/fragment_manager.spec.ts +0 -404
  208. package/test/core/live_data.spec.ts +0 -558
  209. package/test/core/renderer.spec.ts +0 -113
  210. package/test/dom-assertions.test.ts +0 -182
  211. package/test/elements/MonacoSetup.ts +0 -65
  212. package/test/elements/authorization/basic-method.test.ts +0 -177
  213. package/test/elements/authorization/bearer-method.test.ts +0 -143
  214. package/test/elements/authorization/ntlm-method.test.ts +0 -219
  215. package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
  216. package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
  217. package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
  218. package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
  219. package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
  220. package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
  221. package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
  222. package/test/elements/authorization/openid-method.test.ts +0 -591
  223. package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
  224. package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
  225. package/test/elements/code-editor/code-editor.test.ts +0 -574
  226. package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
  227. package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
  228. package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
  229. package/test/elements/currency/CurrencyPicker.test.ts +0 -486
  230. package/test/elements/data-table/DataTable.browser.test.ts +0 -649
  231. package/test/elements/har/HarUtils.test.ts +0 -45
  232. package/test/elements/har/HarViewerElement.test.ts +0 -687
  233. package/test/elements/har/test-data/har1.har +0 -3044
  234. package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
  235. package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
  236. package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
  237. package/test/elements/highlight/remoteSanitization.md +0 -1
  238. package/test/elements/highlight/test.md +0 -3
  239. package/test/elements/highlight/test1.md +0 -3
  240. package/test/elements/highlight/test2.md +0 -1
  241. package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
  242. package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
  243. package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
  244. package/test/elements/http/CertificateAdd.test.ts +0 -457
  245. package/test/elements/http/HttpAssertions.test.ts +0 -994
  246. package/test/elements/http/HttpFlows.test.ts +0 -502
  247. package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
  248. package/test/elements/layout/SplitItem.test.ts +0 -440
  249. package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
  250. package/test/elements/layout/SplitPanel.test.ts +0 -1109
  251. package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
  252. package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
  253. package/test/elements/navigation/Navigation.test.ts +0 -120
  254. package/test/env.ts +0 -15
  255. package/test/events/EventTypes.test.ts +0 -363
  256. package/test/events/EventsTestHelpers.ts +0 -16
  257. package/test/helpers/TestUtils.ts +0 -243
  258. package/test/helpers/UiMock.ts +0 -185
  259. package/test/lib/Dom.test.ts +0 -231
  260. package/test/md/button/UiButton.test.ts +0 -347
  261. package/test/md/button/UiIconButton.test.ts +0 -155
  262. package/test/md/chip/UiChip.test.ts +0 -219
  263. package/test/md/collapse/UiCollapse.test.ts +0 -250
  264. package/test/md/collapse/flex-layout.test.ts +0 -105
  265. package/test/md/date-time/DateTime.test.ts +0 -348
  266. package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
  267. package/test/md/dialog/UiDialog.test.ts +0 -759
  268. package/test/md/menu/Menu.test.ts +0 -855
  269. package/test/md/menu/MenuIntegration.test.ts +0 -426
  270. package/test/md/menu/MenuItem.test.ts +0 -652
  271. package/test/md/menu/SubMenu.test.ts +0 -410
  272. package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
  273. package/test/md/progress/UiProgressElement.test.ts +0 -117
  274. package/test/md/progress/UiRangeElement.test.ts +0 -156
  275. package/test/md/select/Select.test.ts +0 -925
  276. package/test/plugins/takeScreenshotPlugin.js +0 -35
  277. package/test/setup.test.ts +0 -217
  278. package/test/setup.ts +0 -117
  279. package/test/tsconfig.json +0 -7
  280. package/web-dev-server.config.js +0 -21
  281. package/web-test-runner.config.js +0 -90
@@ -1,219 +0,0 @@
1
- import { html, fixture, assert, oneEvent } from '@open-wc/testing'
2
- import { INtlmAuthorization, IRequestAuthorization, RequestAuthorization } from '@api-client/core/browser.js'
3
- import { Authorization } from '../../../src/elements/authorization/ui/Authorization.js'
4
- import Input from '../../../src/md/input/Input.js'
5
- import '../../../src/define/authorization/ntlm-authorization.js'
6
-
7
- describe('NTLM method', () => {
8
- const usernameSelector = 'ui-filled-text-field[name="username"]'
9
- const passwordSelector = 'ui-filled-text-field[name="password"]'
10
- const domainSelector = 'ui-filled-text-field[name="domain"]'
11
-
12
- const username = 'test-username'
13
- const password = 'test-password'
14
- const domain = 'test-domain'
15
-
16
- async function basicFixture(auth?: IRequestAuthorization): Promise<Authorization> {
17
- return fixture(html`<ntlm-authorization .authorization="${auth}"></ntlm-authorization>`)
18
- }
19
-
20
- describe('DOM rendering', () => {
21
- let element: Authorization
22
- let form: HTMLFormElement
23
-
24
- beforeEach(async () => {
25
- const auth = RequestAuthorization.fromTypedConfig('ntlm', {}).toJSON()
26
- element = await basicFixture(auth)
27
- form = element.shadowRoot!.querySelector('form')!
28
- })
29
-
30
- it('has form in the DOM', async () => {
31
- assert.ok(form)
32
- })
33
-
34
- it('has form has autocomplete', async () => {
35
- assert.equal(form.getAttribute('autocomplete'), 'on')
36
- })
37
-
38
- it('form has username input', async () => {
39
- const input = form.querySelector(usernameSelector)
40
- assert.ok(input)
41
- })
42
-
43
- it('username is required', async () => {
44
- const input = form.querySelector(usernameSelector) as Input
45
- assert.isTrue(input.required)
46
- })
47
-
48
- it('username has the invalid label', async () => {
49
- const input = form.querySelector(usernameSelector) as Input
50
- assert.equal(input.invalidText, 'Username is required')
51
- })
52
-
53
- it('form has password input', async () => {
54
- const input = form.querySelector(passwordSelector)
55
- assert.ok(input)
56
- })
57
-
58
- it('password is not required', async () => {
59
- const input = form.querySelector(passwordSelector) as Input
60
- assert.notOk(input.required)
61
- })
62
-
63
- it('form has domain input', async () => {
64
- const input = form.querySelector(domainSelector)
65
- assert.ok(input)
66
- })
67
-
68
- it('domain is not required', async () => {
69
- const input = form.querySelector(domainSelector) as Input
70
- assert.notOk(input.required)
71
- })
72
-
73
- it('has no other inputs', () => {
74
- const controls = form.querySelectorAll('ui-filled-text-field')
75
- assert.lengthOf(controls, 3)
76
- })
77
- })
78
-
79
- describe('change notification', () => {
80
- let element: Authorization
81
- beforeEach(async () => {
82
- const auth = RequestAuthorization.fromTypedConfig('ntlm', {}).toJSON()
83
- element = await basicFixture(auth)
84
- })
85
-
86
- it('notifies when username changes', async () => {
87
- const input = element.shadowRoot!.querySelector(usernameSelector) as Input
88
- setTimeout(() => {
89
- input.value = 'test'
90
- input.dispatchEvent(new CustomEvent('change'))
91
- })
92
- const e = await oneEvent(element, 'change')
93
- assert.ok(e)
94
- })
95
-
96
- it('notifies when password changes', async () => {
97
- const input = element.shadowRoot!.querySelector(passwordSelector) as Input
98
- setTimeout(() => {
99
- input.value = 'test'
100
- input.dispatchEvent(new CustomEvent('change'))
101
- })
102
- const e = await oneEvent(element, 'change')
103
- assert.ok(e)
104
- })
105
-
106
- it('notifies when domain changes', async () => {
107
- const input = element.shadowRoot!.querySelector(domainSelector) as Input
108
- setTimeout(() => {
109
- input.value = 'test'
110
- input.dispatchEvent(new CustomEvent('change'))
111
- })
112
- const e = await oneEvent(element, 'change')
113
- assert.ok(e)
114
- })
115
- })
116
-
117
- describe('updating the model', () => {
118
- let element: Authorization
119
- beforeEach(async () => {
120
- const auth = RequestAuthorization.fromTypedConfig('ntlm', {
121
- username,
122
- password,
123
- domain,
124
- }).toJSON()
125
- element = await basicFixture(auth)
126
- })
127
-
128
- it('updates the username from user input', () => {
129
- const input = element.shadowRoot!.querySelector(usernameSelector) as Input
130
- input.value = 'test'
131
- input.dispatchEvent(new Event('change'))
132
- const config = element.authorization!.config as INtlmAuthorization
133
- assert.equal(config.username, 'test')
134
- })
135
-
136
- it('updates the password from user input', () => {
137
- const input = element.shadowRoot!.querySelector(passwordSelector) as Input
138
- input.value = 'test'
139
- input.dispatchEvent(new Event('change'))
140
- const config = element.authorization!.config as INtlmAuthorization
141
- assert.equal(config.password, 'test')
142
- })
143
-
144
- it('updates the domain from user input', () => {
145
- const input = element.shadowRoot!.querySelector(domainSelector) as Input
146
- input.value = 'test'
147
- input.dispatchEvent(new Event('change'))
148
- const config = element.authorization!.config as INtlmAuthorization
149
- assert.equal(config.domain, 'test')
150
- })
151
- })
152
-
153
- describe('data restoration', () => {
154
- let element: Authorization
155
- beforeEach(async () => {
156
- const auth = RequestAuthorization.fromTypedConfig('ntlm', {
157
- username,
158
- password,
159
- domain,
160
- }).toJSON()
161
- element = await basicFixture(auth)
162
- })
163
-
164
- it('has the value on the username filed', () => {
165
- const input = element.shadowRoot!.querySelector(usernameSelector) as Input
166
- assert.equal(input.value, username)
167
- })
168
-
169
- it('has the value on the password filed', () => {
170
- const input = element.shadowRoot!.querySelector(passwordSelector) as Input
171
- assert.equal(input.value, password)
172
- })
173
-
174
- it('has the value on the domain filed', () => {
175
- const input = element.shadowRoot!.querySelector(domainSelector) as Input
176
- assert.equal(input.value, domain)
177
- })
178
- })
179
-
180
- describe('validation', () => {
181
- let element: Authorization
182
- beforeEach(async () => {
183
- const auth = RequestAuthorization.fromTypedConfig('ntlm', {}).toJSON()
184
- element = await basicFixture(auth)
185
- })
186
-
187
- it('is not valid without the username', () => {
188
- const result = element.checkValidity()
189
- assert.isFalse(result)
190
- })
191
-
192
- it('is valid with the username', async () => {
193
- ;(element.authorization!.config as INtlmAuthorization).username = 'test-username'
194
- element.requestUpdate()
195
- await element.updateComplete
196
- const result = element.checkValidity()
197
- assert.isTrue(result)
198
- })
199
- })
200
-
201
- describe('a11y', () => {
202
- it('is accessible without the model', async () => {
203
- const element = await basicFixture()
204
- await assert.isAccessible(element)
205
- })
206
-
207
- it('is accessible when empty', async () => {
208
- const auth = RequestAuthorization.fromTypedConfig('ntlm', {}).toJSON()
209
- const element = await basicFixture(auth)
210
- await assert.isAccessible(element)
211
- })
212
-
213
- it('is accessible with values', async () => {
214
- const auth = RequestAuthorization.fromTypedConfig('ntlm', { username, password, domain }).toJSON()
215
- const element = await basicFixture(auth)
216
- await assert.isAccessible(element)
217
- })
218
- })
219
- })
@@ -1,334 +0,0 @@
1
- import { html, fixture, assert, oneEvent } from '@open-wc/testing'
2
- import { spy } from 'sinon'
3
- import {
4
- EventTypes,
5
- IOAuth2Authorization,
6
- IRequestAuthorization,
7
- RequestAuthorizationKind,
8
- } from '@api-client/core/browser.js'
9
- import OAuth2Authorization from '../../../src/elements/authorization/ui/OAuth2Authorization.js'
10
- import Input from '../../../src/md/input/Input.js'
11
- import { Oauth2Credentials } from '../../../src/elements/authorization/types.js'
12
- import UiListItem from '../../../src/md/list/internals/ListItem.js'
13
- import '../../../src/define/authorization/oauth2-authorization.js'
14
-
15
- describe('Authorization', () => {
16
- describe('<oauth2-authorization>', () => {
17
- describe('client_credentials', () => {
18
- const baseConfig: IOAuth2Authorization = {
19
- grantType: 'client_credentials',
20
- clientId: 'test-client-id',
21
- clientSecret: 'test-secret-client',
22
- accessTokenUri: 'https://accounts.google.com/o/oauth2/v2/token',
23
- scopes: ['email', 'profile'],
24
- deliveryMethod: 'header',
25
- }
26
-
27
- async function basicFixture(opts: IOAuth2Authorization = {}): Promise<OAuth2Authorization> {
28
- const auth: IRequestAuthorization = {
29
- config: opts,
30
- enabled: true,
31
- kind: RequestAuthorizationKind,
32
- type: 'oauth 2',
33
- valid: true,
34
- }
35
- return fixture(html`<oauth2-authorization .authorization="${auth}"></oauth2-authorization>`)
36
- }
37
-
38
- async function baseUriFixture(baseUri: string, opts: IOAuth2Authorization): Promise<OAuth2Authorization> {
39
- const auth: IRequestAuthorization = {
40
- config: opts,
41
- enabled: true,
42
- kind: RequestAuthorizationKind,
43
- type: 'oauth 2',
44
- valid: true,
45
- }
46
- return fixture(
47
- html`<oauth2-authorization .authorization="${auth}" .baseUri="${baseUri}"></oauth2-authorization>`
48
- )
49
- }
50
-
51
- async function credentialSourceFixture(
52
- credentialsSource: Oauth2Credentials[],
53
- opts: IOAuth2Authorization
54
- ): Promise<OAuth2Authorization> {
55
- const auth: IRequestAuthorization = {
56
- config: opts,
57
- enabled: true,
58
- kind: RequestAuthorizationKind,
59
- type: 'oauth 2',
60
- valid: true,
61
- }
62
- return fixture(
63
- html`<oauth2-authorization
64
- .authorization="${auth}"
65
- .credentialsSource="${credentialsSource}"
66
- ></oauth2-authorization>`
67
- )
68
- }
69
-
70
- describe('DOM rendering', () => {
71
- let element: OAuth2Authorization
72
- let form: HTMLFormElement
73
- beforeEach(async () => {
74
- element = await basicFixture({ ...baseConfig })
75
- form = element.shadowRoot!.querySelector('form')!
76
- })
77
-
78
- it(`has the clientId input`, async () => {
79
- const input = form.querySelector(`[name="clientId"]`) as Input
80
- assert.ok(input, 'has the input')
81
- })
82
-
83
- it(`has the clientSecret input`, async () => {
84
- const input = form.querySelector(`[name="clientSecret"]`) as Input
85
- assert.ok(input, 'has the input')
86
- })
87
-
88
- it(`has the accessTokenUri input`, async () => {
89
- const input = form.querySelector(`[name="accessTokenUri"]`) as Input
90
- assert.ok(input, 'has the input')
91
- })
92
-
93
- it('client secret is not required', async () => {
94
- const input = form.querySelector(`[name="clientSecret"]`) as Input
95
- assert.notOk(input.required)
96
- })
97
-
98
- it('does not render the redirect URI field', async () => {
99
- const section = element.shadowRoot!.querySelector('[name="redirectUri"]')
100
- assert.notOk(section)
101
- })
102
-
103
- it('does not render the PKCE checkbox', async () => {
104
- const node = element.shadowRoot!.querySelector('[name="pkce"]')
105
- assert.notOk(node)
106
- })
107
-
108
- it('renders the delivery method drop down', async () => {
109
- const input = element.shadowRoot!.querySelector('*[name="deliveryMethod"]') as Input
110
- assert.ok(input)
111
- })
112
- })
113
-
114
- describe('Data initialization', () => {
115
- let element: OAuth2Authorization
116
- beforeEach(async () => {
117
- element = await basicFixture({ ...baseConfig })
118
- })
119
-
120
- it(`has the clientId`, async () => {
121
- const input = element.shadowRoot!.querySelector(`*[name="clientId"]`) as Input
122
- assert.equal(input.value, baseConfig.clientId)
123
- })
124
-
125
- it(`has the clientSecret`, async () => {
126
- const input = element.shadowRoot!.querySelector(`*[name="clientSecret"]`) as Input
127
- assert.equal(input.value, baseConfig.clientSecret)
128
- })
129
-
130
- it(`has the accessTokenUri input`, async () => {
131
- const input = element.shadowRoot!.querySelector(`*[name="accessTokenUri"]`) as Input
132
- assert.equal(input.value, baseConfig.accessTokenUri)
133
- })
134
-
135
- it('has the delivery method', async () => {
136
- const input = element.shadowRoot!.querySelector('*[name="deliveryMethod"]') as Input
137
- assert.equal(input.dataset.selected, baseConfig.deliveryMethod)
138
- })
139
- })
140
-
141
- describe('Change notification', () => {
142
- let element: OAuth2Authorization
143
- beforeEach(async () => {
144
- element = await basicFixture({ ...baseConfig })
145
- })
146
-
147
- it(`notifies when clientId changes`, async () => {
148
- setTimeout(() => {
149
- const input = element.shadowRoot!.querySelector(`[name="clientId"]`) as Input
150
- input.value = 'changed'
151
- input.dispatchEvent(new CustomEvent('change'))
152
- })
153
- const e = await oneEvent(element, 'change')
154
- assert.ok(e)
155
- })
156
-
157
- it(`notifies when clientSecret changes`, async () => {
158
- setTimeout(() => {
159
- const input = element.shadowRoot!.querySelector(`[name="clientSecret"]`) as Input
160
- input.value = 'changed'
161
- input.dispatchEvent(new CustomEvent('change'))
162
- })
163
- const e = await oneEvent(element, 'change')
164
- assert.ok(e)
165
- })
166
-
167
- it(`notifies when accessTokenUri changes`, async () => {
168
- setTimeout(() => {
169
- const input = element.shadowRoot!.querySelector(`[name="accessTokenUri"]`) as Input
170
- input.value = 'changed'
171
- input.dispatchEvent(new CustomEvent('change'))
172
- })
173
- const e = await oneEvent(element, 'change')
174
- assert.ok(e)
175
- })
176
-
177
- it(`notifies when deliveryMethod changes`, async () => {
178
- setTimeout(() => {
179
- const item = element.shadowRoot!.querySelector(`.delivery-method-line [data-value="body"]`) as UiListItem
180
- item.click()
181
- })
182
- const e = await oneEvent(element, 'change')
183
- assert.ok(e)
184
- })
185
- })
186
-
187
- describe('Data serialization', () => {
188
- let element: OAuth2Authorization
189
- beforeEach(async () => {
190
- element = await basicFixture({ ...baseConfig })
191
- })
192
-
193
- it(`serializes the clientId`, async () => {
194
- const result = element.serialize()
195
- assert.equal(result.clientId, baseConfig.clientId)
196
- })
197
-
198
- it(`serializes the clientSecret`, async () => {
199
- const result = element.serialize()
200
- assert.equal(result.clientSecret, baseConfig.clientSecret)
201
- })
202
-
203
- it(`serializes the accessTokenUri`, async () => {
204
- const result = element.serialize()
205
- assert.equal(result.accessTokenUri, baseConfig.accessTokenUri)
206
- })
207
-
208
- it(`serializes the scopes`, async () => {
209
- const result = element.serialize()
210
- assert.deepEqual(result.scopes, baseConfig.scopes)
211
- })
212
-
213
- it(`serializes the deliveryMethod`, async () => {
214
- const result = element.serialize()
215
- assert.deepEqual(result.deliveryMethod, baseConfig.deliveryMethod)
216
- })
217
- })
218
-
219
- describe('authorization event', () => {
220
- let element: OAuth2Authorization
221
-
222
- beforeEach(async () => {
223
- element = await basicFixture({ ...baseConfig })
224
- })
225
-
226
- it(`sets the serialized values onto the event`, async () => {
227
- const handler = spy()
228
- element.addEventListener(EventTypes.Authorization.OAuth2.authorize, handler)
229
- element.authorize()
230
- const { detail } = handler.args[0][0] as CustomEvent<IOAuth2Authorization & { result?: unknown }>
231
- delete detail.state
232
- delete detail.result
233
- assert.deepEqual(detail, element.serialize())
234
- })
235
- })
236
-
237
- describe('application grant type', () => {
238
- let element: OAuth2Authorization
239
-
240
- beforeEach(async () => {
241
- const opts = {
242
- ...baseConfig,
243
- grantType: 'application',
244
- }
245
- element = await basicFixture(opts)
246
- })
247
-
248
- it(`authorization event has credentials when grant_type is application`, async () => {
249
- const handler = spy()
250
- element.addEventListener(EventTypes.Authorization.OAuth2.authorize, handler)
251
- await element.authorize()
252
- const { detail } = handler.args[0][0]
253
- assert.equal(detail.grantType, 'application')
254
- assert.equal(detail.clientId, baseConfig.clientId)
255
- assert.equal(detail.clientSecret, baseConfig.clientSecret)
256
- })
257
- })
258
-
259
- describe('#baseUri', () => {
260
- const baseUri = 'https://api.domain.com/auth'
261
-
262
- it('adds base URI to accessTokenUri', async () => {
263
- const params = { ...baseConfig }
264
- params.accessTokenUri = '/authorize'
265
- const element = await baseUriFixture(baseUri, params)
266
- const result = element.serialize()
267
- assert.equal(result.accessTokenUri, 'https://api.domain.com/auth/authorize')
268
- })
269
-
270
- it('ignores trailing slash', async () => {
271
- const uri = `${baseUri}/`
272
- const params = { ...baseConfig }
273
- params.accessTokenUri = '/authorize'
274
- const element = await baseUriFixture(uri, params)
275
- const result = element.serialize()
276
- assert.equal(result.accessTokenUri, 'https://api.domain.com/auth/authorize')
277
- })
278
-
279
- it('makes accessTokenUri input text type', async () => {
280
- const element = await baseUriFixture(baseUri, { ...baseConfig })
281
- const node = element.shadowRoot!.querySelector('[name="accessTokenUri"]') as Input
282
- assert.equal(node.type, 'string')
283
- })
284
- })
285
-
286
- describe('Credentials source', () => {
287
- const credentials: Oauth2Credentials[] = [
288
- {
289
- grantType: 'client_credentials',
290
- credentials: [
291
- { name: 'My social Network', clientId: '123', clientSecret: 'xyz' },
292
- { name: 'My social Network 2', clientId: '1234', clientSecret: 'wxyz' },
293
- ],
294
- },
295
- ]
296
-
297
- let element: OAuth2Authorization
298
- beforeEach(async () => {
299
- element = await credentialSourceFixture(credentials, { ...baseConfig })
300
- })
301
-
302
- it('renders credentials source dropdown', async () => {
303
- assert.isNotNull(element.shadowRoot!.querySelector('[name="credentialSource"]'))
304
- })
305
-
306
- it('should fill clientId and clientSecret as read only from source', async () => {
307
- setTimeout(() => {
308
- const item = element.shadowRoot!.querySelector(
309
- `.credential-source-list [data-value="${credentials[0].credentials[0].name}"]`
310
- ) as UiListItem
311
- item.click()
312
- })
313
- const e = await oneEvent(element, 'change')
314
- assert.ok(e)
315
- assert.equal(element.config.clientSecret, 'xyz')
316
- assert.equal(element.config.clientId, '123')
317
- assert.isTrue(element.credentialsDisabled)
318
- })
319
- })
320
-
321
- describe('a11y', () => {
322
- let element: OAuth2Authorization
323
-
324
- beforeEach(async () => {
325
- element = await basicFixture({ ...baseConfig })
326
- })
327
-
328
- it('passes automated a11y tests', async () => {
329
- await assert.isAccessible(element)
330
- })
331
- })
332
- })
333
- })
334
- })