@crowdstrike/glide-core 0.8.0 → 0.9.0
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/dist/button-group.button.d.ts +14 -15
- package/dist/button-group.button.js +1 -1
- package/dist/button-group.button.styles.js +75 -52
- package/dist/button-group.button.test.basics.d.ts +1 -1
- package/dist/button-group.button.test.basics.js +83 -147
- package/dist/button-group.button.test.events.js +8 -67
- package/dist/button-group.button.test.focus.js +13 -0
- package/dist/button-group.button.test.interactions.d.ts +1 -0
- package/dist/button-group.button.test.interactions.js +42 -0
- package/dist/button-group.d.ts +7 -10
- package/dist/button-group.js +1 -1
- package/dist/button-group.stories.d.ts +1 -5
- package/dist/button-group.styles.js +18 -6
- package/dist/button-group.test.basics.js +113 -234
- package/dist/button-group.test.events.js +210 -263
- package/dist/button-group.test.focus.d.ts +1 -0
- package/dist/button-group.test.focus.js +39 -0
- package/dist/button-group.test.interactions.d.ts +1 -0
- package/dist/button-group.test.interactions.js +91 -0
- package/dist/button.test.basics.js +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox-group.styles.js +1 -1
- package/dist/checkbox-group.test.basics.js +1 -1
- package/dist/checkbox-group.test.events.js +4 -4
- package/dist/checkbox-group.test.focus.js +4 -3
- package/dist/checkbox.d.ts +7 -1
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.styles.js +10 -0
- package/dist/checkbox.test.events.js +4 -4
- package/dist/checkbox.test.focus.js +2 -2
- package/dist/{checkbox.test.states.js → checkbox.test.interactions.js} +24 -1
- package/dist/drawer.js +1 -1
- package/dist/dropdown.d.ts +6 -4
- package/dist/dropdown.js +1 -1
- package/dist/dropdown.option.d.ts +6 -2
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +13 -0
- package/dist/dropdown.option.test.basics.js +6 -3
- package/dist/dropdown.option.test.events.js +1 -1
- package/dist/dropdown.option.test.focus.js +1 -1
- package/dist/dropdown.option.test.interactions.multiple.js +1 -54
- package/dist/dropdown.option.test.interactions.single.js +51 -9
- package/dist/dropdown.styles.js +20 -19
- package/dist/dropdown.test.basics.js +143 -2
- package/dist/dropdown.test.basics.multiple.js +5 -2
- package/dist/dropdown.test.events.filterable.js +74 -0
- package/dist/dropdown.test.events.js +49 -160
- package/dist/dropdown.test.events.multiple.js +265 -8
- package/dist/dropdown.test.events.single.js +199 -2
- package/dist/dropdown.test.focus.filterable.js +9 -5
- package/dist/dropdown.test.focus.js +1 -1
- package/dist/dropdown.test.focus.multiple.js +1 -1
- package/dist/dropdown.test.focus.single.js +1 -1
- package/dist/dropdown.test.interactions.filterable.js +68 -11
- package/dist/dropdown.test.interactions.js +94 -5
- package/dist/dropdown.test.interactions.multiple.js +202 -5
- package/dist/dropdown.test.interactions.single.js +68 -6
- package/dist/form-controls-layout.test.basics.js +1 -1
- package/dist/icon-button.test.basics.js +1 -1
- package/dist/icons/checked.d.ts +1 -1
- package/dist/icons/checked.js +1 -1
- package/dist/icons/magnifying-glass.js +1 -1
- package/dist/input.d.ts +0 -6
- package/dist/input.js +1 -1
- package/dist/input.styles.js +7 -2
- package/dist/input.test.basics.js +19 -5
- package/dist/input.test.events.js +4 -4
- package/dist/input.test.focus.js +4 -4
- package/dist/input.test.translations.d.ts +1 -0
- package/dist/input.test.translations.js +38 -0
- package/dist/input.test.validity.js +133 -4
- package/dist/label.d.ts +1 -1
- package/dist/label.js +1 -1
- package/dist/label.styles.js +22 -13
- package/dist/label.test.basics.js +26 -24
- package/dist/library/expect-argument-error.js +1 -1
- package/dist/library/localize.d.ts +3 -1
- package/dist/menu.d.ts +3 -5
- package/dist/menu.js +1 -1
- package/dist/menu.options.test.basics.js +2 -2
- package/dist/menu.styles.js +1 -15
- package/dist/menu.test.basics.d.ts +1 -2
- package/dist/menu.test.basics.js +22 -6
- package/dist/menu.test.focus.d.ts +1 -0
- package/dist/menu.test.focus.js +13 -6
- package/dist/menu.test.interactions.js +212 -56
- package/dist/modal.icon-button.test.basics.js +1 -1
- package/dist/modal.js +1 -1
- package/dist/modal.styles.js +18 -13
- package/dist/modal.tertiary-icon.d.ts +0 -1
- package/dist/modal.tertiary-icon.js +1 -1
- package/dist/modal.tertiary-icon.test.basics.js +1 -1
- package/dist/modal.test.basics.js +1 -1
- package/dist/modal.test.events.js +10 -10
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.styles.js +1 -1
- package/dist/radio-group.test.focus.js +3 -3
- package/dist/radio.d.ts +1 -0
- package/dist/radio.js +1 -1
- package/dist/radio.styles.js +33 -0
- package/dist/split-container.test.basics.js +4 -0
- package/dist/split-link.test.interactions.js +1 -1
- package/dist/styles/variables.css +1 -1
- package/dist/tab.d.ts +1 -1
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.test.basics.js +1 -1
- package/dist/tab.group.test.interactions.js +198 -2
- package/dist/tab.js +1 -1
- package/dist/tab.panel.d.ts +1 -0
- package/dist/tab.panel.js +1 -1
- package/dist/tab.panel.styles.js +11 -1
- package/dist/tag.test.basics.js +2 -2
- package/dist/textarea.d.ts +0 -1
- package/dist/textarea.js +2 -2
- package/dist/textarea.stories.d.ts +3 -4
- package/dist/textarea.styles.js +14 -3
- package/dist/textarea.test.basics.js +80 -44
- package/dist/textarea.test.events.js +56 -41
- package/dist/textarea.test.translations.d.ts +1 -0
- package/dist/textarea.test.translations.js +34 -0
- package/dist/textarea.test.validity.js +104 -20
- package/dist/toasts.js +1 -1
- package/dist/toasts.styles.js +8 -1
- package/dist/toasts.test.basics.js +20 -0
- package/dist/toggle.js +1 -1
- package/dist/toggle.test.focus.js +1 -1
- package/dist/toggle.test.interactions.d.ts +1 -0
- package/dist/tooltip.d.ts +7 -5
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +90 -25
- package/dist/tooltip.test.basics.js +38 -3
- package/dist/tooltip.test.interactions.js +136 -34
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/tree.d.ts +0 -1
- package/dist/tree.item.d.ts +1 -2
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +0 -1
- package/dist/tree.item.menu.js +1 -1
- package/dist/tree.js +1 -1
- package/dist/tree.test.basics.js +1 -1
- package/package.json +2 -4
- package/dist/drawer.test.floating-components.d.ts +0 -1
- package/dist/drawer.test.floating-components.js +0 -52
- package/dist/library/set-containing-block.d.ts +0 -15
- package/dist/library/set-containing-block.js +0 -1
- package/dist/modal.test.floating-components.js +0 -63
- /package/dist/{checkbox.test.states.d.ts → button-group.button.test.focus.d.ts} +0 -0
- /package/dist/{modal.test.floating-components.d.ts → checkbox.test.interactions.d.ts} +0 -0
- /package/dist/{toggle.test.states.d.ts → dropdown.test.events.filterable.d.ts} +0 -0
- /package/dist/{toggle.test.states.js → toggle.test.interactions.js} +0 -0
@@ -2,8 +2,163 @@
|
|
2
2
|
import './dropdown.option.js';
|
3
3
|
import * as sinon from 'sinon';
|
4
4
|
import { aTimeout, expect, fixture, html, oneEvent } from '@open-wc/testing';
|
5
|
+
import { sendKeys } from '@web/test-runner-commands';
|
5
6
|
import GlideCoreDropdown from './dropdown.js';
|
6
7
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
8
|
+
it('dispatches one "change" event when an option is selected via click', async () => {
|
9
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
10
|
+
<glide-core-dropdown-option
|
11
|
+
label="One"
|
12
|
+
value="one"
|
13
|
+
></glide-core-dropdown-option>
|
14
|
+
|
15
|
+
<glide-core-dropdown-option
|
16
|
+
label="Two"
|
17
|
+
value="two"
|
18
|
+
selected
|
19
|
+
></glide-core-dropdown-option>
|
20
|
+
</glide-core-dropdown>`);
|
21
|
+
const spy = sinon.spy();
|
22
|
+
component.addEventListener('change', spy);
|
23
|
+
setTimeout(() => {
|
24
|
+
component.querySelector('glide-core-dropdown-option')?.click();
|
25
|
+
});
|
26
|
+
const event = await oneEvent(component, 'change');
|
27
|
+
expect(event instanceof Event).to.be.true;
|
28
|
+
expect(event.bubbles).to.be.true;
|
29
|
+
expect(spy.callCount).to.equal(1);
|
30
|
+
});
|
31
|
+
it('dispatches one "change" event when an option is selected via Enter', async () => {
|
32
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
33
|
+
<glide-core-dropdown-option
|
34
|
+
label="One"
|
35
|
+
value="one"
|
36
|
+
></glide-core-dropdown-option>
|
37
|
+
|
38
|
+
<glide-core-dropdown-option
|
39
|
+
label="Two"
|
40
|
+
value="two"
|
41
|
+
selected
|
42
|
+
></glide-core-dropdown-option>
|
43
|
+
</glide-core-dropdown>`);
|
44
|
+
const spy = sinon.spy();
|
45
|
+
component.addEventListener('change', spy);
|
46
|
+
// Activate the first option before selecting it. The second option is
|
47
|
+
// currently active because it's selected.
|
48
|
+
component
|
49
|
+
.querySelector('glide-core-dropdown-option')
|
50
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
51
|
+
component.focus();
|
52
|
+
sendKeys({ press: 'Enter' });
|
53
|
+
const event = await oneEvent(component, 'change');
|
54
|
+
expect(event instanceof Event).to.be.true;
|
55
|
+
expect(event.bubbles).to.be.true;
|
56
|
+
expect(spy.callCount).to.equal(1);
|
57
|
+
});
|
58
|
+
it('dispatches one "change" event when an option is selected via Space', async () => {
|
59
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
60
|
+
<glide-core-dropdown-option
|
61
|
+
label="One"
|
62
|
+
value="one"
|
63
|
+
></glide-core-dropdown-option>
|
64
|
+
|
65
|
+
<glide-core-dropdown-option
|
66
|
+
label="Two"
|
67
|
+
value="two"
|
68
|
+
selected
|
69
|
+
></glide-core-dropdown-option>
|
70
|
+
</glide-core-dropdown>`);
|
71
|
+
const spy = sinon.spy();
|
72
|
+
component.addEventListener('change', spy);
|
73
|
+
// Activate the first option before selecting it. The second option is
|
74
|
+
// currently active because it's selected.
|
75
|
+
component
|
76
|
+
.querySelector('glide-core-dropdown-option')
|
77
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
78
|
+
component.focus();
|
79
|
+
sendKeys({ press: ' ' });
|
80
|
+
const event = await oneEvent(component, 'change');
|
81
|
+
expect(event instanceof Event).to.be.true;
|
82
|
+
expect(event.bubbles).to.be.true;
|
83
|
+
expect(spy.callCount).to.equal(1);
|
84
|
+
});
|
85
|
+
it('dispatches one "input" event when an option is selected via click', async () => {
|
86
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
87
|
+
<glide-core-dropdown-option
|
88
|
+
label="One"
|
89
|
+
value="one"
|
90
|
+
></glide-core-dropdown-option>
|
91
|
+
|
92
|
+
<glide-core-dropdown-option
|
93
|
+
label="Two"
|
94
|
+
value="two"
|
95
|
+
selected
|
96
|
+
></glide-core-dropdown-option>
|
97
|
+
</glide-core-dropdown>`);
|
98
|
+
const spy = sinon.spy();
|
99
|
+
component.addEventListener('input', spy);
|
100
|
+
setTimeout(() => {
|
101
|
+
component.querySelector('glide-core-dropdown-option')?.click();
|
102
|
+
});
|
103
|
+
const event = await oneEvent(component, 'input');
|
104
|
+
expect(event instanceof Event).to.be.true;
|
105
|
+
expect(event.bubbles).to.be.true;
|
106
|
+
expect(spy.callCount).to.equal(1);
|
107
|
+
});
|
108
|
+
it('dispatches one "input" event when an option is selected via Enter', async () => {
|
109
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
110
|
+
<glide-core-dropdown-option
|
111
|
+
label="One"
|
112
|
+
value="one"
|
113
|
+
></glide-core-dropdown-option>
|
114
|
+
|
115
|
+
<glide-core-dropdown-option
|
116
|
+
label="Two"
|
117
|
+
value="two"
|
118
|
+
selected
|
119
|
+
></glide-core-dropdown-option>
|
120
|
+
</glide-core-dropdown>`);
|
121
|
+
const spy = sinon.spy();
|
122
|
+
component.addEventListener('input', spy);
|
123
|
+
// Activate the first option before selecting it. The second option is
|
124
|
+
// currently active because it's selected.
|
125
|
+
component
|
126
|
+
.querySelector('glide-core-dropdown-option')
|
127
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
128
|
+
component.focus();
|
129
|
+
sendKeys({ press: 'Enter' });
|
130
|
+
const event = await oneEvent(component, 'input');
|
131
|
+
expect(event instanceof Event).to.be.true;
|
132
|
+
expect(event.bubbles).to.be.true;
|
133
|
+
expect(spy.callCount).to.equal(1);
|
134
|
+
});
|
135
|
+
it('dispatches one "input" event when an option is selected via Space', async () => {
|
136
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
137
|
+
<glide-core-dropdown-option
|
138
|
+
label="One"
|
139
|
+
value="one"
|
140
|
+
></glide-core-dropdown-option>
|
141
|
+
|
142
|
+
<glide-core-dropdown-option
|
143
|
+
label="Two"
|
144
|
+
value="two"
|
145
|
+
selected
|
146
|
+
></glide-core-dropdown-option>
|
147
|
+
</glide-core-dropdown>`);
|
148
|
+
const spy = sinon.spy();
|
149
|
+
component.addEventListener('input', spy);
|
150
|
+
// Activate the first option before selecting it. The second option is
|
151
|
+
// currently active because it's selected.
|
152
|
+
component
|
153
|
+
.querySelector('glide-core-dropdown-option')
|
154
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
155
|
+
component.focus();
|
156
|
+
sendKeys({ press: ' ' });
|
157
|
+
const event = await oneEvent(component, 'input');
|
158
|
+
expect(event instanceof Event).to.be.true;
|
159
|
+
expect(event.bubbles).to.be.true;
|
160
|
+
expect(spy.callCount).to.equal(1);
|
161
|
+
});
|
7
162
|
it('does not dispatch a "change" event when `value` is changed programmatically', async () => {
|
8
163
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
9
164
|
<glide-core-dropdown-option
|
@@ -23,7 +178,7 @@ it('does not dispatch a "change" event when `value` is changed programmatically'
|
|
23
178
|
component.value = ['one'];
|
24
179
|
});
|
25
180
|
await aTimeout(0);
|
26
|
-
expect(spy.
|
181
|
+
expect(spy.callCount).to.equal(0);
|
27
182
|
});
|
28
183
|
it('continues to dispatch "change" events upon selection after `value` is changed programmatically', async () => {
|
29
184
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
@@ -64,7 +219,49 @@ it('does not dispatch an "input" event when `value` is changed programmatically'
|
|
64
219
|
component.value = ['one'];
|
65
220
|
});
|
66
221
|
await aTimeout(0);
|
67
|
-
expect(spy.
|
222
|
+
expect(spy.callCount).to.equal(0);
|
223
|
+
});
|
224
|
+
it('does not dispatch a "change" event when an already selected option is selected', async () => {
|
225
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
226
|
+
<glide-core-dropdown-option
|
227
|
+
label="One"
|
228
|
+
value="one"
|
229
|
+
selected
|
230
|
+
></glide-core-dropdown-option>
|
231
|
+
|
232
|
+
<glide-core-dropdown-option
|
233
|
+
label="Two"
|
234
|
+
value="two"
|
235
|
+
></glide-core-dropdown-option>
|
236
|
+
</glide-core-dropdown>`);
|
237
|
+
const spy = sinon.spy();
|
238
|
+
component.addEventListener('change', spy);
|
239
|
+
setTimeout(() => {
|
240
|
+
component.querySelector('glide-core-dropdown-option')?.click();
|
241
|
+
});
|
242
|
+
await aTimeout(0);
|
243
|
+
expect(spy.callCount).to.equal(0);
|
244
|
+
});
|
245
|
+
it('does not dispatch an "input" event when an already selected option is selected', async () => {
|
246
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
247
|
+
<glide-core-dropdown-option
|
248
|
+
label="One"
|
249
|
+
value="one"
|
250
|
+
selected
|
251
|
+
></glide-core-dropdown-option>
|
252
|
+
|
253
|
+
<glide-core-dropdown-option
|
254
|
+
label="Two"
|
255
|
+
value="two"
|
256
|
+
></glide-core-dropdown-option>
|
257
|
+
</glide-core-dropdown>`);
|
258
|
+
const spy = sinon.spy();
|
259
|
+
component.addEventListener('input', spy);
|
260
|
+
setTimeout(() => {
|
261
|
+
component.querySelector('glide-core-dropdown-option')?.click();
|
262
|
+
});
|
263
|
+
await aTimeout(0);
|
264
|
+
expect(spy.callCount).to.equal(0);
|
68
265
|
});
|
69
266
|
it('continues to dispatch "input" events upon selection after `value` is changed programmatically', async () => {
|
70
267
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import './dropdown.option.js';
|
2
|
-
import { assert, expect, fixture, html } from '@open-wc/testing';
|
2
|
+
import { aTimeout, assert, expect, fixture, html } from '@open-wc/testing';
|
3
3
|
import { sendMouse } from '@web/test-runner-commands';
|
4
4
|
import GlideCoreDropdown from './dropdown.js';
|
5
5
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
@@ -61,7 +61,7 @@ const defaultSlot = html `
|
|
61
61
|
value="eleven"
|
62
62
|
></glide-core-dropdown-option>
|
63
63
|
`;
|
64
|
-
it('focuses the input when `focus` is called', async () => {
|
64
|
+
it('focuses the input when `focus()` is called', async () => {
|
65
65
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
66
66
|
${defaultSlot}
|
67
67
|
</glide-core-dropdown>`);
|
@@ -78,12 +78,14 @@ it('retains focus on the input when an option is selected via click', async () =
|
|
78
78
|
>
|
79
79
|
${defaultSlot}
|
80
80
|
</glide-core-dropdown>`);
|
81
|
+
// Wait for it to open.
|
82
|
+
await aTimeout(0);
|
81
83
|
component.focus();
|
82
84
|
const option = component.querySelector('glide-core-dropdown-option');
|
83
85
|
assert(option);
|
84
86
|
const { x, y } = option.getBoundingClientRect();
|
85
87
|
// A simple `option.click()` won't do because we need a "mousedown" so that
|
86
|
-
// `#onOptionsMousedown`
|
88
|
+
// `#onOptionsMousedown` is covered.
|
87
89
|
await sendMouse({
|
88
90
|
type: 'click',
|
89
91
|
position: [Math.ceil(x), Math.ceil(y)],
|
@@ -92,9 +94,11 @@ it('retains focus on the input when an option is selected via click', async () =
|
|
92
94
|
expect(component.shadowRoot?.activeElement).to.equal(input);
|
93
95
|
});
|
94
96
|
it('retains focus on the the input when an option is selected via Enter', async () => {
|
95
|
-
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
97
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
96
98
|
${defaultSlot}
|
97
99
|
</glide-core-dropdown>`);
|
100
|
+
// Wait for it to open.
|
101
|
+
await aTimeout(0);
|
98
102
|
component.focus();
|
99
103
|
component
|
100
104
|
.querySelector('glide-core-dropdown-option')
|
@@ -104,7 +108,7 @@ it('retains focus on the the input when an option is selected via Enter', async
|
|
104
108
|
expect(component.shadowRoot?.activeElement).to.equal(input);
|
105
109
|
});
|
106
110
|
it('retains focus on the the input when the button is clicked', async () => {
|
107
|
-
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
111
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
108
112
|
${defaultSlot}
|
109
113
|
</glide-core-dropdown>`);
|
110
114
|
component.focus();
|
@@ -33,5 +33,5 @@ it('closes and reports validity when it loses focus', async () => {
|
|
33
33
|
expect(component.open).to.be.false;
|
34
34
|
expect(component.shadowRoot?.activeElement).to.equal(null);
|
35
35
|
expect(component.validity.valid).to.equal(false);
|
36
|
-
expect(component.shadowRoot?.querySelector('glide-core-label')?.error).to.equal(true);
|
36
|
+
expect(component.shadowRoot?.querySelector('glide-core-private-label')?.error).to.equal(true);
|
37
37
|
});
|
@@ -4,7 +4,7 @@ import GlideCoreDropdown from './dropdown.js';
|
|
4
4
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
5
5
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
6
6
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
|
-
it('focuses the button when `focus` is called', async () => {
|
7
|
+
it('focuses the button when `focus()` is called', async () => {
|
8
8
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
9
9
|
<glide-core-dropdown-option
|
10
10
|
label="One"
|
@@ -4,7 +4,7 @@ import GlideCoreDropdown from './dropdown.js';
|
|
4
4
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
5
5
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
6
6
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
|
-
it('focuses the button when `focus` is called', async () => {
|
7
|
+
it('focuses the button when `focus()` is called', async () => {
|
8
8
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
9
9
|
<glide-core-dropdown-option
|
10
10
|
label="Label"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
|
-
import { assert, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
2
|
+
import { aTimeout, assert, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
3
3
|
import { sendKeys } from '@web/test-runner-commands';
|
4
4
|
import GlideCoreDropdown from './dropdown.js';
|
5
5
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
@@ -72,7 +72,11 @@ it('opens on click', async () => {
|
|
72
72
|
component.shadowRoot
|
73
73
|
?.querySelector('[data-test="input"]')
|
74
74
|
?.dispatchEvent(new CustomEvent('click', { bubbles: true, detail: 1 }));
|
75
|
+
// Wait for it to open.
|
76
|
+
await aTimeout(0);
|
77
|
+
const options = component.shadowRoot?.querySelector('[data-test="options"]');
|
75
78
|
expect(component.open).to.be.true;
|
79
|
+
expect(options?.checkVisibility()).to.be.true;
|
76
80
|
});
|
77
81
|
it('filters', async () => {
|
78
82
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
@@ -85,10 +89,12 @@ it('filters', async () => {
|
|
85
89
|
].filter(({ hidden }) => !hidden);
|
86
90
|
expect(options.length).to.equal(1);
|
87
91
|
});
|
88
|
-
it('
|
92
|
+
it('unfilters when an option is selected via click', async () => {
|
89
93
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
90
94
|
${defaultSlot}
|
91
95
|
</glide-core-dropdown>`);
|
96
|
+
// Wait for it to open.
|
97
|
+
await aTimeout(0);
|
92
98
|
component.focus();
|
93
99
|
await sendKeys({ type: ' one ' });
|
94
100
|
const option = [
|
@@ -102,6 +108,20 @@ it('clears the filter term when an option is selected', async () => {
|
|
102
108
|
expect(input?.value).to.equal('');
|
103
109
|
expect(options.length).to.equal(11);
|
104
110
|
});
|
111
|
+
it('unfilters when an option is selected via Enter', async () => {
|
112
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
113
|
+
${defaultSlot}
|
114
|
+
</glide-core-dropdown>`);
|
115
|
+
component.focus();
|
116
|
+
await sendKeys({ type: ' one ' });
|
117
|
+
await sendKeys({ press: 'Enter' });
|
118
|
+
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
119
|
+
const options = [
|
120
|
+
...component.querySelectorAll('glide-core-dropdown-option'),
|
121
|
+
].filter(({ hidden }) => !hidden);
|
122
|
+
expect(input?.value).to.equal('');
|
123
|
+
expect(options.length).to.equal(11);
|
124
|
+
});
|
105
125
|
it('shows the magnifying glass icon when there is a filter term', async () => {
|
106
126
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
107
127
|
${defaultSlot}
|
@@ -119,9 +139,11 @@ it('hides the magnifying glass icon when there is no filter term', async () => {
|
|
119
139
|
expect(icon?.checkVisibility()).to.be.not.ok;
|
120
140
|
});
|
121
141
|
it('hides the magnifying glass icon when an option is selected', async () => {
|
122
|
-
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
142
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
123
143
|
${defaultSlot}
|
124
144
|
</glide-core-dropdown>`);
|
145
|
+
// Wait for it to open.
|
146
|
+
await aTimeout(0);
|
125
147
|
component.focus();
|
126
148
|
await sendKeys({ type: ' one ' });
|
127
149
|
const option = [
|
@@ -147,10 +169,14 @@ it('hides the options when all of them are filtered out', async () => {
|
|
147
169
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
148
170
|
${defaultSlot}
|
149
171
|
</glide-core-dropdown>`);
|
172
|
+
// Wait for it to open.
|
173
|
+
await aTimeout(0);
|
150
174
|
component.focus();
|
151
|
-
await sendKeys({ type: '
|
175
|
+
await sendKeys({ type: 'fifty' });
|
176
|
+
// Wait for it to close.
|
177
|
+
await aTimeout(0);
|
152
178
|
const options = component.shadowRoot?.querySelector('[data-test="options"]');
|
153
|
-
expect(options?.
|
179
|
+
expect(options?.checkVisibility()).to.be.false;
|
154
180
|
});
|
155
181
|
it('hides Select All when filtering', async () => {
|
156
182
|
const component = await fixture(html `<glide-core-dropdown
|
@@ -194,6 +220,20 @@ it('updates `value` when an option `value` is changed programmatically', async (
|
|
194
220
|
option.value = 'two';
|
195
221
|
expect(component.value).to.deep.equal(['two']);
|
196
222
|
});
|
223
|
+
it('does not select options on Space', async () => {
|
224
|
+
const component = await fixture(html `<glide-core-dropdown
|
225
|
+
label="Label"
|
226
|
+
placeholder="Placeholder"
|
227
|
+
multiple
|
228
|
+
open
|
229
|
+
>
|
230
|
+
${defaultSlot}
|
231
|
+
</glide-core-dropdown>`);
|
232
|
+
const options = component.querySelectorAll('glide-core-dropdown-option');
|
233
|
+
options[0]?.focus();
|
234
|
+
await sendKeys({ press: ' ' });
|
235
|
+
expect(options[0]?.selected).to.be.false;
|
236
|
+
});
|
197
237
|
it('deselects options on Backspace', async () => {
|
198
238
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
199
239
|
${defaultSlot}
|
@@ -244,6 +284,8 @@ it('sets `aria-activedescendant` on ArrowDown', async () => {
|
|
244
284
|
>
|
245
285
|
${defaultSlot}
|
246
286
|
</glide-core-dropdown>`);
|
287
|
+
// Wait for it to open.
|
288
|
+
await aTimeout(0);
|
247
289
|
const options = component.querySelectorAll('glide-core-dropdown-option');
|
248
290
|
options[0]?.focus();
|
249
291
|
await sendKeys({ press: 'ArrowDown' });
|
@@ -259,6 +301,8 @@ it('sets `aria-activedescendant` on ArrowUp', async () => {
|
|
259
301
|
>
|
260
302
|
${defaultSlot}
|
261
303
|
</glide-core-dropdown>`);
|
304
|
+
// Wait for it to open.
|
305
|
+
await aTimeout(0);
|
262
306
|
const options = component.querySelectorAll('glide-core-dropdown-option');
|
263
307
|
options[1]?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
264
308
|
options[1]?.focus();
|
@@ -275,6 +319,8 @@ it('sets `aria-activedescendant` on Home', async () => {
|
|
275
319
|
>
|
276
320
|
${defaultSlot}
|
277
321
|
</glide-core-dropdown>`);
|
322
|
+
// Wait for it to open.
|
323
|
+
await aTimeout(0);
|
278
324
|
const options = component.querySelectorAll('glide-core-dropdown-option');
|
279
325
|
options[1]?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
280
326
|
options[1].focus();
|
@@ -291,6 +337,8 @@ it('sets `aria-activedescendant` on PageUp', async () => {
|
|
291
337
|
>
|
292
338
|
${defaultSlot}
|
293
339
|
</glide-core-dropdown>`);
|
340
|
+
// Wait for it to open.
|
341
|
+
await aTimeout(0);
|
294
342
|
const options = component.querySelectorAll('glide-core-dropdown-option');
|
295
343
|
options[1].dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
296
344
|
options[1].focus();
|
@@ -298,7 +346,7 @@ it('sets `aria-activedescendant` on PageUp', async () => {
|
|
298
346
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
299
347
|
expect(input?.getAttribute('aria-activedescendant')).to.equal(options[0].id);
|
300
348
|
});
|
301
|
-
it('sets `aria-activedescendant` on
|
349
|
+
it('sets `aria-activedescendant` on Meta + ArrowUp', async () => {
|
302
350
|
const component = await fixture(html `<glide-core-dropdown
|
303
351
|
label="Label"
|
304
352
|
placeholder="Placeholder"
|
@@ -307,9 +355,11 @@ it('sets `aria-activedescendant` on ArrowUp + Meta', async () => {
|
|
307
355
|
>
|
308
356
|
${defaultSlot}
|
309
357
|
</glide-core-dropdown>`);
|
358
|
+
// Wait for it to open.
|
359
|
+
await aTimeout(0);
|
360
|
+
component.focus();
|
310
361
|
const options = component.querySelectorAll('glide-core-dropdown-option');
|
311
362
|
options[1]?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
312
|
-
options[1].focus();
|
313
363
|
await sendKeys({ down: 'Meta' });
|
314
364
|
await sendKeys({ press: 'ArrowUp' });
|
315
365
|
await sendKeys({ up: 'Meta' });
|
@@ -327,7 +377,8 @@ it('sets `aria-activedescendant` on open via click', async () => {
|
|
327
377
|
component.shadowRoot
|
328
378
|
?.querySelector('[data-test="button"]')
|
329
379
|
?.dispatchEvent(new CustomEvent('click', { bubbles: true, detail: 1 }));
|
330
|
-
|
380
|
+
// Wait for it to open.
|
381
|
+
await aTimeout(0);
|
331
382
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
332
383
|
const option = component.querySelector('glide-core-dropdown-option');
|
333
384
|
expect(input?.getAttribute('aria-activedescendant')).to.equal(option?.id);
|
@@ -351,11 +402,13 @@ it('sets `aria-activedescendant` on End', async () => {
|
|
351
402
|
>
|
352
403
|
${defaultSlot}
|
353
404
|
</glide-core-dropdown>`);
|
405
|
+
// Wait for it to open.
|
406
|
+
await aTimeout(0);
|
407
|
+
component.focus();
|
354
408
|
// Made into an array because the linter forces `at(-1)` instead of
|
355
409
|
// `[options.length - 1]` but doesn't take into account that `options`
|
356
410
|
// isn't an actual array and doesn't have an `at()` method.
|
357
411
|
const options = [...component.querySelectorAll('glide-core-dropdown-option')];
|
358
|
-
options[0]?.focus();
|
359
412
|
await sendKeys({ press: 'End' });
|
360
413
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
361
414
|
expect(input?.getAttribute('aria-activedescendant')).to.equal(options.at(-1)?.id);
|
@@ -369,11 +422,13 @@ it('sets `aria-activedescendant` on PageDown', async () => {
|
|
369
422
|
>
|
370
423
|
${defaultSlot}
|
371
424
|
</glide-core-dropdown>`);
|
425
|
+
// Wait for it to open.
|
426
|
+
await aTimeout(0);
|
427
|
+
component.focus();
|
372
428
|
// Made into an array because the linter forces `at(-1)` instead of
|
373
429
|
// `[options.length - 1]` but doesn't take into account that `options`
|
374
430
|
// isn't an actual array and doesn't have an `at()` method.
|
375
431
|
const options = [...component.querySelectorAll('glide-core-dropdown-option')];
|
376
|
-
options[0]?.focus();
|
377
432
|
await sendKeys({ press: 'PageDown' });
|
378
433
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
379
434
|
expect(input?.getAttribute('aria-activedescendant')).to.equal(options.at(-1)?.id);
|
@@ -387,11 +442,13 @@ it('sets `aria-activedescendant` on Meta + ArrowDown', async () => {
|
|
387
442
|
>
|
388
443
|
${defaultSlot}
|
389
444
|
</glide-core-dropdown>`);
|
445
|
+
// Wait for it to open.
|
446
|
+
await aTimeout(0);
|
447
|
+
component.focus();
|
390
448
|
// Spread into an array because the linter forces `at(-1)` instead of
|
391
449
|
// `[options.length - 1]` but doesn't take into account that `options`
|
392
450
|
// isn't an actual array and doesn't have an `at()` method.
|
393
451
|
const options = [...component.querySelectorAll('glide-core-dropdown-option')];
|
394
|
-
options[0]?.focus();
|
395
452
|
await sendKeys({ down: 'Meta' });
|
396
453
|
await sendKeys({ press: 'ArrowDown' });
|
397
454
|
await sendKeys({ up: 'Meta' });
|