@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,486 +0,0 @@
|
|
|
1
|
-
import { fixture, assert, nextFrame, html, oneEvent } from '@open-wc/testing'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import CurrencyPicker from '../../../src/elements/currency/internals/Picker.js'
|
|
4
|
-
import '../../../src/elements/currency/currency-picker.js'
|
|
5
|
-
|
|
6
|
-
describe('CurrencyPicker', () => {
|
|
7
|
-
async function basicFixture(): Promise<CurrencyPicker> {
|
|
8
|
-
return fixture(html`<currency-picker></currency-picker>`)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async function multiSelectFixture(): Promise<CurrencyPicker> {
|
|
12
|
-
return fixture(html`<currency-picker multi></currency-picker>`)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function allowedCurrenciesFixture(): Promise<CurrencyPicker> {
|
|
16
|
-
return fixture(html`<currency-picker .allowedCurrencies="${['USD', 'EUR', 'GBP']}"></currency-picker>`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function requiredFixture(): Promise<CurrencyPicker> {
|
|
20
|
-
return fixture(html`<currency-picker required></currency-picker>`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function formFixture(): Promise<{ form: HTMLFormElement; picker: CurrencyPicker }> {
|
|
24
|
-
const form = (await fixture(html`
|
|
25
|
-
<form>
|
|
26
|
-
<currency-picker name="currencies" .selected="${['USD']}"></currency-picker>
|
|
27
|
-
</form>
|
|
28
|
-
`)) as HTMLFormElement
|
|
29
|
-
const picker = form.querySelector('currency-picker') as CurrencyPicker
|
|
30
|
-
return { form, picker }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe('Basic Functionality', () => {
|
|
34
|
-
let picker: CurrencyPicker
|
|
35
|
-
|
|
36
|
-
beforeEach(async () => {
|
|
37
|
-
picker = await basicFixture()
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('should create element', () => {
|
|
41
|
-
assert.instanceOf(picker, CurrencyPicker)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('should have default properties', () => {
|
|
45
|
-
assert.deepEqual(picker.selected, [])
|
|
46
|
-
assert.deepEqual(picker.allowedCurrencies, [])
|
|
47
|
-
assert.equal(picker.label, 'Add Currency')
|
|
48
|
-
assert.isFalse(picker.multi)
|
|
49
|
-
assert.isFalse(picker.required)
|
|
50
|
-
assert.isFalse(picker.disabled)
|
|
51
|
-
assert.isTrue(picker.showErrors)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('should render currency selector', () => {
|
|
55
|
-
const selector = picker.shadowRoot?.querySelector('ui-select')
|
|
56
|
-
assert.exists(selector)
|
|
57
|
-
assert.equal(selector?.getAttribute('label'), 'Add Currency')
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('should populate currency options', async () => {
|
|
61
|
-
await nextFrame()
|
|
62
|
-
const options = picker.shadowRoot?.querySelectorAll('ui-option')
|
|
63
|
-
assert.exists(options)
|
|
64
|
-
assert.isAtLeast(options?.length || 0, 25) // Should have popular currencies
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
describe('Currency Selection', () => {
|
|
69
|
-
let picker: CurrencyPicker
|
|
70
|
-
|
|
71
|
-
beforeEach(async () => {
|
|
72
|
-
picker = await basicFixture()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should select a currency', async () => {
|
|
76
|
-
const select = picker.shadowRoot?.querySelector('ui-select') as HTMLElement
|
|
77
|
-
assert.exists(select)
|
|
78
|
-
|
|
79
|
-
// Simulate selecting USD
|
|
80
|
-
const changeEvent = new CustomEvent('change', {
|
|
81
|
-
detail: { value: 'USD' },
|
|
82
|
-
})
|
|
83
|
-
Object.defineProperty(changeEvent, 'target', {
|
|
84
|
-
value: { value: 'USD' },
|
|
85
|
-
writable: false,
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
select.dispatchEvent(changeEvent)
|
|
89
|
-
await nextFrame()
|
|
90
|
-
|
|
91
|
-
assert.deepEqual(picker.selected, ['USD'])
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('should dispatch change event on user selection', async () => {
|
|
95
|
-
const changePromise = oneEvent(picker, 'change')
|
|
96
|
-
|
|
97
|
-
// Simulate user selecting a currency through the select element
|
|
98
|
-
const select = picker.shadowRoot?.querySelector('ui-select') as HTMLElement
|
|
99
|
-
assert.exists(select)
|
|
100
|
-
|
|
101
|
-
const changeEvent = new CustomEvent('change', {
|
|
102
|
-
detail: { value: 'USD' },
|
|
103
|
-
})
|
|
104
|
-
Object.defineProperty(changeEvent, 'target', {
|
|
105
|
-
value: { value: 'USD' },
|
|
106
|
-
writable: false,
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
select.dispatchEvent(changeEvent)
|
|
110
|
-
await nextFrame()
|
|
111
|
-
|
|
112
|
-
const event = await changePromise
|
|
113
|
-
assert.equal(event.type, 'change')
|
|
114
|
-
assert.deepEqual(event.detail.codes, ['USD'])
|
|
115
|
-
assert.equal(event.detail.currencies.length, 1)
|
|
116
|
-
assert.equal(event.detail.currencies[0].code, 'USD')
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('should get selected currencies', async () => {
|
|
120
|
-
picker.multi = true
|
|
121
|
-
picker.selected = ['USD', 'EUR']
|
|
122
|
-
await picker.updateComplete
|
|
123
|
-
await nextFrame()
|
|
124
|
-
const currencies = picker.getSelectedCurrencies()
|
|
125
|
-
assert.equal(currencies.length, 2)
|
|
126
|
-
assert.equal(currencies[0].code, 'USD')
|
|
127
|
-
assert.equal(currencies[1].code, 'EUR')
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
it('should clear selection', async () => {
|
|
131
|
-
picker.selected = ['USD', 'EUR']
|
|
132
|
-
await nextFrame()
|
|
133
|
-
|
|
134
|
-
picker.clearSelection()
|
|
135
|
-
await nextFrame()
|
|
136
|
-
|
|
137
|
-
assert.deepEqual(picker.selected, [])
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
describe('Multi-select Mode', () => {
|
|
142
|
-
let picker: CurrencyPicker
|
|
143
|
-
|
|
144
|
-
beforeEach(async () => {
|
|
145
|
-
picker = await multiSelectFixture()
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('should allow multiple selections', async () => {
|
|
149
|
-
picker.selected = ['USD', 'EUR', 'GBP']
|
|
150
|
-
await nextFrame()
|
|
151
|
-
|
|
152
|
-
assert.equal(picker.selected.length, 3)
|
|
153
|
-
assert.include(picker.selected, 'USD')
|
|
154
|
-
assert.include(picker.selected, 'EUR')
|
|
155
|
-
assert.include(picker.selected, 'GBP')
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('should render chips for selected currencies', async () => {
|
|
159
|
-
picker.selected = ['USD', 'EUR']
|
|
160
|
-
await nextFrame()
|
|
161
|
-
|
|
162
|
-
const chipSet = picker.shadowRoot?.querySelector('ui-chip-set')
|
|
163
|
-
const chips = picker.shadowRoot?.querySelectorAll('ui-chip')
|
|
164
|
-
|
|
165
|
-
assert.exists(chipSet)
|
|
166
|
-
assert.equal(chips?.length, 2)
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('should remove currency when chip is removed', async () => {
|
|
170
|
-
picker.selected = ['USD', 'EUR']
|
|
171
|
-
await nextFrame()
|
|
172
|
-
|
|
173
|
-
const changePromise = oneEvent(picker, 'change')
|
|
174
|
-
const chip = picker.shadowRoot?.querySelector('ui-chip[data-code="USD"]') as HTMLElement
|
|
175
|
-
assert.exists(chip)
|
|
176
|
-
|
|
177
|
-
// Simulate remove event
|
|
178
|
-
const removeEvent = new CustomEvent('remove')
|
|
179
|
-
Object.defineProperty(removeEvent, 'target', {
|
|
180
|
-
value: { dataset: { code: 'USD' } },
|
|
181
|
-
writable: false,
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
chip.dispatchEvent(removeEvent)
|
|
185
|
-
await nextFrame()
|
|
186
|
-
|
|
187
|
-
// Should update selection
|
|
188
|
-
assert.deepEqual(picker.selected, ['EUR'])
|
|
189
|
-
|
|
190
|
-
// Should dispatch change event
|
|
191
|
-
const event = await changePromise
|
|
192
|
-
assert.equal(event.type, 'change')
|
|
193
|
-
assert.deepEqual(event.detail.codes, ['EUR'])
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
it('should filter out selected currencies from options', async () => {
|
|
197
|
-
picker.selected = ['USD']
|
|
198
|
-
await nextFrame()
|
|
199
|
-
|
|
200
|
-
const selectableCurrencies = picker.shadowRoot?.querySelectorAll('ui-option[value="USD"]')
|
|
201
|
-
assert.equal(selectableCurrencies?.length, 0) // USD should not be in options
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
describe('Allowed Currencies', () => {
|
|
206
|
-
let picker: CurrencyPicker
|
|
207
|
-
|
|
208
|
-
beforeEach(async () => {
|
|
209
|
-
picker = await allowedCurrenciesFixture()
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
it('should filter options based on allowed currencies', async () => {
|
|
213
|
-
await nextFrame()
|
|
214
|
-
|
|
215
|
-
const options = picker.shadowRoot?.querySelectorAll('ui-option[value]')
|
|
216
|
-
const optionValues = Array.from(options || [])
|
|
217
|
-
.map((option) => option.getAttribute('value'))
|
|
218
|
-
.filter(Boolean)
|
|
219
|
-
|
|
220
|
-
// Should only have USD, EUR, GBP (plus empty option)
|
|
221
|
-
assert.isAtMost(optionValues.length, 3)
|
|
222
|
-
assert.include(optionValues, 'USD')
|
|
223
|
-
assert.include(optionValues, 'EUR')
|
|
224
|
-
assert.include(optionValues, 'GBP')
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
it('should validate selected currencies against allowed currencies', async () => {
|
|
228
|
-
const errorPromise = oneEvent(picker, 'error')
|
|
229
|
-
|
|
230
|
-
// Try to set a currency not in allowed list
|
|
231
|
-
picker.selected = ['JPY'] // Not in allowed list
|
|
232
|
-
await nextFrame()
|
|
233
|
-
|
|
234
|
-
const errorEvent = await errorPromise
|
|
235
|
-
assert.equal(errorEvent.type, 'error')
|
|
236
|
-
assert.equal(errorEvent.detail.error.type, 'validation')
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
describe('Validation and Error Handling', () => {
|
|
241
|
-
let picker: CurrencyPicker
|
|
242
|
-
|
|
243
|
-
beforeEach(async () => {
|
|
244
|
-
picker = await requiredFixture()
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it('should show validation error when required and empty', async () => {
|
|
248
|
-
const errorPromise = oneEvent(picker, 'error')
|
|
249
|
-
|
|
250
|
-
picker.clearSelection()
|
|
251
|
-
await nextFrame()
|
|
252
|
-
|
|
253
|
-
const errorEvent = await errorPromise
|
|
254
|
-
assert.equal(errorEvent.detail.error.type, 'selection')
|
|
255
|
-
assert.include(errorEvent.detail.error.message, 'required')
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
it('should show error state in UI when showErrors is true', async () => {
|
|
259
|
-
picker.showErrors = true
|
|
260
|
-
picker.clearSelection() // This should trigger required validation error
|
|
261
|
-
await picker.updateComplete
|
|
262
|
-
const errorElement = picker.shadowRoot?.querySelector('.error')
|
|
263
|
-
const selectElement = picker.shadowRoot?.querySelector('ui-select')
|
|
264
|
-
const isInvalid = !picker.validity.valid
|
|
265
|
-
const hasAriaInvalid = selectElement?.getAttribute('aria-invalid') === 'true'
|
|
266
|
-
|
|
267
|
-
assert.exists(errorElement, 'Error element should exist')
|
|
268
|
-
assert.isTrue(isInvalid, 'Component should be in invalid state')
|
|
269
|
-
assert.isTrue(hasAriaInvalid, 'Select element should have aria-invalid=true')
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
it('should not show error UI when showErrors is false', async () => {
|
|
273
|
-
picker.showErrors = false
|
|
274
|
-
picker.clearSelection() // This should trigger required validation error
|
|
275
|
-
await nextFrame()
|
|
276
|
-
|
|
277
|
-
const errorElement = picker.shadowRoot?.querySelector('.error')
|
|
278
|
-
assert.isNull(errorElement)
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
it('should validate invalid currency codes', async () => {
|
|
282
|
-
const errorPromise = oneEvent(picker, 'error')
|
|
283
|
-
|
|
284
|
-
picker.selected = ['INVALID_CODE']
|
|
285
|
-
await nextFrame()
|
|
286
|
-
|
|
287
|
-
const errorEvent = await errorPromise
|
|
288
|
-
assert.equal(errorEvent.detail.error.type, 'validation')
|
|
289
|
-
assert.include(errorEvent.detail.error.message, 'Invalid currency codes')
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
it('should prevent multiple selections in single-select mode', async () => {
|
|
293
|
-
picker.multi = false
|
|
294
|
-
const errorPromise = oneEvent(picker, 'error')
|
|
295
|
-
|
|
296
|
-
picker.selected = ['USD', 'EUR'] // Multiple selections in single-select mode
|
|
297
|
-
await nextFrame()
|
|
298
|
-
|
|
299
|
-
const errorEvent = await errorPromise
|
|
300
|
-
assert.equal(errorEvent.detail.error.type, 'selection')
|
|
301
|
-
assert.include(errorEvent.detail.error.message, 'Multiple currency selection is not allowed')
|
|
302
|
-
})
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
describe('Form Integration', () => {
|
|
306
|
-
let form: HTMLFormElement
|
|
307
|
-
let picker: CurrencyPicker
|
|
308
|
-
|
|
309
|
-
beforeEach(async () => {
|
|
310
|
-
const fixture = await formFixture()
|
|
311
|
-
form = fixture.form
|
|
312
|
-
picker = fixture.picker
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
it('should be form-associated', () => {
|
|
316
|
-
assert.isTrue(CurrencyPicker.formAssociated)
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
it('should have form value', async () => {
|
|
320
|
-
picker.multi = true
|
|
321
|
-
picker.selected = ['USD', 'EUR']
|
|
322
|
-
await nextFrame()
|
|
323
|
-
|
|
324
|
-
// Check ElementInternals form value
|
|
325
|
-
const formData = new FormData(form)
|
|
326
|
-
assert.equal(formData.get('currencies'), 'USD,EUR')
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
it('should reset with form', async () => {
|
|
330
|
-
picker.selected = ['USD', 'EUR']
|
|
331
|
-
await nextFrame()
|
|
332
|
-
|
|
333
|
-
form.reset()
|
|
334
|
-
await nextFrame()
|
|
335
|
-
|
|
336
|
-
assert.deepEqual(picker.selected, [])
|
|
337
|
-
})
|
|
338
|
-
|
|
339
|
-
it('should restore form state', async () => {
|
|
340
|
-
// Simulate form state restoration
|
|
341
|
-
picker.multi = true
|
|
342
|
-
picker.formStateRestoreCallback('USD,EUR')
|
|
343
|
-
await nextFrame()
|
|
344
|
-
|
|
345
|
-
assert.deepEqual(picker.selected, ['USD', 'EUR'])
|
|
346
|
-
})
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
describe('Accessibility', () => {
|
|
350
|
-
let picker: CurrencyPicker
|
|
351
|
-
|
|
352
|
-
beforeEach(async () => {
|
|
353
|
-
picker = await basicFixture()
|
|
354
|
-
})
|
|
355
|
-
|
|
356
|
-
it('should have proper ARIA attributes', async () => {
|
|
357
|
-
await nextFrame()
|
|
358
|
-
|
|
359
|
-
const container = picker.shadowRoot?.querySelector('.currency-picker')
|
|
360
|
-
const select = picker.shadowRoot?.querySelector('ui-select')
|
|
361
|
-
|
|
362
|
-
assert.equal(container?.getAttribute('role'), 'group')
|
|
363
|
-
assert.exists(container?.getAttribute('aria-label'))
|
|
364
|
-
assert.exists(select?.getAttribute('aria-invalid'))
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
it('should update ARIA label based on selection', async () => {
|
|
368
|
-
picker.selected = ['USD']
|
|
369
|
-
await nextFrame()
|
|
370
|
-
|
|
371
|
-
const container = picker.shadowRoot?.querySelector('.currency-picker')
|
|
372
|
-
const ariaLabel = container?.getAttribute('aria-label')
|
|
373
|
-
|
|
374
|
-
assert.include(ariaLabel || '', 'USD selected')
|
|
375
|
-
})
|
|
376
|
-
|
|
377
|
-
it('should have error announcements', async () => {
|
|
378
|
-
picker.showErrors = true
|
|
379
|
-
picker.required = true
|
|
380
|
-
picker.clearSelection()
|
|
381
|
-
await nextFrame()
|
|
382
|
-
|
|
383
|
-
const errorElement = picker.shadowRoot?.querySelector('.error')
|
|
384
|
-
assert.equal(errorElement?.getAttribute('role'), 'alert')
|
|
385
|
-
assert.equal(errorElement?.getAttribute('aria-live'), 'polite')
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
it('should be keyboard navigable', async () => {
|
|
389
|
-
const select = picker.shadowRoot?.querySelector('ui-select') as HTMLElement
|
|
390
|
-
assert.exists(select)
|
|
391
|
-
|
|
392
|
-
// Focus should work
|
|
393
|
-
select.focus()
|
|
394
|
-
assert.equal(document.activeElement, picker)
|
|
395
|
-
})
|
|
396
|
-
})
|
|
397
|
-
|
|
398
|
-
describe('Performance', () => {
|
|
399
|
-
let picker: CurrencyPicker
|
|
400
|
-
|
|
401
|
-
beforeEach(async () => {
|
|
402
|
-
picker = await basicFixture()
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
it('should handle rapid property changes efficiently', async () => {
|
|
406
|
-
const start = performance.now()
|
|
407
|
-
|
|
408
|
-
// Rapidly change properties
|
|
409
|
-
for (let i = 0; i < 100; i++) {
|
|
410
|
-
picker.selected = i % 2 === 0 ? ['USD'] : ['EUR']
|
|
411
|
-
picker.allowedCurrencies = i % 3 === 0 ? ['USD', 'EUR'] : ['USD', 'EUR', 'GBP']
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
await nextFrame()
|
|
415
|
-
const end = performance.now()
|
|
416
|
-
|
|
417
|
-
// Should complete in reasonable time (less than 100ms)
|
|
418
|
-
assert.isBelow(end - start, 100)
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
it('should not re-render unnecessarily', async () => {
|
|
422
|
-
const renderSpy = sinon.spy(picker, 'render')
|
|
423
|
-
|
|
424
|
-
// Set same values multiple times
|
|
425
|
-
picker.selected = ['USD']
|
|
426
|
-
picker.selected = ['USD']
|
|
427
|
-
picker.selected = ['USD']
|
|
428
|
-
|
|
429
|
-
await nextFrame()
|
|
430
|
-
|
|
431
|
-
// Should only render once after property stabilizes
|
|
432
|
-
assert.isAtMost(renderSpy.callCount, 2) // Initial + one update
|
|
433
|
-
|
|
434
|
-
renderSpy.restore()
|
|
435
|
-
})
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
describe('Edge Cases', () => {
|
|
439
|
-
let picker: CurrencyPicker
|
|
440
|
-
|
|
441
|
-
beforeEach(async () => {
|
|
442
|
-
picker = await basicFixture()
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
it('should handle empty arrays gracefully', async () => {
|
|
446
|
-
picker.selected = []
|
|
447
|
-
picker.allowedCurrencies = []
|
|
448
|
-
await nextFrame()
|
|
449
|
-
|
|
450
|
-
assert.deepEqual(picker.selected, [])
|
|
451
|
-
assert.deepEqual(picker.getSelectedCurrencies(), [])
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
it('should handle invalid input types', async () => {
|
|
455
|
-
const errorPromise = oneEvent(picker, 'error')
|
|
456
|
-
|
|
457
|
-
// Try to set invalid types
|
|
458
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
459
|
-
picker.selected = 'invalid' as any
|
|
460
|
-
await nextFrame()
|
|
461
|
-
|
|
462
|
-
const errorEvent = await errorPromise
|
|
463
|
-
assert.equal(errorEvent.detail.error.type, 'validation')
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
it('should handle disconnection/reconnection', async () => {
|
|
467
|
-
picker.selected = ['USD']
|
|
468
|
-
await nextFrame()
|
|
469
|
-
|
|
470
|
-
// Disconnect and reconnect
|
|
471
|
-
picker.remove()
|
|
472
|
-
document.body.appendChild(picker)
|
|
473
|
-
await nextFrame()
|
|
474
|
-
|
|
475
|
-
assert.deepEqual(picker.selected, ['USD'])
|
|
476
|
-
})
|
|
477
|
-
|
|
478
|
-
it('should handle disabled state', async () => {
|
|
479
|
-
picker.disabled = true
|
|
480
|
-
await nextFrame()
|
|
481
|
-
|
|
482
|
-
const select = picker.shadowRoot?.querySelector('ui-select')
|
|
483
|
-
assert.isTrue(select?.hasAttribute('disabled'))
|
|
484
|
-
})
|
|
485
|
-
})
|
|
486
|
-
})
|