@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,994 +0,0 @@
1
- import {
2
- DataSteps,
3
- FlowResponseDataEnum,
4
- FlowSourceEnum,
5
- TransformationSteps,
6
- HttpAssertions as CoreAssertions,
7
- IHttpStep,
8
- } from '@api-client/core/browser.js'
9
- import { assert, fixture, html } from '@open-wc/testing'
10
- import { resetMouse, setViewport } from '@web/test-runner-commands'
11
- import sinon from 'sinon'
12
- import type HttpAssertionsElement from '../../../src/elements/http/HttpAssertions.element.js'
13
- import type UiChip from '../../../src/md/chip/internals/Chip.js'
14
- import type Input from '../../../src/md/input/Input.js'
15
- import { UiMock } from '../../helpers/UiMock.js'
16
- import '../../../src/define/http/http-assertions.js'
17
-
18
- describe('element', () => {
19
- describe('http', () => {
20
- before(async () => {
21
- await setViewport({ width: 1920, height: 1080 })
22
- })
23
-
24
- describe('HttpAssertions', () => {
25
- async function basicFixture(): Promise<HttpAssertionsElement> {
26
- return fixture(html`<http-assertions></http-assertions>`)
27
- }
28
-
29
- describe('initialization', () => {
30
- it('has no assertions UI', async () => {
31
- const editor = await basicFixture()
32
- const nodes = editor.shadowRoot!.querySelectorAll('.param-row')
33
- assert.lengthOf(nodes, 0, 'has no param-row nodes')
34
- })
35
-
36
- it('has the assertion options panel', async () => {
37
- const editor = await basicFixture()
38
- const node = editor.shadowRoot!.querySelector('.options')
39
- assert.ok(node)
40
- })
41
-
42
- it('has the empty message rendered', async () => {
43
- const editor = await basicFixture()
44
- const node = editor.shadowRoot!.querySelector('.empty-message')!
45
- assert.ok(node, 'has the node')
46
- assert.equal(node.textContent?.trim(), 'No assertions added')
47
- })
48
- })
49
-
50
- describe('addAssertion()', () => {
51
- it('adds a new assertions', async () => {
52
- const editor = await basicFixture()
53
- editor.addAssertion()
54
- assert.lengthOf(editor.model, 1, 'has the added assertions')
55
- const [info] = editor.model
56
- assert.isTrue(info.enabled, 'the assertion is enabled by default')
57
- assert.isUndefined(info.description, 'the assertion has no description')
58
- assert.deepEqual(info.steps, [], 'the assertion has empty steps')
59
- })
60
-
61
- it('does not notify change when adding an empty assertion', async () => {
62
- const editor = await basicFixture()
63
- const spy = sinon.spy()
64
- editor.addEventListener('change', spy)
65
- editor.addAssertion()
66
- assert.isFalse(spy.called)
67
- })
68
-
69
- it('schedules an update', async () => {
70
- const editor = await basicFixture()
71
- editor.addAssertion()
72
- assert.isTrue(editor.isUpdatePending)
73
- })
74
-
75
- it('renders the assertion', async () => {
76
- const editor = await basicFixture()
77
- editor.addAssertion()
78
- await editor.updateComplete
79
- const nodes = editor.shadowRoot!.querySelectorAll('.param-row')
80
- assert.lengthOf(nodes, 1)
81
- })
82
-
83
- it('adds the assertion when clicking on the add button', async () => {
84
- const editor = await basicFixture()
85
- const button = editor.shadowRoot!.querySelector('.editor-actions .add-button') as HTMLElement
86
- assert.ok(button, 'has the button')
87
- button.click()
88
- assert.lengthOf(editor.model, 1, 'has the added assertions')
89
- })
90
- })
91
-
92
- describe('removeAssertion()', () => {
93
- let editor: HttpAssertionsElement
94
- beforeEach(async () => {
95
- editor = await basicFixture()
96
- editor.addAssertion()
97
- })
98
-
99
- it('removes the assertion', () => {
100
- editor.removeAssertion(0)
101
- assert.deepEqual(editor.model, [])
102
- })
103
-
104
- it('throws when the index is out of bounds', () => {
105
- assert.throws(
106
- () => {
107
- editor.removeAssertion(1)
108
- },
109
- RangeError,
110
- 'Invalid index: 1'
111
- )
112
- })
113
-
114
- it('removes the specific assertion', () => {
115
- editor.addAssertion()
116
- editor.addAssertion()
117
- editor.model[0].description = '0'
118
- editor.model[1].description = '1'
119
- editor.model[2].description = '2'
120
- editor.removeAssertion(1)
121
- assert.deepEqual(editor.model[0].description, '0')
122
- assert.deepEqual(editor.model[1].description, '2')
123
- })
124
-
125
- it('notifies about the change', async () => {
126
- const spy = sinon.spy()
127
- editor.addEventListener('change', spy)
128
- editor.removeAssertion(0)
129
- assert.isTrue(spy.calledOnce)
130
- })
131
-
132
- it('schedules an update', async () => {
133
- editor.removeAssertion(0)
134
- assert.isTrue(editor.isUpdatePending)
135
- })
136
-
137
- it('removes the assertion when clicking on the delete button', async () => {
138
- const button = editor.shadowRoot!.querySelector('.param-row .delete-button') as HTMLElement
139
- assert.ok(button, 'has the button')
140
- button.click()
141
- await editor.updateComplete
142
- assert.deepEqual(editor.model, [], 'model is empty')
143
- const nodes = editor.shadowRoot!.querySelectorAll('.param-row')
144
- assert.lengthOf(nodes, 0, 'Has no rows rendered')
145
- })
146
- })
147
-
148
- describe('toggleAssertion()', () => {
149
- let editor: HttpAssertionsElement
150
- beforeEach(async () => {
151
- editor = await basicFixture()
152
- editor.addAssertion()
153
- })
154
-
155
- it('toggle the assertion', () => {
156
- editor.toggleAssertion(0, false)
157
- assert.isFalse(editor.model[0].enabled)
158
- })
159
-
160
- it('throws when the index is out of bounds', () => {
161
- assert.throws(
162
- () => {
163
- editor.toggleAssertion(1, false)
164
- },
165
- RangeError,
166
- 'Invalid index: 1'
167
- )
168
- })
169
-
170
- it('notifies about the change', async () => {
171
- const spy = sinon.spy()
172
- editor.addEventListener('change', spy)
173
- editor.toggleAssertion(0, false)
174
- assert.isTrue(spy.calledOnce)
175
- })
176
-
177
- it('schedules an update', async () => {
178
- editor.toggleAssertion(0, false)
179
- assert.isTrue(editor.isUpdatePending)
180
- })
181
-
182
- it('toggles the assertion when clicking on the toggle button', async () => {
183
- const button = editor.shadowRoot!.querySelector('.param-row .toggle-button') as HTMLElement
184
- assert.ok(button, 'has the button')
185
- button.click()
186
- assert.isFalse(editor.model[0].enabled)
187
- })
188
- })
189
-
190
- describe('Data source chips', () => {
191
- describe('chips rendering', () => {
192
- let editor: HttpAssertionsElement
193
- beforeEach(async () => {
194
- editor = await basicFixture()
195
- editor.addAssertion()
196
- })
197
-
198
- it('renders the status code', () => {
199
- const chip = editor.shadowRoot!.querySelector(
200
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.status}"]`
201
- ) as UiChip
202
- assert.ok(chip, 'has the chip')
203
- assert.equal(chip.dataset.group, 'data-source', 'has the group')
204
- assert.equal(chip.dataset.source, FlowSourceEnum.response, 'has the source')
205
- assert.equal(chip.innerText.trim(), 'Status code', 'has the label')
206
- assert.isTrue(chip.draggable, 'the chip is draggable')
207
- })
208
-
209
- it('renders the response headers', () => {
210
- const chip = editor.shadowRoot!.querySelector(
211
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.headers}"]`
212
- ) as UiChip
213
- assert.ok(chip, 'has the chip')
214
- assert.equal(chip.dataset.group, 'data-source', 'has the group')
215
- assert.equal(chip.dataset.source, FlowSourceEnum.response, 'has the source')
216
- assert.equal(chip.innerText.trim(), 'Response headers', 'has the label')
217
- assert.isTrue(chip.draggable, 'the chip is draggable')
218
- })
219
-
220
- it('renders the response body', () => {
221
- const chip = editor.shadowRoot!.querySelector(
222
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.body}"]`
223
- ) as UiChip
224
- assert.ok(chip, 'has the chip')
225
- assert.equal(chip.dataset.group, 'data-source', 'has the group')
226
- assert.equal(chip.dataset.source, FlowSourceEnum.response, 'has the source')
227
- assert.equal(chip.innerText.trim(), 'Response body', 'has the label')
228
- assert.isTrue(chip.draggable, 'the chip is draggable')
229
- })
230
-
231
- it('renders the status message', () => {
232
- const chip = editor.shadowRoot!.querySelector(
233
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.statusText}"]`
234
- ) as UiChip
235
- assert.ok(chip, 'has the chip')
236
- assert.equal(chip.dataset.group, 'data-source', 'has the group')
237
- assert.equal(chip.dataset.source, FlowSourceEnum.response, 'has the source')
238
- assert.equal(chip.innerText.trim(), 'Status message', 'has the label')
239
- assert.isTrue(chip.draggable, 'the chip is draggable')
240
- })
241
- })
242
-
243
- describe('drag and drop', () => {
244
- let editor: HttpAssertionsElement
245
- beforeEach(async () => {
246
- editor = await basicFixture()
247
- editor.addAssertion()
248
- })
249
-
250
- afterEach(async () => {
251
- await resetMouse()
252
- })
253
-
254
- it('drops the status code source onto an assertion field', async () => {
255
- const chip = editor.shadowRoot!.querySelector(
256
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.status}"]`
257
- ) as UiChip
258
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
259
- await UiMock.dragAndDrop(chip, target)
260
- await editor.updateComplete
261
-
262
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
263
- const step = editor.model[0].steps[0] as DataSteps.IReadDataSourceStep
264
-
265
- assert.equal(step.kind, DataSteps.ReadDataSourceStepKind, 'has the kind')
266
- assert.equal(step.source, FlowSourceEnum.response, 'has the source')
267
- assert.equal(step.data, FlowResponseDataEnum.status, 'has the data')
268
-
269
- const unit = target.querySelector('.step-unit')!
270
- assert.ok(unit, 'renders the step container')
271
- const spacer = unit.querySelector('.drop-target.spacer')!
272
- assert.ok(spacer, 'renders the drop target')
273
- const pill = unit.querySelector('.step-pill')!
274
- assert.ok(pill, 'renders the data pill')
275
- assert.equal(pill.textContent?.trim(), 'Status code', 'renders the data pill value')
276
- assert.isTrue(spacer.nextElementSibling === pill, 'render the drop target before the pill')
277
- })
278
-
279
- it('drops the status message source onto an assertion field', async () => {
280
- const chip = editor.shadowRoot!.querySelector(
281
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.statusText}"]`
282
- ) as UiChip
283
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
284
- await UiMock.dragAndDrop(chip, target)
285
- await editor.updateComplete
286
-
287
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
288
- const step = editor.model[0].steps[0] as DataSteps.IReadDataSourceStep
289
-
290
- assert.equal(step.kind, DataSteps.ReadDataSourceStepKind, 'has the kind')
291
- assert.equal(step.source, FlowSourceEnum.response, 'has the source')
292
- assert.equal(step.data, FlowResponseDataEnum.statusText, 'has the data')
293
-
294
- const unit = target.querySelector('.step-unit')!
295
- assert.ok(unit, 'renders the step container')
296
- const spacer = unit.querySelector('.drop-target.spacer')!
297
- assert.ok(spacer, 'renders the drop target')
298
- const pill = unit.querySelector('.step-pill')!
299
- assert.ok(pill, 'renders the data pill')
300
- assert.equal(pill.textContent?.trim(), 'Status message', 'renders the data pill value')
301
- assert.isTrue(spacer.nextElementSibling === pill, 'render the drop target before the pill')
302
- })
303
-
304
- it('drops the status message source onto an assertion field', async () => {
305
- const chip = editor.shadowRoot!.querySelector(
306
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.headers}"]`
307
- ) as UiChip
308
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
309
- await UiMock.dragAndDrop(chip, target)
310
- await editor.updateComplete
311
-
312
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
313
- const step = editor.model[0].steps[0] as DataSteps.IReadDataSourceStep
314
-
315
- assert.equal(step.kind, DataSteps.ReadDataSourceStepKind, 'has the kind')
316
- assert.equal(step.source, FlowSourceEnum.response, 'has the source')
317
- assert.equal(step.data, FlowResponseDataEnum.headers, 'has the data')
318
-
319
- const unit = target.querySelector('.step-unit')!
320
- assert.ok(unit, 'renders the step container')
321
- const spacer = unit.querySelector('.drop-target.spacer')!
322
- assert.ok(spacer, 'renders the drop target')
323
- const pill = unit.querySelector('.step-pill')!
324
- assert.ok(pill, 'renders the data pill')
325
- assert.equal(pill.textContent?.trim(), 'Response headers', 'renders the data pill value')
326
- assert.isTrue(spacer.nextElementSibling === pill, 'render the drop target before the pill')
327
- })
328
-
329
- it('drops the status message source onto an assertion field', async () => {
330
- const chip = editor.shadowRoot!.querySelector(
331
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.body}"]`
332
- ) as UiChip
333
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
334
- await UiMock.dragAndDrop(chip, target)
335
- await editor.updateComplete
336
-
337
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
338
- const step = editor.model[0].steps[0] as DataSteps.IReadDataSourceStep
339
-
340
- assert.equal(step.kind, DataSteps.ReadDataSourceStepKind, 'has the kind')
341
- assert.equal(step.source, FlowSourceEnum.response, 'has the source')
342
- assert.equal(step.data, FlowResponseDataEnum.body, 'has the data')
343
-
344
- const unit = target.querySelector('.step-unit')!
345
- assert.ok(unit, 'renders the step container')
346
- const spacer = unit.querySelector('.drop-target.spacer')!
347
- assert.ok(spacer, 'renders the drop target')
348
- const pill = unit.querySelector('.step-pill')!
349
- assert.ok(pill, 'renders the data pill')
350
- assert.equal(pill.textContent?.trim(), 'Response body', 'renders the data pill value')
351
- assert.isTrue(spacer.nextElementSibling === pill, 'render the drop target before the pill')
352
- })
353
-
354
- it('drops the data source onto a drop target', async () => {
355
- editor.model = [
356
- {
357
- steps: [new DataSteps.ReadValueStep().toJSON(), new CoreAssertions.EqualAssertion().toJSON()],
358
- },
359
- ]
360
- await editor.updateComplete
361
- const chip = editor.shadowRoot!.querySelector(
362
- `ui-chip[data-kind="${DataSteps.ReadDataSourceStepKind}"][data-data="${FlowResponseDataEnum.status}"]`
363
- ) as UiChip
364
- const target = editor.shadowRoot!.querySelector(`.param-row .steps [data-step-index="0"]`) as HTMLElement
365
- await UiMock.dragAndDrop(chip, target)
366
- await editor.updateComplete
367
-
368
- assert.lengthOf(editor.model[0].steps, 3, 'has the added step')
369
- const step = editor.model[0].steps[0] as DataSteps.IReadDataSourceStep
370
-
371
- assert.equal(step.kind, DataSteps.ReadDataSourceStepKind, 'puts the added step at the position')
372
- })
373
- })
374
- })
375
-
376
- describe('Transformation chips', () => {
377
- describe('chips rendering', () => {
378
- let editor: HttpAssertionsElement
379
- beforeEach(async () => {
380
- editor = await basicFixture()
381
- editor.addAssertion()
382
- })
383
-
384
- it('renders the read value', () => {
385
- const chip = editor.shadowRoot!.querySelector(
386
- `ui-chip[data-kind="${DataSteps.ReadValueStepKind}"]`
387
- ) as UiChip
388
- assert.ok(chip, 'has the chip')
389
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
390
- assert.notOk(chip.dataset.variant, 'has no variant')
391
- assert.equal(chip.innerText.trim(), 'Read value', 'has the label')
392
- assert.isTrue(chip.draggable, 'the chip is draggable')
393
- })
394
-
395
- it('renders the as number', () => {
396
- const chip = editor.shadowRoot!.querySelector(
397
- `ui-chip[data-kind="${TransformationSteps.AsNumberStepKind}"]`
398
- ) as UiChip
399
- assert.ok(chip, 'has the chip')
400
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
401
- assert.notOk(chip.dataset.variant, 'has no variant')
402
- assert.equal(chip.innerText.trim(), 'As number', 'has the label')
403
- assert.isTrue(chip.draggable, 'the chip is draggable')
404
- })
405
-
406
- it('renders the round', () => {
407
- const chip = editor.shadowRoot!.querySelector(
408
- `ui-chip[data-kind="${TransformationSteps.RoundStepKind}"]`
409
- ) as UiChip
410
- assert.ok(chip, 'has the chip')
411
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
412
- assert.notOk(chip.dataset.variant, 'has no variant')
413
- assert.equal(chip.innerText.trim(), 'Round', 'has the label')
414
- assert.isTrue(chip.draggable, 'the chip is draggable')
415
- })
416
-
417
- it('renders the to lower case', () => {
418
- const chip = editor.shadowRoot!.querySelector(
419
- `ui-chip[data-kind="${TransformationSteps.AsLowerCaseStepKind}"]`
420
- ) as UiChip
421
- assert.ok(chip, 'has the chip')
422
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
423
- assert.notOk(chip.dataset.variant, 'has no variant')
424
- assert.equal(chip.innerText.trim(), 'To lower case', 'has the label')
425
- assert.isTrue(chip.draggable, 'the chip is draggable')
426
- })
427
-
428
- it('renders the to upper case', () => {
429
- const chip = editor.shadowRoot!.querySelector(
430
- `ui-chip[data-kind="${TransformationSteps.AsUpperCaseStepKind}"]`
431
- ) as UiChip
432
- assert.ok(chip, 'has the chip')
433
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
434
- assert.notOk(chip.dataset.variant, 'has no variant')
435
- assert.equal(chip.innerText.trim(), 'To upper case', 'has the label')
436
- assert.isTrue(chip.draggable, 'the chip is draggable')
437
- })
438
-
439
- it('renders the trim', () => {
440
- const chip = editor.shadowRoot!.querySelector(
441
- `ui-chip[data-kind="${TransformationSteps.TrimStepKind}"]`
442
- ) as UiChip
443
- assert.ok(chip, 'has the chip')
444
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
445
- assert.notOk(chip.dataset.variant, 'has no variant')
446
- assert.equal(chip.innerText.trim(), 'Trim', 'has the label')
447
- assert.isTrue(chip.draggable, 'the chip is draggable')
448
- })
449
-
450
- it('renders the substring', () => {
451
- const chip = editor.shadowRoot!.querySelector(
452
- `ui-chip[data-kind="${TransformationSteps.SubstringStepKind}"]`
453
- ) as UiChip
454
- assert.ok(chip, 'has the chip')
455
- assert.equal(chip.dataset.group, 'transformation', 'has the group')
456
- assert.notOk(chip.dataset.variant, 'has no variant')
457
- assert.equal(chip.innerText.trim(), 'Substring', 'has the label')
458
- assert.isTrue(chip.draggable, 'the chip is draggable')
459
- })
460
- })
461
-
462
- describe('drag and drop', () => {
463
- let editor: HttpAssertionsElement
464
- beforeEach(async () => {
465
- editor = await basicFixture()
466
- editor.addAssertion()
467
- })
468
-
469
- afterEach(async () => {
470
- await resetMouse()
471
- })
472
-
473
- it('drops the read value onto an assertion field', async () => {
474
- const chip = editor.shadowRoot!.querySelector(
475
- `ui-chip[data-kind="${DataSteps.ReadValueStepKind}"]`
476
- ) as UiChip
477
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
478
- await UiMock.dragAndDrop(chip, target)
479
- await editor.updateComplete
480
-
481
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
482
- const step = editor.model[0].steps[0] as DataSteps.IReadValueStep
483
-
484
- assert.equal(step.kind, DataSteps.ReadValueStepKind, 'has the kind')
485
- })
486
-
487
- it('drops the as number value onto an assertion field', async () => {
488
- const chip = editor.shadowRoot!.querySelector(
489
- `ui-chip[data-kind="${TransformationSteps.AsNumberStepKind}"]`
490
- ) as UiChip
491
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
492
- await UiMock.dragAndDrop(chip, target)
493
- await editor.updateComplete
494
-
495
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
496
- const step = editor.model[0].steps[0] as TransformationSteps.IAsNumberStep
497
-
498
- assert.equal(step.kind, TransformationSteps.AsNumberStepKind, 'has the kind')
499
- })
500
-
501
- it('drops the round onto an assertion field', async () => {
502
- const chip = editor.shadowRoot!.querySelector(
503
- `ui-chip[data-kind="${TransformationSteps.RoundStepKind}"]`
504
- ) as UiChip
505
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
506
- await UiMock.dragAndDrop(chip, target)
507
- await editor.updateComplete
508
-
509
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
510
- const step = editor.model[0].steps[0] as TransformationSteps.IRoundStep
511
-
512
- assert.equal(step.kind, TransformationSteps.RoundStepKind, 'has the kind')
513
- })
514
-
515
- it('drops the as lower case onto an assertion field', async () => {
516
- const chip = editor.shadowRoot!.querySelector(
517
- `ui-chip[data-kind="${TransformationSteps.AsLowerCaseStepKind}"]`
518
- ) as UiChip
519
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
520
- await UiMock.dragAndDrop(chip, target)
521
- await editor.updateComplete
522
-
523
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
524
- const step = editor.model[0].steps[0] as TransformationSteps.IAsLowerCaseStep
525
-
526
- assert.equal(step.kind, TransformationSteps.AsLowerCaseStepKind, 'has the kind')
527
- })
528
-
529
- it('drops the as upper case onto an assertion field', async () => {
530
- const chip = editor.shadowRoot!.querySelector(
531
- `ui-chip[data-kind="${TransformationSteps.AsUpperCaseStepKind}"]`
532
- ) as UiChip
533
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
534
- await UiMock.dragAndDrop(chip, target)
535
- await editor.updateComplete
536
-
537
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
538
- const step = editor.model[0].steps[0] as TransformationSteps.IAsUpperCaseStep
539
-
540
- assert.equal(step.kind, TransformationSteps.AsUpperCaseStepKind, 'has the kind')
541
- })
542
-
543
- it('drops the trim onto an assertion field', async () => {
544
- const chip = editor.shadowRoot!.querySelector(
545
- `ui-chip[data-kind="${TransformationSteps.TrimStepKind}"]`
546
- ) as UiChip
547
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
548
- await UiMock.dragAndDrop(chip, target)
549
- await editor.updateComplete
550
-
551
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
552
- const step = editor.model[0].steps[0] as TransformationSteps.ITrimStep
553
-
554
- assert.equal(step.kind, TransformationSteps.TrimStepKind, 'has the kind')
555
- })
556
-
557
- it('drops the substring onto an assertion field', async () => {
558
- const chip = editor.shadowRoot!.querySelector(
559
- `ui-chip[data-kind="${TransformationSteps.SubstringStepKind}"]`
560
- ) as UiChip
561
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
562
- await UiMock.dragAndDrop(chip, target)
563
- await editor.updateComplete
564
-
565
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
566
- const step = editor.model[0].steps[0] as TransformationSteps.ISubstringStep
567
-
568
- assert.equal(step.kind, TransformationSteps.SubstringStepKind, 'has the kind')
569
- })
570
-
571
- it('drops the data source onto a drop target', async () => {
572
- editor.model = [
573
- {
574
- steps: [
575
- new DataSteps.ReadDataSourceStep(FlowSourceEnum.response, FlowResponseDataEnum.headers).toJSON(),
576
- new CoreAssertions.EqualAssertion().toJSON(),
577
- ],
578
- },
579
- ]
580
- await editor.updateComplete
581
- const chip = editor.shadowRoot!.querySelector(
582
- `ui-chip[data-kind="${DataSteps.ReadValueStepKind}"]`
583
- ) as UiChip
584
- const target = editor.shadowRoot!.querySelector(`.param-row .steps [data-step-index="1"]`) as HTMLElement
585
- await UiMock.dragAndDrop(chip, target)
586
- await editor.updateComplete
587
-
588
- assert.lengthOf(editor.model[0].steps, 3, 'has the added step')
589
- const step = editor.model[0].steps[1] as DataSteps.IReadValueStep
590
-
591
- assert.equal(step.kind, DataSteps.ReadValueStepKind, 'puts the added step at the position')
592
- })
593
- })
594
- })
595
-
596
- describe('Assertion chips', () => {
597
- describe('chips rendering', () => {
598
- let editor: HttpAssertionsElement
599
- beforeEach(async () => {
600
- editor = await basicFixture()
601
- editor.addAssertion()
602
- })
603
-
604
- it('renders the Equal assertion', () => {
605
- const chip = editor.shadowRoot!.querySelector(
606
- `ui-chip[data-kind="${CoreAssertions.EqualAssertionKind}"]`
607
- ) as UiChip
608
- assert.ok(chip, 'has the chip')
609
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
610
- assert.notOk(chip.dataset.variant, 'has no variant')
611
- assert.equal(chip.innerText.trim(), 'Equal', 'has the label')
612
- assert.isTrue(chip.draggable, 'the chip is draggable')
613
- })
614
-
615
- it('renders the Not equal assertion', () => {
616
- const chip = editor.shadowRoot!.querySelector(
617
- `ui-chip[data-kind="${CoreAssertions.NotEqualAssertionKind}"]`
618
- ) as UiChip
619
- assert.ok(chip, 'has the chip')
620
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
621
- assert.notOk(chip.dataset.variant, 'has no variant')
622
- assert.equal(chip.innerText.trim(), 'Not equal', 'has the label')
623
- assert.isTrue(chip.draggable, 'the chip is draggable')
624
- })
625
-
626
- it('renders the Greater than assertion', () => {
627
- const chip = editor.shadowRoot!.querySelector(
628
- `ui-chip[data-kind="${CoreAssertions.GreaterThanAssertionKind}"]:not([data-variant])`
629
- ) as UiChip
630
- assert.ok(chip, 'has the chip')
631
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
632
- assert.notOk(chip.dataset.variant, 'has no variant')
633
- assert.equal(chip.innerText.trim(), 'Greater than', 'has the label')
634
- assert.isTrue(chip.draggable, 'the chip is draggable')
635
- })
636
-
637
- it('renders the Greater than equal assertion', () => {
638
- const chip = editor.shadowRoot!.querySelector(
639
- `ui-chip[data-kind="${CoreAssertions.GreaterThanAssertionKind}"][data-variant]`
640
- ) as UiChip
641
- assert.ok(chip, 'has the chip')
642
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
643
- assert.equal(chip.dataset.variant, 'equal', 'has the variant')
644
- assert.equal(chip.innerText.trim(), 'Greater than equal', 'has the label')
645
- assert.isTrue(chip.draggable, 'the chip is draggable')
646
- })
647
-
648
- it('renders the Less than assertion', () => {
649
- const chip = editor.shadowRoot!.querySelector(
650
- `ui-chip[data-kind="${CoreAssertions.LessThanAssertionKind}"]:not([data-variant])`
651
- ) as UiChip
652
- assert.ok(chip, 'has the chip')
653
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
654
- assert.notOk(chip.dataset.variant, 'has no variant')
655
- assert.equal(chip.innerText.trim(), 'Less than', 'has the label')
656
- assert.isTrue(chip.draggable, 'the chip is draggable')
657
- })
658
-
659
- it('renders the Less than equal assertion', () => {
660
- const chip = editor.shadowRoot!.querySelector(
661
- `ui-chip[data-kind="${CoreAssertions.LessThanAssertionKind}"][data-variant]`
662
- ) as UiChip
663
- assert.ok(chip, 'has the chip')
664
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
665
- assert.equal(chip.dataset.variant, 'equal', 'has the variant')
666
- assert.equal(chip.innerText.trim(), 'Less than equal', 'has the label')
667
- assert.isTrue(chip.draggable, 'the chip is draggable')
668
- })
669
-
670
- it('renders the Includes assertion', () => {
671
- const chip = editor.shadowRoot!.querySelector(
672
- `ui-chip[data-kind="${CoreAssertions.IncludesAssertionKind}"]`
673
- ) as UiChip
674
- assert.ok(chip, 'has the chip')
675
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
676
- assert.notOk(chip.dataset.variant, 'has no variant')
677
- assert.equal(chip.innerText.trim(), 'Includes', 'has the label')
678
- assert.isTrue(chip.draggable, 'the chip is draggable')
679
- })
680
-
681
- it('renders the Not includes assertion', () => {
682
- const chip = editor.shadowRoot!.querySelector(
683
- `ui-chip[data-kind="${CoreAssertions.NotIncludesAssertionKind}"]`
684
- ) as UiChip
685
- assert.ok(chip, 'has the chip')
686
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
687
- assert.notOk(chip.dataset.variant, 'has no variant')
688
- assert.equal(chip.innerText.trim(), 'Not includes', 'has the label')
689
- assert.isTrue(chip.draggable, 'the chip is draggable')
690
- })
691
-
692
- it('renders the Matches assertion', () => {
693
- const chip = editor.shadowRoot!.querySelector(
694
- `ui-chip[data-kind="${CoreAssertions.MatchesAssertionKind}"]`
695
- ) as UiChip
696
- assert.ok(chip, 'has the chip')
697
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
698
- assert.notOk(chip.dataset.variant, 'has no variant')
699
- assert.equal(chip.innerText.trim(), 'Matches', 'has the label')
700
- assert.isTrue(chip.draggable, 'the chip is draggable')
701
- })
702
-
703
- it('renders the OK assertion', () => {
704
- const chip = editor.shadowRoot!.querySelector(
705
- `ui-chip[data-kind="${CoreAssertions.OkAssertionKind}"]`
706
- ) as UiChip
707
- assert.ok(chip, 'has the chip')
708
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
709
- assert.notOk(chip.dataset.variant, 'has no variant')
710
- assert.equal(chip.innerText.trim(), 'OK', 'has the label')
711
- assert.isTrue(chip.draggable, 'the chip is draggable')
712
- })
713
-
714
- it('renders the Not OK assertion', () => {
715
- const chip = editor.shadowRoot!.querySelector(
716
- `ui-chip[data-kind="${CoreAssertions.NotOkAssertionKind}"]`
717
- ) as UiChip
718
- assert.ok(chip, 'has the chip')
719
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
720
- assert.notOk(chip.dataset.variant, 'has no variant')
721
- assert.equal(chip.innerText.trim(), 'Not OK', 'has the label')
722
- assert.isTrue(chip.draggable, 'the chip is draggable')
723
- })
724
-
725
- it('renders the To be... assertion', () => {
726
- const chip = editor.shadowRoot!.querySelector(
727
- `ui-chip[data-kind="${CoreAssertions.ToBeAssertionKind}"]`
728
- ) as UiChip
729
- assert.ok(chip, 'has the chip')
730
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
731
- assert.notOk(chip.dataset.variant, 'has no variant')
732
- assert.equal(chip.innerText.trim(), 'To be...', 'has the label')
733
- assert.isTrue(chip.draggable, 'the chip is draggable')
734
- })
735
-
736
- it('renders the Not to be... assertion', () => {
737
- const chip = editor.shadowRoot!.querySelector(
738
- `ui-chip[data-kind="${CoreAssertions.NotToBeAssertionKind}"]`
739
- ) as UiChip
740
- assert.ok(chip, 'has the chip')
741
- assert.equal(chip.dataset.group, 'assertion', 'has the group')
742
- assert.notOk(chip.dataset.variant, 'has no variant')
743
- assert.equal(chip.innerText.trim(), 'Not to be...', 'has the label')
744
- assert.isTrue(chip.draggable, 'the chip is draggable')
745
- })
746
- })
747
-
748
- describe('drag and drop', () => {
749
- let editor: HttpAssertionsElement
750
- beforeEach(async () => {
751
- editor = await basicFixture()
752
- editor.addAssertion()
753
- await editor.updateComplete
754
- })
755
-
756
- afterEach(async () => {
757
- await resetMouse()
758
- })
759
- ;[
760
- CoreAssertions.EqualAssertionKind,
761
- CoreAssertions.NotEqualAssertionKind,
762
- CoreAssertions.IncludesAssertionKind,
763
- CoreAssertions.NotIncludesAssertionKind,
764
- CoreAssertions.MatchesAssertionKind,
765
- CoreAssertions.OkAssertionKind,
766
- CoreAssertions.NotOkAssertionKind,
767
- CoreAssertions.ToBeAssertionKind,
768
- CoreAssertions.NotToBeAssertionKind,
769
- ].forEach((kind) => {
770
- it(`drops the ${kind} onto an assertion field`, async () => {
771
- const chip = editor.shadowRoot!.querySelector(`ui-chip[data-kind="${kind}"]`) as UiChip
772
- const target = editor.shadowRoot!.querySelector(`.param-row .steps`) as HTMLElement
773
- await UiMock.dragAndDrop(chip, target)
774
- await editor.updateComplete
775
-
776
- assert.lengthOf(editor.model[0].steps, 1, 'has added step')
777
- const step = editor.model[0].steps[0] as IHttpStep
778
-
779
- assert.equal(step.kind, kind, 'has the kind')
780
- })
781
- })
782
-
783
- it('drops the data source onto a drop target', async () => {
784
- editor.model = [
785
- {
786
- steps: [
787
- new DataSteps.ReadDataSourceStep(FlowSourceEnum.response, FlowResponseDataEnum.headers).toJSON(),
788
- new CoreAssertions.EqualAssertion().toJSON(),
789
- ],
790
- },
791
- ]
792
- await editor.updateComplete
793
- const chip = editor.shadowRoot!.querySelector(
794
- `ui-chip[data-kind="${CoreAssertions.EqualAssertionKind}"]`
795
- ) as UiChip
796
- const target = editor.shadowRoot!.querySelector(`.param-row .steps [data-step-index="1"]`) as HTMLElement
797
- await UiMock.dragAndDrop(chip, target)
798
- await editor.updateComplete
799
-
800
- assert.lengthOf(editor.model[0].steps, 3, 'has the added step')
801
- const step = editor.model[0].steps[1] as CoreAssertions.IEqualAssertion
802
-
803
- assert.equal(step.kind, CoreAssertions.EqualAssertionKind, 'puts the added step at the position')
804
- })
805
- })
806
-
807
- describe('updating values', () => {
808
- let editor: HttpAssertionsElement
809
- beforeEach(async () => {
810
- editor = await basicFixture()
811
- editor.addAssertion()
812
- })
813
-
814
- it('updates the value of the equal assertion', async () => {
815
- editor.model = [
816
- {
817
- steps: [new CoreAssertions.EqualAssertion().toJSON()],
818
- },
819
- ]
820
- await editor.updateComplete
821
- const spy = sinon.spy()
822
- editor.addEventListener('change', spy)
823
- const input = editor.shadowRoot!.querySelector(
824
- `ui-filled-text-field[data-kind="${CoreAssertions.EqualAssertionKind}"]`
825
- ) as Input
826
- input.value = 'test value'
827
- input.dispatchEvent(new Event('change'))
828
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
829
- const step = editor.model[0].steps[0] as CoreAssertions.IEqualAssertion
830
- assert.equal(step.value, 'test value')
831
- })
832
-
833
- it('updates the value of the not equal assertion', async () => {
834
- editor.model = [
835
- {
836
- steps: [new CoreAssertions.NotEqualAssertion().toJSON()],
837
- },
838
- ]
839
- await editor.updateComplete
840
- const spy = sinon.spy()
841
- editor.addEventListener('change', spy)
842
- const input = editor.shadowRoot!.querySelector(
843
- `ui-filled-text-field[data-kind="${CoreAssertions.NotEqualAssertionKind}"]`
844
- ) as Input
845
- input.value = 'test value'
846
- input.dispatchEvent(new Event('change'))
847
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
848
- const step = editor.model[0].steps[0] as CoreAssertions.INotEqualAssertion
849
- assert.equal(step.value, 'test value')
850
- })
851
-
852
- it('updates the value of the includes assertion', async () => {
853
- editor.model = [
854
- {
855
- steps: [new CoreAssertions.IncludesAssertion().toJSON()],
856
- },
857
- ]
858
- await editor.updateComplete
859
- const spy = sinon.spy()
860
- editor.addEventListener('change', spy)
861
- const input = editor.shadowRoot!.querySelector(
862
- `ui-filled-text-field[data-kind="${CoreAssertions.IncludesAssertionKind}"]`
863
- ) as Input
864
- input.value = 'test value'
865
- input.dispatchEvent(new Event('change'))
866
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
867
- const step = editor.model[0].steps[0] as CoreAssertions.IIncludesAssertion
868
- assert.equal(step.value, 'test value')
869
- })
870
-
871
- it('updates the value of the not includes assertion', async () => {
872
- editor.model = [
873
- {
874
- steps: [new CoreAssertions.NotIncludesAssertion().toJSON()],
875
- },
876
- ]
877
- await editor.updateComplete
878
- const spy = sinon.spy()
879
- editor.addEventListener('change', spy)
880
- const input = editor.shadowRoot!.querySelector(
881
- `ui-filled-text-field[data-kind="${CoreAssertions.NotIncludesAssertionKind}"]`
882
- ) as Input
883
-
884
- input.value = 'test value'
885
- input.dispatchEvent(new Event('change'))
886
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
887
- const step = editor.model[0].steps[0] as CoreAssertions.INotIncludesAssertion
888
- assert.equal(step.value, 'test value')
889
- })
890
-
891
- it('updates the value of the matches assertion', async () => {
892
- editor.model = [
893
- {
894
- steps: [new CoreAssertions.MatchesAssertion().toJSON()],
895
- },
896
- ]
897
- await editor.updateComplete
898
- const spy = sinon.spy()
899
- editor.addEventListener('change', spy)
900
- const input = editor.shadowRoot!.querySelector(
901
- `ui-filled-text-field[data-kind="${CoreAssertions.MatchesAssertionKind}"]`
902
- ) as Input
903
-
904
- input.value = 'test value'
905
- input.dispatchEvent(new Event('change'))
906
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
907
- const step = editor.model[0].steps[0] as CoreAssertions.IMatchesAssertion
908
- assert.equal(step.value, 'test value')
909
- })
910
-
911
- it('updates the value of the to be assertion', async () => {
912
- editor.model = [
913
- {
914
- steps: [new CoreAssertions.ToBeAssertion().toJSON()],
915
- },
916
- ]
917
- await editor.updateComplete
918
- const spy = sinon.spy()
919
- editor.addEventListener('change', spy)
920
- const input = editor.shadowRoot!.querySelector(
921
- `ui-filled-text-field[data-kind="${CoreAssertions.ToBeAssertionKind}"]`
922
- ) as Input
923
-
924
- input.value = 'test value'
925
- input.dispatchEvent(new Event('change'))
926
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
927
- const step = editor.model[0].steps[0] as CoreAssertions.IToBeAssertion
928
- assert.equal(step.value, 'test value')
929
- })
930
-
931
- it('updates the value of the not to be assertion', async () => {
932
- editor.model = [
933
- {
934
- steps: [new CoreAssertions.NotToBeAssertion().toJSON()],
935
- },
936
- ]
937
- await editor.updateComplete
938
- const spy = sinon.spy()
939
- editor.addEventListener('change', spy)
940
- const input = editor.shadowRoot!.querySelector(
941
- `ui-filled-text-field[data-kind="${CoreAssertions.NotToBeAssertionKind}"]`
942
- ) as Input
943
-
944
- input.value = 'test value'
945
- input.dispatchEvent(new Event('change'))
946
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
947
- const step = editor.model[0].steps[0] as CoreAssertions.INotToBeAssertion
948
- assert.equal(step.value, 'test value')
949
- })
950
-
951
- it('updates the value of the greater than be assertion', async () => {
952
- editor.model = [
953
- {
954
- steps: [new CoreAssertions.GreaterThanAssertion().toJSON()],
955
- },
956
- ]
957
- await editor.updateComplete
958
- const spy = sinon.spy()
959
- editor.addEventListener('change', spy)
960
- const input = editor.shadowRoot!.querySelector(
961
- `ui-filled-text-field[data-kind="${CoreAssertions.GreaterThanAssertionKind}"]`
962
- ) as Input
963
-
964
- input.value = '20'
965
- input.dispatchEvent(new Event('change'))
966
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
967
- const step = editor.model[0].steps[0] as CoreAssertions.IGreaterThanAssertion
968
- assert.equal(step.value, 20)
969
- })
970
-
971
- it('updates the value of the less than be assertion', async () => {
972
- editor.model = [
973
- {
974
- steps: [new CoreAssertions.LessThanAssertion().toJSON()],
975
- },
976
- ]
977
- await editor.updateComplete
978
- const spy = sinon.spy()
979
- editor.addEventListener('change', spy)
980
- const input = editor.shadowRoot!.querySelector(
981
- `ui-filled-text-field[data-kind="${CoreAssertions.LessThanAssertionKind}"]`
982
- ) as Input
983
-
984
- input.value = '20'
985
- input.dispatchEvent(new Event('change'))
986
- assert.isTrue(spy.calledOnce, 'dispatched the change event')
987
- const step = editor.model[0].steps[0] as CoreAssertions.ILessThanAssertion
988
- assert.equal(step.value, 20)
989
- })
990
- })
991
- })
992
- })
993
- })
994
- })