@api-client/ui 0.5.39 → 0.5.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/elements/contextual-menu/{internals/ContextualMenu.d.ts → ContextualMenu.d.ts} +11 -6
- package/build/src/elements/contextual-menu/ContextualMenu.d.ts.map +1 -0
- package/build/src/elements/contextual-menu/{internals/ContextualMenu.js → ContextualMenu.js} +25 -3
- package/build/src/elements/contextual-menu/ContextualMenu.js.map +1 -0
- package/build/src/elements/contextual-menu/internals/types.d.ts +16 -7
- package/build/src/elements/contextual-menu/internals/types.d.ts.map +1 -1
- package/build/src/elements/contextual-menu/internals/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/elements/contextual-menu/{internals/ContextualMenu.ts → ContextualMenu.ts} +31 -7
- package/src/elements/contextual-menu/internals/types.ts +17 -7
- package/.aiexclude +0 -3
- package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
- package/.cursor/rules/lit-best-practices.mdc +0 -89
- package/.editorconfig +0 -29
- package/.github/CONTRIBUTING.md +0 -24
- package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
- package/.github/instructions/lit-best-practices.instructions.md +0 -90
- package/.github/release.yml +0 -14
- package/.github/stale.yml +0 -23
- package/.github/workflows/auto-release.yml +0 -182
- package/.github/workflows/release.yml +0 -82
- package/.prettierrc.js +0 -14
- package/.vscode/settings.json +0 -18
- package/RELEASE.md +0 -163
- package/RELEASE_SETUP.md +0 -235
- package/build/src/demo/DemoPage.d.ts +0 -81
- package/build/src/demo/DemoPage.d.ts.map +0 -1
- package/build/src/demo/DemoPage.js +0 -175
- package/build/src/demo/DemoPage.js.map +0 -1
- package/build/src/demo/DemoStyles.d.ts +0 -3
- package/build/src/demo/DemoStyles.d.ts.map +0 -1
- package/build/src/demo/DemoStyles.js +0 -60
- package/build/src/demo/DemoStyles.js.map +0 -1
- package/build/src/elements/contextual-menu/internals/ContextualMenu.d.ts.map +0 -1
- package/build/src/elements/contextual-menu/internals/ContextualMenu.js.map +0 -1
- package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
- package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
- package/build/test/elements/navigation/Navigation.test.js +0 -113
- package/build/test/elements/navigation/Navigation.test.js.map +0 -1
- package/commitlint.config.cjs +0 -2
- package/demo/elements/authorization/AuthPlugin.js +0 -57
- package/demo/elements/authorization/AuthProxy.js +0 -215
- package/demo/elements/authorization/api-key.html +0 -27
- package/demo/elements/authorization/api-key.ts +0 -44
- package/demo/elements/authorization/basic.html +0 -27
- package/demo/elements/authorization/basic.ts +0 -43
- package/demo/elements/authorization/bearer.html +0 -27
- package/demo/elements/authorization/bearer.ts +0 -43
- package/demo/elements/authorization/env.js +0 -8
- package/demo/elements/authorization/index.html +0 -44
- package/demo/elements/authorization/ntlm.html +0 -27
- package/demo/elements/authorization/ntlm.ts +0 -43
- package/demo/elements/authorization/oauth-authorize.html +0 -75
- package/demo/elements/authorization/oauth-authorize.ts +0 -40
- package/demo/elements/authorization/oauth-error.html +0 -18
- package/demo/elements/authorization/oauth-error.ts +0 -10
- package/demo/elements/authorization/oauth-popup.html +0 -36
- package/demo/elements/authorization/oauth2.html +0 -27
- package/demo/elements/authorization/oauth2.ts +0 -100
- package/demo/elements/authorization/oidc.html +0 -27
- package/demo/elements/authorization/oidc.ts +0 -139
- package/demo/elements/authorization/private.crt +0 -31
- package/demo/elements/authorization/private.csr +0 -28
- package/demo/elements/authorization/private.key +0 -51
- package/demo/elements/authorization/private.pem +0 -31
- package/demo/elements/authorization/redirect.html +0 -20
- package/demo/elements/authorization/ssl-commands.sh +0 -30
- package/demo/elements/authorization/ssl.conf +0 -24
- package/demo/elements/autocomplete/index.html +0 -64
- package/demo/elements/autocomplete/index.ts +0 -171
- package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
- package/demo/elements/code-editor/index.html +0 -19
- package/demo/elements/context-menu/DemoIcons.ts +0 -21
- package/demo/elements/context-menu/basic.html +0 -25
- package/demo/elements/context-menu/basic.ts +0 -119
- package/demo/elements/context-menu/custom-data.html +0 -25
- package/demo/elements/context-menu/custom-data.ts +0 -62
- package/demo/elements/context-menu/demo.css +0 -28
- package/demo/elements/context-menu/enabled-state.html +0 -25
- package/demo/elements/context-menu/enabled-state.ts +0 -73
- package/demo/elements/context-menu/icons.html +0 -25
- package/demo/elements/context-menu/icons.ts +0 -64
- package/demo/elements/context-menu/index.html +0 -43
- package/demo/elements/context-menu/nested.html +0 -25
- package/demo/elements/context-menu/nestedt.ts +0 -152
- package/demo/elements/context-menu/no-execute.html +0 -25
- package/demo/elements/context-menu/no-execute.ts +0 -134
- package/demo/elements/context-menu/radio-menu.html +0 -25
- package/demo/elements/context-menu/radio-menu.ts +0 -83
- package/demo/elements/context-menu/separators.html +0 -25
- package/demo/elements/context-menu/separators.ts +0 -172
- package/demo/elements/currency/index.html +0 -91
- package/demo/elements/currency/index.ts +0 -352
- package/demo/elements/environment/environment-editor.html +0 -20
- package/demo/elements/environment/environment-editor.ts +0 -49
- package/demo/elements/environment/index.html +0 -33
- package/demo/elements/environment/server-editor.html +0 -20
- package/demo/elements/environment/server-editor.ts +0 -67
- package/demo/elements/environment/variables-editor.html +0 -20
- package/demo/elements/environment/variables-editor.ts +0 -94
- package/demo/elements/har/har-viewer.html +0 -20
- package/demo/elements/har/har-viewer.ts +0 -76
- package/demo/elements/har/har1.har +0 -3044
- package/demo/elements/har/har2.json +0 -439
- package/demo/elements/har/index.html +0 -26
- package/demo/elements/highlight/example.md +0 -27
- package/demo/elements/highlight/index.html +0 -31
- package/demo/elements/highlight/marked-highlight.html +0 -132
- package/demo/elements/highlight/marked-highlight.ts +0 -22
- package/demo/elements/highlight/prism-highlight.html +0 -62
- package/demo/elements/highlight/prism-highlight.ts +0 -17
- package/demo/elements/http/body-editor.html +0 -17
- package/demo/elements/http/body-editor.ts +0 -115
- package/demo/elements/http/headers.html +0 -17
- package/demo/elements/http/headers.ts +0 -59
- package/demo/elements/http/http-assertions.html +0 -20
- package/demo/elements/http/http-assertions.ts +0 -89
- package/demo/elements/http/http-flows.html +0 -23
- package/demo/elements/http/http-flows.ts +0 -89
- package/demo/elements/http/index.html +0 -45
- package/demo/elements/http/request-editor.html +0 -26
- package/demo/elements/http/request-editor.ts +0 -197
- package/demo/elements/http/request-log.html +0 -16
- package/demo/elements/http/request-log.ts +0 -136
- package/demo/elements/http/url-editing.html +0 -17
- package/demo/elements/http/url-editing.ts +0 -112
- package/demo/elements/icons/index.html +0 -81
- package/demo/elements/icons/index.ts +0 -52
- package/demo/elements/index.html +0 -72
- package/demo/elements/mention-textarea/index.html +0 -19
- package/demo/elements/mention-textarea/index.ts +0 -205
- package/demo/elements/navigation/navigation-item.html +0 -49
- package/demo/elements/navigation/navigation-item.ts +0 -131
- package/demo/elements/navigation/navigation.html +0 -20
- package/demo/elements/navigation/navigation.ts +0 -45
- package/demo/elements/project/index.html +0 -29
- package/demo/elements/project/project-run-report.html +0 -20
- package/demo/elements/project/project-run-report.ts +0 -132
- package/demo/elements/project/request-editor.html +0 -23
- package/demo/elements/project/request-editor.ts +0 -232
- package/demo/elements/user/user-avatar.html +0 -17
- package/demo/elements/user/user-avatar.ts +0 -60
- package/demo/env.js +0 -4
- package/demo/index.html +0 -34
- package/demo/layout/index.html +0 -94
- package/demo/layout/index.ts +0 -190
- package/demo/md/DemoStyles.ts +0 -61
- package/demo/md/UiDemoPage.ts +0 -6
- package/demo/md/buttons/button.html +0 -121
- package/demo/md/buttons/button.ts +0 -246
- package/demo/md/buttons/group.html +0 -36
- package/demo/md/buttons/group.ts +0 -171
- package/demo/md/checkbox/index.html +0 -39
- package/demo/md/checkbox/index.ts +0 -220
- package/demo/md/chip/chip.html +0 -70
- package/demo/md/chip/chip.ts +0 -219
- package/demo/md/chip/pawel6c9a.jpg +0 -0
- package/demo/md/collapse/CustomDetail.ts +0 -89
- package/demo/md/collapse/collapse.html +0 -21
- package/demo/md/collapse/collapse.ts +0 -78
- package/demo/md/date-picker/date-picker.ts +0 -336
- package/demo/md/date-picker/index.html +0 -171
- package/demo/md/dialog/confirm-dialog.html +0 -49
- package/demo/md/dialog/confirm-dialog.ts +0 -121
- package/demo/md/dialog/dialog.html +0 -25
- package/demo/md/dialog/dialog.ts +0 -468
- package/demo/md/dropdown-list/index.html +0 -31
- package/demo/md/dropdown-list/index.ts +0 -158
- package/demo/md/icon-button/index.html +0 -122
- package/demo/md/icon-button/index.ts +0 -132
- package/demo/md/index.html +0 -73
- package/demo/md/inputs/input.html +0 -73
- package/demo/md/inputs/input.ts +0 -278
- package/demo/md/inputs/radio.html +0 -39
- package/demo/md/inputs/radio.ts +0 -156
- package/demo/md/inputs/switch.html +0 -45
- package/demo/md/inputs/switch.ts +0 -144
- package/demo/md/list/list.html +0 -65
- package/demo/md/list/list.ts +0 -204
- package/demo/md/listbox/listbox.html +0 -31
- package/demo/md/listbox/listbox.ts +0 -27
- package/demo/md/menu/index.html +0 -19
- package/demo/md/menu/index.ts +0 -514
- package/demo/md/notification/snack.html +0 -21
- package/demo/md/notification/snack.ts +0 -70
- package/demo/md/progress/progress.html +0 -46
- package/demo/md/progress/progress.ts +0 -161
- package/demo/md/segmented-button/index.html +0 -21
- package/demo/md/segmented-button/index.ts +0 -55
- package/demo/md/select/index.html +0 -16
- package/demo/md/select/index.ts +0 -217
- package/demo/md/tabs/tabs.html +0 -40
- package/demo/md/tabs/tabs.ts +0 -214
- package/demo/oauth-popup.html +0 -36
- package/demo/page.css +0 -8
- package/demo/resources/calendar-month.png +0 -0
- package/demo/resources/favorite.png +0 -0
- package/demo/resources/fingerprint.png +0 -0
- package/demo/resources/home-work.png +0 -0
- package/demo/resources/mood.png +0 -0
- package/demo/resources/print.png +0 -0
- package/demo/resources/stars.png +0 -0
- package/demo/resources/theaters.png +0 -0
- package/demo/tsconfig.json +0 -4
- package/eslint.config.js +0 -97
- package/scripts/copy-assets.js +0 -21
- package/scripts/release.js +0 -66
- package/src/demo/DemoPage.ts +0 -169
- package/src/demo/DemoStyles.ts +0 -60
- package/test/README.md +0 -375
- package/test/contextual-menu/ContextMenu.test.ts +0 -760
- package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
- package/test/core/activity.spec.ts +0 -413
- package/test/core/activity_manager.spec.ts +0 -544
- package/test/core/application.spec.ts +0 -218
- package/test/core/fragment.spec.ts +0 -565
- package/test/core/fragment_manager.spec.ts +0 -404
- package/test/core/live_data.spec.ts +0 -558
- package/test/core/renderer.spec.ts +0 -113
- package/test/dom-assertions.test.ts +0 -182
- package/test/elements/MonacoSetup.ts +0 -65
- package/test/elements/authorization/basic-method.test.ts +0 -177
- package/test/elements/authorization/bearer-method.test.ts +0 -143
- package/test/elements/authorization/ntlm-method.test.ts +0 -219
- package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
- package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
- package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
- package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
- package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
- package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
- package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
- package/test/elements/authorization/openid-method.test.ts +0 -591
- package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
- package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
- package/test/elements/code-editor/code-editor.test.ts +0 -574
- package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
- package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
- package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
- package/test/elements/currency/CurrencyPicker.test.ts +0 -486
- package/test/elements/data-table/DataTable.browser.test.ts +0 -649
- package/test/elements/har/HarUtils.test.ts +0 -45
- package/test/elements/har/HarViewerElement.test.ts +0 -687
- package/test/elements/har/test-data/har1.har +0 -3044
- package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
- package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
- package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
- package/test/elements/highlight/remoteSanitization.md +0 -1
- package/test/elements/highlight/test.md +0 -3
- package/test/elements/highlight/test1.md +0 -3
- package/test/elements/highlight/test2.md +0 -1
- package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
- package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
- package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
- package/test/elements/http/CertificateAdd.test.ts +0 -457
- package/test/elements/http/HttpAssertions.test.ts +0 -994
- package/test/elements/http/HttpFlows.test.ts +0 -502
- package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
- package/test/elements/layout/SplitItem.test.ts +0 -440
- package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
- package/test/elements/layout/SplitPanel.test.ts +0 -1109
- package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
- package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
- package/test/elements/navigation/Navigation.test.ts +0 -120
- package/test/env.ts +0 -15
- package/test/events/EventTypes.test.ts +0 -363
- package/test/events/EventsTestHelpers.ts +0 -16
- package/test/helpers/TestUtils.ts +0 -243
- package/test/helpers/UiMock.ts +0 -185
- package/test/lib/Dom.test.ts +0 -231
- package/test/md/button/UiButton.test.ts +0 -347
- package/test/md/button/UiIconButton.test.ts +0 -155
- package/test/md/chip/UiChip.test.ts +0 -219
- package/test/md/collapse/UiCollapse.test.ts +0 -250
- package/test/md/collapse/flex-layout.test.ts +0 -105
- package/test/md/date-time/DateTime.test.ts +0 -348
- package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
- package/test/md/dialog/UiDialog.test.ts +0 -759
- package/test/md/menu/Menu.test.ts +0 -855
- package/test/md/menu/MenuIntegration.test.ts +0 -426
- package/test/md/menu/MenuItem.test.ts +0 -652
- package/test/md/menu/SubMenu.test.ts +0 -410
- package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
- package/test/md/progress/UiProgressElement.test.ts +0 -117
- package/test/md/progress/UiRangeElement.test.ts +0 -156
- package/test/md/select/Select.test.ts +0 -925
- package/test/plugins/takeScreenshotPlugin.js +0 -35
- package/test/setup.test.ts +0 -217
- package/test/setup.ts +0 -117
- package/test/tsconfig.json +0 -7
- package/web-dev-server.config.js +0 -21
- package/web-test-runner.config.js +0 -90
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
import { assert, aTimeout, fixture, html, nextFrame } from '@open-wc/testing'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import { ProjectMock, Property } from '@api-client/core/browser.js'
|
|
4
|
-
import { loadMonaco } from '../MonacoSetup.js'
|
|
5
|
-
import BodyFormdataEditorElement from '../../../src/elements/http/BodyUrlEncodedEditor.js'
|
|
6
|
-
import SwitchElement from '../../../src/md/switch/internals/SwitchElement.js'
|
|
7
|
-
import type UiButtonElement from '../../../src/md/icon-button/internals/IconButton.js'
|
|
8
|
-
import '../../../src/define/http/http-body-urlencoded-editor.js'
|
|
9
|
-
|
|
10
|
-
describe('elements', () => {
|
|
11
|
-
describe('http', () => {
|
|
12
|
-
describe('BodyUrlEncodedEditor', () => {
|
|
13
|
-
async function basicFixture(): Promise<BodyFormdataEditorElement> {
|
|
14
|
-
return fixture(html`<http-body-urlencoded-editor allowFormInfo></http-body-urlencoded-editor>`)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function valueFixture(value: string): Promise<BodyFormdataEditorElement> {
|
|
18
|
-
return fixture(
|
|
19
|
-
html`<http-body-urlencoded-editor .value="${value}" allowFormInfo></http-body-urlencoded-editor>`
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function autoEncodeFixture(): Promise<BodyFormdataEditorElement> {
|
|
24
|
-
return fixture(html`<http-body-urlencoded-editor autoEncode allowFormInfo></http-body-urlencoded-editor>`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const generator = new ProjectMock()
|
|
28
|
-
|
|
29
|
-
before(async () => loadMonaco())
|
|
30
|
-
|
|
31
|
-
describe('Empty state', () => {
|
|
32
|
-
let element: BodyFormdataEditorElement
|
|
33
|
-
beforeEach(async () => {
|
|
34
|
-
element = await basicFixture()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('renders empty message', () => {
|
|
38
|
-
const node = element.shadowRoot!.querySelector('.empty-message')
|
|
39
|
-
assert.ok(node)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('renders the form mime information', () => {
|
|
43
|
-
const node = element.shadowRoot!.querySelector('.form-info')
|
|
44
|
-
assert.ok(node)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('has empty model', () => {
|
|
48
|
-
assert.deepEqual(element.model, [])
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
describe('adding a property', () => {
|
|
53
|
-
let element: BodyFormdataEditorElement
|
|
54
|
-
beforeEach(async () => {
|
|
55
|
-
element = await basicFixture()
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('adds a model item on add button click', () => {
|
|
59
|
-
element.addParameter()
|
|
60
|
-
assert.lengthOf(element.model, 1)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('does not add a model when readonly', () => {
|
|
64
|
-
element.readOnly = true
|
|
65
|
-
element.addParameter()
|
|
66
|
-
assert.lengthOf(element.model, 0)
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
it('does not add a model when disabled', () => {
|
|
70
|
-
element.disabled = true
|
|
71
|
-
element.addParameter()
|
|
72
|
-
assert.lengthOf(element.model, 0)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('model item has basic schema', () => {
|
|
76
|
-
element.addParameter()
|
|
77
|
-
const p = Property.String()
|
|
78
|
-
assert.deepEqual(element.model[0], p.toJSON())
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('adds an item with undefined model', () => {
|
|
82
|
-
// @ts-expect-error for testing
|
|
83
|
-
element.model = undefined
|
|
84
|
-
element.addParameter()
|
|
85
|
-
assert.lengthOf(element.model, 1)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('focuses on the added item', async () => {
|
|
89
|
-
const spy = sinon.spy(element, 'focusLast')
|
|
90
|
-
element.addParameter()
|
|
91
|
-
await aTimeout(0)
|
|
92
|
-
assert.isTrue(spy.called)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('does not notify model change', async () => {
|
|
96
|
-
// there's no point of storing the model without empty values. They are not generating
|
|
97
|
-
// any editor value
|
|
98
|
-
const spy = sinon.spy()
|
|
99
|
-
element.addEventListener('change', spy)
|
|
100
|
-
element.addParameter()
|
|
101
|
-
assert.isFalse(spy.called)
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
describe('#value', () => {
|
|
106
|
-
let element: BodyFormdataEditorElement
|
|
107
|
-
beforeEach(async () => {
|
|
108
|
-
element = await basicFixture()
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('reads set value', () => {
|
|
112
|
-
element.value = 'a=b'
|
|
113
|
-
assert.equal(element.value, 'a=b')
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('generates a view model', () => {
|
|
117
|
-
element.value = 'a=b&c=d'
|
|
118
|
-
assert.lengthOf(element.model, 2)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('generated model has basic properties', () => {
|
|
122
|
-
element.value = 'a=b&c=d'
|
|
123
|
-
const [item] = element.model
|
|
124
|
-
const p = Property.String('a', 'b')
|
|
125
|
-
assert.deepEqual(item, p.toJSON())
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('clears the model when no value', () => {
|
|
129
|
-
element.value = 'a=b&c=d'
|
|
130
|
-
assert.lengthOf(element.model, 2)
|
|
131
|
-
element.value = ''
|
|
132
|
-
assert.lengthOf(element.model, 0)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it('updates existing model', () => {
|
|
136
|
-
const p = Property.String('test', 'true')
|
|
137
|
-
element.model = [p.toJSON()]
|
|
138
|
-
element.value = 'a=b&c=d'
|
|
139
|
-
assert.equal(element.model[0].name, 'a')
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
it('does not notify model change', async () => {
|
|
143
|
-
// value/model setters should not dispatch change events
|
|
144
|
-
const spy = sinon.spy()
|
|
145
|
-
element.addEventListener('change', spy)
|
|
146
|
-
element.value = 'a=b&c=d'
|
|
147
|
-
assert.isFalse(spy.called)
|
|
148
|
-
})
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
describe('#model', () => {
|
|
152
|
-
let element: BodyFormdataEditorElement
|
|
153
|
-
beforeEach(async () => {
|
|
154
|
-
element = await basicFixture()
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
it('reads set value', () => {
|
|
158
|
-
const p = Property.String('test', 'true')
|
|
159
|
-
element.model = [p.toJSON()]
|
|
160
|
-
assert.deepEqual(element.model, [p.toJSON()])
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it('generates a value', () => {
|
|
164
|
-
const p = Property.String('test', 'true')
|
|
165
|
-
element.model = [p.toJSON()]
|
|
166
|
-
assert.equal(element.value, 'test=true')
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('clears the previously set value', () => {
|
|
170
|
-
element.value = 'a=b&c=d'
|
|
171
|
-
// @ts-expect-error for testing
|
|
172
|
-
element.model = undefined
|
|
173
|
-
assert.equal(element.value, '')
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('updates existing value', () => {
|
|
177
|
-
element.value = 'a=b&c=d'
|
|
178
|
-
const p = Property.String('test', 'true')
|
|
179
|
-
element.model = [p.toJSON()]
|
|
180
|
-
assert.equal(element.value, 'test=true')
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
it('does not notify model change', () => {
|
|
184
|
-
// value/model setters should not dispatch change events
|
|
185
|
-
const spy = sinon.spy()
|
|
186
|
-
element.addEventListener('change', spy)
|
|
187
|
-
const p = Property.String('test', 'true')
|
|
188
|
-
element.model = [p.toJSON()]
|
|
189
|
-
assert.isFalse(spy.called)
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
describe('values rendering', () => {
|
|
194
|
-
let element: BodyFormdataEditorElement
|
|
195
|
-
beforeEach(async () => {
|
|
196
|
-
const value = generator.http.payload.urlEncoded()
|
|
197
|
-
element = await valueFixture(value)
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('renders form rows for each model entry', () => {
|
|
201
|
-
const items = element.shadowRoot!.querySelectorAll('.param-row')
|
|
202
|
-
assert.lengthOf(items, element.model.length)
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
it('renders the enable switch', () => {
|
|
206
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch')
|
|
207
|
-
assert.ok(item)
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('renders the remove button', () => {
|
|
211
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-icon-button')
|
|
212
|
-
assert.ok(item)
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
it('renders the name input', () => {
|
|
216
|
-
const item = element.shadowRoot!.querySelector('.param-row .name-input input')
|
|
217
|
-
assert.ok(item)
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
it('renders the value input', () => {
|
|
221
|
-
const item = element.shadowRoot!.querySelector('.param-row .value-input input')
|
|
222
|
-
assert.ok(item)
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
describe('enable/disable action', () => {
|
|
227
|
-
let element: BodyFormdataEditorElement
|
|
228
|
-
beforeEach(async () => {
|
|
229
|
-
const value = generator.http.payload.urlEncoded()
|
|
230
|
-
element = await valueFixture(value)
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
it('disables the form item', () => {
|
|
234
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch') as SwitchElement
|
|
235
|
-
item.click()
|
|
236
|
-
assert.isFalse(element.model[0].enabled)
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
it('updates the value', () => {
|
|
240
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch') as SwitchElement
|
|
241
|
-
item.click()
|
|
242
|
-
const { name, value: modelValue } = element.model[0]
|
|
243
|
-
const { value } = element
|
|
244
|
-
assert.notInclude(value, `${name}=${modelValue}`)
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it('dispatches the change event', () => {
|
|
248
|
-
const spy = sinon.spy()
|
|
249
|
-
element.addEventListener('change', spy)
|
|
250
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch') as SwitchElement
|
|
251
|
-
item.click()
|
|
252
|
-
assert.isTrue(spy.called)
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
it('re-enables the form item', async () => {
|
|
256
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch') as SwitchElement
|
|
257
|
-
item.click()
|
|
258
|
-
await aTimeout(0)
|
|
259
|
-
item.click()
|
|
260
|
-
assert.isTrue(element.model[0].enabled)
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
it('changes the value when enabling', async () => {
|
|
264
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch') as SwitchElement
|
|
265
|
-
item.click()
|
|
266
|
-
await aTimeout(0)
|
|
267
|
-
item.click()
|
|
268
|
-
const { name, value: modelValue } = element.model[0]
|
|
269
|
-
const { value } = element
|
|
270
|
-
assert.include(value, `${name}=${modelValue}`)
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
it('dispatches the change event when enabling', async () => {
|
|
274
|
-
const spy = sinon.spy()
|
|
275
|
-
element.addEventListener('change', spy)
|
|
276
|
-
const item = element.shadowRoot!.querySelector('.param-row ui-switch') as SwitchElement
|
|
277
|
-
item.click()
|
|
278
|
-
await aTimeout(0)
|
|
279
|
-
item.click()
|
|
280
|
-
assert.equal(spy.callCount, 2)
|
|
281
|
-
})
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
describe('removing an item', () => {
|
|
285
|
-
let element: BodyFormdataEditorElement
|
|
286
|
-
beforeEach(async () => {
|
|
287
|
-
const value = generator.http.payload.urlEncoded()
|
|
288
|
-
element = await valueFixture(value)
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
it('removes an item from the model', () => {
|
|
292
|
-
const item = { ...element.model[0] }
|
|
293
|
-
const button = element.shadowRoot!.querySelector('.param-row ui-icon-button') as UiButtonElement
|
|
294
|
-
button.click()
|
|
295
|
-
assert.notDeepEqual(element.model[0], item)
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
it('updates the value', () => {
|
|
299
|
-
const item = { ...element.model[0] }
|
|
300
|
-
const button = element.shadowRoot!.querySelector('.param-row ui-icon-button') as UiButtonElement
|
|
301
|
-
button.click()
|
|
302
|
-
assert.notInclude(element.value, `${item.name}=${item.value}`)
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
it('dispatches the change event', () => {
|
|
306
|
-
const spy = sinon.spy()
|
|
307
|
-
element.addEventListener('change', spy)
|
|
308
|
-
const button = element.shadowRoot!.querySelector('.param-row ui-icon-button') as UiButtonElement
|
|
309
|
-
button.click()
|
|
310
|
-
assert.isTrue(spy.calledOnce)
|
|
311
|
-
})
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
describe('name change', () => {
|
|
315
|
-
let element: BodyFormdataEditorElement
|
|
316
|
-
beforeEach(async () => {
|
|
317
|
-
const value = generator.http.payload.urlEncoded()
|
|
318
|
-
element = await valueFixture(value)
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
it('changes the name', () => {
|
|
322
|
-
const item = { ...element.model[0] }
|
|
323
|
-
const input = element.shadowRoot!.querySelector('.param-row .name-input input') as HTMLInputElement
|
|
324
|
-
input.value = 'new-value-test'
|
|
325
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
326
|
-
assert.notEqual(element.model[0].name, item.name)
|
|
327
|
-
assert.equal(element.model[0].name, 'new-value-test')
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
it('updates the value', () => {
|
|
331
|
-
const input = element.shadowRoot!.querySelector('.param-row .name-input input') as HTMLInputElement
|
|
332
|
-
input.value = 'new-value-test'
|
|
333
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
334
|
-
assert.include(element.value, `new-value-test=${element.model[0].value}`)
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
it('dispatches the change event', () => {
|
|
338
|
-
const spy = sinon.spy()
|
|
339
|
-
element.addEventListener('change', spy)
|
|
340
|
-
const input = element.shadowRoot!.querySelector('.param-row .name-input input') as HTMLInputElement
|
|
341
|
-
input.value = 'new-value-test'
|
|
342
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
343
|
-
assert.isTrue(spy.calledOnce)
|
|
344
|
-
})
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
describe('value change', () => {
|
|
348
|
-
let element: BodyFormdataEditorElement
|
|
349
|
-
beforeEach(async () => {
|
|
350
|
-
const value = generator.http.payload.urlEncoded()
|
|
351
|
-
element = await valueFixture(value)
|
|
352
|
-
})
|
|
353
|
-
|
|
354
|
-
it('changes the value', () => {
|
|
355
|
-
const item = { ...element.model[0] }
|
|
356
|
-
const input = element.shadowRoot!.querySelector('.param-row .value-input input') as HTMLInputElement
|
|
357
|
-
input.value = 'new-value-test'
|
|
358
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
359
|
-
assert.notEqual(element.model[0].value, item.value)
|
|
360
|
-
assert.equal(element.model[0].value, 'new-value-test')
|
|
361
|
-
})
|
|
362
|
-
|
|
363
|
-
it('updates the value', () => {
|
|
364
|
-
const input = element.shadowRoot!.querySelector('.param-row .value-input input') as HTMLInputElement
|
|
365
|
-
input.value = 'new-value-test'
|
|
366
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
367
|
-
assert.include(element.value, `${element.model[0].name}=new-value-test`)
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
it('dispatches the change event', () => {
|
|
371
|
-
const spy = sinon.spy()
|
|
372
|
-
element.addEventListener('change', spy)
|
|
373
|
-
const input = element.shadowRoot!.querySelector('.param-row .value-input input') as HTMLInputElement
|
|
374
|
-
input.value = 'new-value-test'
|
|
375
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
376
|
-
assert.isTrue(spy.calledOnce)
|
|
377
|
-
})
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
-
describe('value encoding', () => {
|
|
381
|
-
let element: BodyFormdataEditorElement
|
|
382
|
-
beforeEach(async () => {
|
|
383
|
-
const value = 'a b=c d'
|
|
384
|
-
element = await valueFixture(value)
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
it('has unchanged values in the model', () => {
|
|
388
|
-
const [item] = element.model
|
|
389
|
-
assert.equal(item.name, 'a b')
|
|
390
|
-
assert.equal(item.value, 'c d')
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
it('encodes the model values', () => {
|
|
394
|
-
element.encodeParameters()
|
|
395
|
-
const [item] = element.model
|
|
396
|
-
assert.equal(item.name, 'a+b')
|
|
397
|
-
assert.equal(item.value, 'c+d')
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
it('encodes the value', () => {
|
|
401
|
-
element.encodeParameters()
|
|
402
|
-
assert.equal(element.value, 'a+b=c+d')
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
it('dispatches the change event', () => {
|
|
406
|
-
const spy = sinon.spy()
|
|
407
|
-
element.addEventListener('change', spy)
|
|
408
|
-
element.encodeParameters()
|
|
409
|
-
assert.isTrue(spy.calledOnce)
|
|
410
|
-
})
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
describe('value decoding', () => {
|
|
414
|
-
let element: BodyFormdataEditorElement
|
|
415
|
-
beforeEach(async () => {
|
|
416
|
-
const value = 'a+b=c+d'
|
|
417
|
-
element = await valueFixture(value)
|
|
418
|
-
})
|
|
419
|
-
|
|
420
|
-
it('has unchanged values in the model', () => {
|
|
421
|
-
const [item] = element.model
|
|
422
|
-
assert.equal(item.name, 'a+b')
|
|
423
|
-
assert.equal(item.value, 'c+d')
|
|
424
|
-
})
|
|
425
|
-
|
|
426
|
-
it('decodes the model values', () => {
|
|
427
|
-
element.decodeParameters()
|
|
428
|
-
const [item] = element.model
|
|
429
|
-
assert.equal(item.name, 'a b')
|
|
430
|
-
assert.equal(item.value, 'c d')
|
|
431
|
-
})
|
|
432
|
-
|
|
433
|
-
it('decodes the value', () => {
|
|
434
|
-
element.decodeParameters()
|
|
435
|
-
assert.equal(element.value, 'a b=c d')
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
it('dispatches the change event', () => {
|
|
439
|
-
const spy = sinon.spy()
|
|
440
|
-
element.addEventListener('change', spy)
|
|
441
|
-
element.decodeParameters()
|
|
442
|
-
assert.isTrue(spy.calledOnce)
|
|
443
|
-
})
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
describe('#autoEncode', () => {
|
|
447
|
-
let element: BodyFormdataEditorElement
|
|
448
|
-
beforeEach(async () => {
|
|
449
|
-
element = await autoEncodeFixture()
|
|
450
|
-
})
|
|
451
|
-
|
|
452
|
-
it('automatically decodes the set value', () => {
|
|
453
|
-
element.value = 'a+b=c+d'
|
|
454
|
-
const [item] = element.model
|
|
455
|
-
assert.equal(item.name, 'a b')
|
|
456
|
-
assert.equal(item.value, 'c d')
|
|
457
|
-
})
|
|
458
|
-
|
|
459
|
-
it('encodes values on input change', async () => {
|
|
460
|
-
element.value = 'a+b=c+d'
|
|
461
|
-
await nextFrame()
|
|
462
|
-
const input = element.shadowRoot!.querySelector('.param-row .name-input input') as HTMLInputElement
|
|
463
|
-
input.value = 'new value test'
|
|
464
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
465
|
-
assert.equal(element.value, 'new+value+test=c+d')
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
it('does not double encodes values', async () => {
|
|
469
|
-
element.value = 'a+b=c+d'
|
|
470
|
-
await nextFrame()
|
|
471
|
-
const input = element.shadowRoot!.querySelector('.param-row .name-input input') as HTMLInputElement
|
|
472
|
-
input.value = 'new value test'
|
|
473
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
474
|
-
await nextFrame()
|
|
475
|
-
input.value = 'new value tests'
|
|
476
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
477
|
-
assert.equal(element.value, 'new+value+tests=c+d')
|
|
478
|
-
})
|
|
479
|
-
})
|
|
480
|
-
})
|
|
481
|
-
})
|
|
482
|
-
})
|