@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,574 +0,0 @@
1
- import { fixture, assert, html, oneEvent, nextFrame, aTimeout } from '@open-wc/testing'
2
- import sinon from 'sinon'
3
-
4
- import { CodeEditorElement } from '../../../src/elements/code-editor/code-editor.js'
5
- import '../../../src/elements/code-editor/code-editor.js' // Registers the element
6
-
7
- import type { Suggestion } from '../../../src/elements/code-editor/internals/types.js'
8
- import type { FunctionSchema } from '@pawel-up/jexl/schemas/types.js'
9
-
10
- describe('CodeEditor', () => {
11
- // Sample test data
12
- const sampleFunctionSchemas: FunctionSchema[] = [
13
- {
14
- name: 'testFunction',
15
- description: 'A test function',
16
- category: 'test',
17
- parameters: [
18
- {
19
- name: 'param1',
20
- required: true,
21
- schema: {
22
- type: 'string',
23
- description: 'First parameter',
24
- },
25
- },
26
- {
27
- name: 'param2',
28
- required: false,
29
- schema: {
30
- type: 'number',
31
- description: 'Second parameter',
32
- },
33
- },
34
- ],
35
- returns: {
36
- type: 'string',
37
- description: 'Returns a string',
38
- },
39
- },
40
- {
41
- name: 'anotherFunction',
42
- description: 'Another test function',
43
- category: 'test',
44
- parameters: [],
45
- returns: {
46
- type: 'boolean',
47
- },
48
- },
49
- ]
50
-
51
- const sampleSuggestions: Suggestion[] = [
52
- {
53
- id: 'suggestion-1',
54
- label: 'First Suggestion',
55
- description: 'Description for first suggestion',
56
- suffix: 'string',
57
- },
58
- {
59
- id: 'suggestion-2',
60
- label: 'Second Suggestion',
61
- description: 'Description for second suggestion',
62
- suffix: 'number',
63
- },
64
- {
65
- id: 'suggestion with spaces',
66
- label: 'Suggestion With Spaces',
67
- description: 'A suggestion with spaces in ID',
68
- suffix: 'object',
69
- },
70
- ]
71
-
72
- async function basicFixture(): Promise<CodeEditorElement> {
73
- return fixture(html`<code-editor></code-editor>`)
74
- }
75
-
76
- async function configuredFixture(): Promise<CodeEditorElement> {
77
- return fixture(html`
78
- <code-editor
79
- label="Test Editor"
80
- supportingtext="Enter your code here"
81
- placeholder="Type here..."
82
- .functionSchemas="${sampleFunctionSchemas}"
83
- .suggestions="${sampleSuggestions}"
84
- ></code-editor>
85
- `)
86
- }
87
-
88
- async function documentationFixture(): Promise<CodeEditorElement> {
89
- return fixture(html`
90
- <code-editor
91
- showdocumentation
92
- .functionSchemas="${sampleFunctionSchemas}"
93
- .suggestions="${sampleSuggestions}"
94
- ></code-editor>
95
- `)
96
- }
97
-
98
- describe('Basic Properties', () => {
99
- it('should render with default properties', async () => {
100
- const el = await basicFixture()
101
-
102
- assert.equal(el.label, '')
103
- assert.equal(el.supportingText, '')
104
- assert.isFalse(el.disabled)
105
- assert.isFalse(el.invalid)
106
- assert.isFalse(el.required)
107
- assert.equal(el.placeholder, '')
108
- assert.equal(el.value, '')
109
- assert.equal(el.language, 'javascript')
110
- assert.isFalse(el.showDocumentation)
111
- assert.deepEqual(el.functionSchemas, [])
112
- assert.deepEqual(el.suggestions, [])
113
- })
114
-
115
- it('should set and get properties correctly', async () => {
116
- const el = await basicFixture()
117
-
118
- el.label = 'Test Label'
119
- el.supportingText = 'Test Support'
120
- el.disabled = true
121
- el.invalid = true
122
- el.required = true
123
- el.placeholder = 'Test Placeholder'
124
- el.value = 'test code'
125
- el.language = 'python'
126
- el.showDocumentation = true
127
- el.functionSchemas = sampleFunctionSchemas
128
- el.suggestions = sampleSuggestions
129
-
130
- await nextFrame()
131
-
132
- assert.equal(el.label, 'Test Label')
133
- assert.equal(el.supportingText, 'Test Support')
134
- assert.isTrue(el.disabled)
135
- assert.isTrue(el.invalid)
136
- assert.isTrue(el.required)
137
- assert.equal(el.placeholder, 'Test Placeholder')
138
- assert.equal(el.value, 'test code')
139
- assert.equal(el.language, 'python')
140
- assert.isTrue(el.showDocumentation)
141
- assert.deepEqual(el.functionSchemas, sampleFunctionSchemas)
142
- assert.deepEqual(el.suggestions, sampleSuggestions)
143
- })
144
-
145
- it('should reflect disabled and invalid properties to attributes', async () => {
146
- const el = await basicFixture()
147
-
148
- el.disabled = true
149
- el.invalid = true
150
- await nextFrame()
151
-
152
- assert.isTrue(el.hasAttribute('disabled'))
153
- assert.isTrue(el.hasAttribute('invalid'))
154
-
155
- el.disabled = false
156
- el.invalid = false
157
- await nextFrame()
158
-
159
- assert.isFalse(el.hasAttribute('disabled'))
160
- assert.isFalse(el.hasAttribute('invalid'))
161
- })
162
- })
163
-
164
- describe('DOM Structure', () => {
165
- it('should render label when provided', async () => {
166
- const el = await configuredFixture()
167
- await nextFrame()
168
-
169
- const label = el.shadowRoot!.querySelector('.label')
170
- assert.exists(label)
171
- assert.equal(label!.textContent, 'Test Editor')
172
- })
173
-
174
- it('should render supporting text when provided', async () => {
175
- const el = await configuredFixture()
176
- await nextFrame()
177
-
178
- const supportingText = el.shadowRoot!.querySelector('.supporting-text')
179
- assert.exists(supportingText)
180
- assert.equal(supportingText!.textContent, 'Enter your code here')
181
- })
182
-
183
- it('should not render label when not provided', async () => {
184
- const el = await basicFixture()
185
- await nextFrame()
186
-
187
- const label = el.shadowRoot!.querySelector('.label')
188
- assert.notExists(label)
189
- })
190
-
191
- it('should not render supporting text when not provided', async () => {
192
- const el = await basicFixture()
193
- await nextFrame()
194
-
195
- const supportingText = el.shadowRoot!.querySelector('.supporting-text')
196
- assert.notExists(supportingText)
197
- })
198
-
199
- it('should have editor container', async () => {
200
- const el = await basicFixture()
201
- await nextFrame()
202
-
203
- const editorContainer = el.shadowRoot!.querySelector('.editor-container')
204
- assert.exists(editorContainer)
205
- })
206
-
207
- it('should apply invalid class when invalid', async () => {
208
- const el = await basicFixture()
209
- el.invalid = true
210
- await nextFrame()
211
-
212
- const surface = el.shadowRoot!.querySelector('.surface')
213
- assert.isTrue(surface!.classList.contains('invalid'))
214
- })
215
- })
216
-
217
- describe('Value Management', () => {
218
- it('should update value programmatically', async () => {
219
- const el = await basicFixture()
220
- await nextFrame()
221
-
222
- el.value = 'new value'
223
- await nextFrame()
224
-
225
- assert.equal(el.value, 'new value')
226
- })
227
-
228
- it('should dispatch input event when content changes', async () => {
229
- const el = await basicFixture()
230
- await nextFrame()
231
-
232
- setTimeout(() => {
233
- el.insertText('test input')
234
- })
235
-
236
- await oneEvent(el, 'input')
237
- assert.include(el.value, 'test input')
238
- })
239
-
240
- it('should dispatch change event when focus is lost and value changed', async () => {
241
- const el = await basicFixture()
242
- await nextFrame()
243
-
244
- el.focus()
245
- el.insertText('test change')
246
-
247
- setTimeout(() => {
248
- el.blur()
249
- })
250
-
251
- const event = await oneEvent(el, 'change')
252
- assert.exists(event)
253
- })
254
- })
255
-
256
- describe('Active Suggestions', () => {
257
- it('should return empty array when no placeholders in value', async () => {
258
- const el = await configuredFixture()
259
- await nextFrame()
260
-
261
- el.value = 'some regular text'
262
- await nextFrame()
263
-
264
- assert.deepEqual(el.activeSuggestions, [])
265
- })
266
-
267
- it('should return matching suggestions for placeholders', async () => {
268
- const el = await configuredFixture()
269
- await nextFrame()
270
-
271
- el.value = 'text {{suggestion-1}} more text {{suggestion-2}}'
272
- await nextFrame()
273
-
274
- const activeSuggestions = el.activeSuggestions
275
- assert.lengthOf(activeSuggestions, 2)
276
- assert.deepEqual(
277
- activeSuggestions.map((s) => s.id),
278
- ['suggestion-1', 'suggestion-2']
279
- )
280
- })
281
-
282
- it('should handle suggestions with spaces in ID', async () => {
283
- const el = await configuredFixture()
284
- await nextFrame()
285
-
286
- el.value = 'text {{suggestion with spaces}} more text'
287
- await nextFrame()
288
-
289
- const activeSuggestions = el.activeSuggestions
290
- assert.lengthOf(activeSuggestions, 1)
291
- assert.equal(activeSuggestions[0].id, 'suggestion with spaces')
292
- })
293
-
294
- it('should ignore placeholders without matching suggestions', async () => {
295
- const el = await configuredFixture()
296
- await nextFrame()
297
-
298
- el.value = 'text {{unknown-suggestion}} {{suggestion-1}}'
299
- await nextFrame()
300
-
301
- const activeSuggestions = el.activeSuggestions
302
- assert.lengthOf(activeSuggestions, 1)
303
- assert.equal(activeSuggestions[0].id, 'suggestion-1')
304
- })
305
- })
306
-
307
- describe('Public Methods', () => {
308
- // This sometimes fails in CI but works locally
309
- it.skip('should focus the editor', async () => {
310
- const el = await basicFixture()
311
- await nextFrame()
312
-
313
- el.focus()
314
- await nextFrame()
315
-
316
- const surface = el.shadowRoot!.querySelector('.surface')
317
- assert.isTrue(surface!.classList.contains('has-focus'))
318
- })
319
-
320
- it('should get current selection', async () => {
321
- const el = await basicFixture()
322
- await nextFrame()
323
-
324
- const selection = el.getSelection()
325
- assert.exists(selection)
326
- assert.property(selection, 'from')
327
- assert.property(selection, 'to')
328
- })
329
-
330
- it('should insert text at cursor position', async () => {
331
- const el = await basicFixture()
332
- await nextFrame()
333
-
334
- el.insertText('inserted text')
335
- await nextFrame()
336
-
337
- assert.include(el.value, 'inserted text')
338
- })
339
- })
340
-
341
- describe('Function Events', () => {
342
- it('should dispatch functioninsert event through user interaction', async () => {
343
- const el = await configuredFixture()
344
- await nextFrame()
345
-
346
- // Wait for editor to be ready
347
- await aTimeout(100)
348
-
349
- // Create a spy to capture the event
350
- const eventSpy = sinon.spy()
351
- el.addEventListener('functioninsert', eventSpy)
352
-
353
- // Note: In a real test, this would be triggered by CodeMirror autocompletion
354
- // For now, we test that the event listener is properly set up
355
- assert.isFalse(eventSpy.called)
356
- })
357
-
358
- it('should dispatch suggestioninsert event through user interaction', async () => {
359
- const el = await configuredFixture()
360
- await nextFrame()
361
-
362
- // Create a spy to capture the event
363
- const eventSpy = sinon.spy()
364
- el.addEventListener('suggestioninsert', eventSpy)
365
-
366
- // Note: In a real test, this would be triggered by CodeMirror autocompletion
367
- // For now, we test that the event listener is properly set up
368
- assert.isFalse(eventSpy.called)
369
- })
370
-
371
- it('should have docsrequest event listener when showDocumentation is true', async () => {
372
- const el = await documentationFixture()
373
- await nextFrame()
374
-
375
- // Create a spy to capture the event
376
- const eventSpy = sinon.spy()
377
- el.addEventListener('docsrequest', eventSpy)
378
-
379
- // Test that the element is configured to dispatch this event
380
- assert.isTrue(el.showDocumentation)
381
- assert.isFalse(eventSpy.called)
382
- })
383
- })
384
-
385
- describe('Accessibility', () => {
386
- it('should have delegatesFocus enabled', async () => {
387
- const el = await basicFixture()
388
-
389
- // The shadowRoot should delegate focus
390
- assert.isTrue(el.shadowRoot!.delegatesFocus)
391
- })
392
-
393
- it('should set aria-placeholder when placeholder is provided', async () => {
394
- const el = await configuredFixture()
395
- await nextFrame()
396
-
397
- // Wait for CodeMirror to initialize
398
- await aTimeout(100)
399
-
400
- // Check if aria-placeholder is set on the editor
401
- const editorElement = el.shadowRoot!.querySelector('.cm-editor')
402
- if (editorElement) {
403
- const contentElement = editorElement.querySelector('.cm-content')
404
- assert.equal(contentElement?.getAttribute('aria-placeholder'), 'Type here...')
405
- }
406
- })
407
- })
408
-
409
- describe('Error Handling', () => {
410
- it('should handle empty function schemas gracefully', async () => {
411
- const el = await basicFixture()
412
- el.functionSchemas = []
413
- await nextFrame()
414
-
415
- assert.deepEqual(el.functionSchemas, [])
416
- assert.doesNotThrow(() => el.activeSuggestions)
417
- })
418
-
419
- it('should handle empty suggestions gracefully', async () => {
420
- const el = await basicFixture()
421
- el.suggestions = []
422
- await nextFrame()
423
-
424
- assert.deepEqual(el.suggestions, [])
425
- assert.doesNotThrow(() => el.activeSuggestions)
426
- })
427
-
428
- it('should handle malformed placeholders gracefully', async () => {
429
- const el = await configuredFixture()
430
- await nextFrame()
431
-
432
- el.value = 'text {{incomplete} {{}} {{valid-suggestion}}'
433
- await nextFrame()
434
-
435
- assert.doesNotThrow(() => el.activeSuggestions)
436
- })
437
- })
438
-
439
- describe('Disabled State', () => {
440
- it('should apply readonly state when disabled', async () => {
441
- const el = await basicFixture()
442
- el.disabled = true
443
- await el.updateComplete
444
-
445
- // Wait for CodeMirror to update
446
- await aTimeout(100)
447
-
448
- assert.isTrue(el.disabled)
449
-
450
- // The editor should be readonly when disabled
451
- const editorElement = el.shadowRoot!.querySelector('.cm-editor [aria-readonly="true"]')
452
- assert.ok(editorElement)
453
- })
454
-
455
- it('should remove readonly state when enabled', async () => {
456
- const el = await basicFixture()
457
- el.disabled = true
458
- await el.updateComplete
459
-
460
- el.disabled = false
461
- await el.updateComplete
462
-
463
- const editorElement = el.shadowRoot!.querySelector('.cm-editor [aria-readonly="true"]')
464
- assert.notOk(editorElement)
465
- })
466
- })
467
-
468
- describe('Documentation Button', () => {
469
- it('should have showDocumentation property', async () => {
470
- const el = await basicFixture()
471
-
472
- assert.isFalse(el.showDocumentation)
473
-
474
- el.showDocumentation = true
475
- assert.isTrue(el.showDocumentation)
476
- })
477
-
478
- it('should be configured for documentation features', async () => {
479
- const el = await documentationFixture()
480
- await nextFrame()
481
-
482
- // Test setup is correct for documentation features
483
- assert.isTrue(el.showDocumentation)
484
- assert.isAtLeast(el.functionSchemas.length, 1)
485
- })
486
-
487
- it('should dispatch docsrequest event when documentation is enabled', async () => {
488
- const el = await documentationFixture()
489
- await nextFrame()
490
- await aTimeout(100) // Wait for CodeMirror initialization
491
-
492
- const eventSpy = sinon.spy()
493
- el.addEventListener('docsrequest', eventSpy)
494
-
495
- // Access the private method through bracket notation to avoid TypeScript errors
496
- const functionSchema = sampleFunctionSchemas[0]
497
- const infoElement = el['createFunctionInfoElement'](functionSchema)
498
-
499
- // Should contain a documentation button when showDocumentation is true
500
- const docButton = infoElement.querySelector('.documentation-button')
501
- assert.exists(docButton)
502
- assert.equal(docButton?.textContent, 'Show documentation')
503
-
504
- // Simulate button click
505
- ;(docButton as HTMLElement).click()
506
-
507
- // Event should be dispatched
508
- assert.isTrue(eventSpy.called)
509
- assert.equal(eventSpy.callCount, 1)
510
-
511
- const eventDetail = eventSpy.firstCall.args[0].detail
512
- assert.exists(eventDetail.functionSchema)
513
- assert.equal(eventDetail.functionSchema.name, functionSchema.name)
514
- })
515
-
516
- it('should not include documentation button when showDocumentation is false', async () => {
517
- const el = await configuredFixture()
518
- await nextFrame()
519
- await aTimeout(100)
520
-
521
- // Access the private method through bracket notation
522
- const functionSchema = sampleFunctionSchemas[0]
523
- const infoElement = el['createFunctionInfoElement'](functionSchema)
524
-
525
- // Should not contain a documentation button when showDocumentation is false
526
- const docButton = infoElement.querySelector('.documentation-button')
527
- assert.notExists(docButton)
528
- })
529
- })
530
-
531
- describe('CodeMirror Integration', () => {
532
- it('should initialize CodeMirror editor', async () => {
533
- const el = await basicFixture()
534
- await nextFrame()
535
-
536
- // Wait for CodeMirror to initialize
537
- await aTimeout(100)
538
-
539
- const editorContainer = el.shadowRoot!.querySelector('.editor-container')
540
- assert.exists(editorContainer)
541
-
542
- // CodeMirror should create a .cm-editor element
543
- const cmEditor = editorContainer!.querySelector('.cm-editor')
544
- assert.exists(cmEditor)
545
- })
546
- })
547
-
548
- describe('Accessibility Features', () => {
549
- it('should have proper ARIA attributes', async () => {
550
- const el = await configuredFixture()
551
- await el.updateComplete
552
-
553
- // Wait for CodeMirror to initialize
554
- await aTimeout(100)
555
-
556
- // Test that the element has proper accessibility setup
557
- assert.isTrue(el.shadowRoot!.delegatesFocus)
558
- })
559
-
560
- // This test is skipped because it fails in the CI environment
561
- // but it works fine locally.
562
- it.skip('should be keyboard navigable', async () => {
563
- const el = await basicFixture()
564
- await nextFrame()
565
-
566
- // Element should be focusable
567
- el.focus()
568
- await nextFrame()
569
-
570
- const surface = el.shadowRoot!.querySelector('.surface')
571
- assert.isTrue(surface!.classList.contains('has-focus'))
572
- })
573
- })
574
- })