@crowdstrike/glide-core 0.9.0 → 0.9.2
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/accordion.d.ts +7 -3
- package/dist/accordion.styles.js +2 -4
- package/dist/button-group.button.d.ts +1 -4
- package/dist/button-group.button.styles.js +4 -8
- package/dist/button-group.d.ts +3 -0
- package/dist/button-group.styles.js +2 -2
- package/dist/button.d.ts +4 -0
- package/dist/button.js +1 -1
- package/dist/button.styles.js +2 -4
- package/dist/button.test.events.js +86 -10
- package/dist/checkbox-group.d.ts +6 -2
- package/dist/checkbox-group.stories.d.ts +1 -1
- package/dist/checkbox.d.ts +5 -4
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.stories.d.ts +1 -1
- package/dist/checkbox.styles.js +43 -6
- package/dist/checkbox.test.basics.js +15 -6
- package/dist/checkbox.test.events.js +12 -4
- package/dist/checkbox.test.focus.js +1 -1
- package/dist/checkbox.test.form.js +17 -0
- package/dist/checkbox.test.interactions.js +52 -7
- package/dist/drawer.d.ts +5 -5
- package/dist/drawer.js +1 -1
- package/dist/drawer.stories.d.ts +0 -1
- package/dist/dropdown.d.ts +7 -4
- package/dist/dropdown.js +1 -1
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +1 -0
- package/dist/dropdown.styles.js +47 -26
- package/dist/dropdown.test.focus.filterable.js +20 -0
- package/dist/dropdown.test.focus.js +1 -0
- package/dist/dropdown.test.form.js +23 -112
- package/dist/dropdown.test.interactions.filterable.js +121 -17
- package/dist/dropdown.test.interactions.multiple.js +15 -22
- package/dist/dropdown.test.interactions.single.js +44 -22
- package/dist/icon-button.d.ts +2 -0
- package/dist/icon-button.styles.js +2 -4
- package/dist/icons/checked.d.ts +5 -0
- package/dist/icons/checked.js +1 -1
- package/dist/input.d.ts +5 -4
- package/dist/input.js +1 -1
- package/dist/input.stories.d.ts +0 -4
- package/dist/input.styles.d.ts +1 -1
- package/dist/input.styles.js +93 -93
- package/dist/input.test.basics.js +45 -45
- package/dist/input.test.form.js +17 -0
- package/dist/label.styles.js +11 -13
- package/dist/library/localize.d.ts +1 -0
- package/dist/library/localize.test.js +45 -0
- package/dist/menu.button.styles.js +1 -0
- package/dist/menu.js +1 -1
- package/dist/menu.link.styles.js +1 -0
- package/dist/menu.styles.js +3 -1
- package/dist/menu.test.events.js +101 -7
- package/dist/menu.test.focus.js +26 -3
- package/dist/menu.test.interactions.js +5 -2
- package/dist/modal.d.ts +0 -7
- package/dist/modal.icon-button.test.basics.js +9 -9
- package/dist/modal.stories.d.ts +1 -0
- package/dist/modal.styles.js +2 -4
- package/dist/modal.tertiary-icon.test.basics.js +15 -15
- package/dist/modal.test.accessibility.js +16 -27
- package/dist/modal.test.basics.js +64 -68
- package/dist/modal.test.close.js +12 -16
- package/dist/modal.test.events.js +32 -44
- package/dist/modal.test.lock-scroll.js +15 -25
- package/dist/modal.test.methods.js +8 -12
- package/dist/modal.test.scrollbars.js +2 -4
- package/dist/radio-group.d.ts +4 -3
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.stories.d.ts +1 -1
- package/dist/radio-group.test.basics.js +3 -3
- package/dist/radio-group.test.events.js +6 -6
- package/dist/radio-group.test.form.js +19 -0
- package/dist/radio.d.ts +1 -2
- package/dist/radio.js +1 -1
- package/dist/radio.styles.js +2 -6
- package/dist/split-button.styles.js +2 -4
- package/dist/split-container.d.ts +1 -1
- package/dist/split-container.styles.js +2 -4
- package/dist/status-indicator.d.ts +1 -1
- package/dist/styles/focus-outline.d.ts +1 -1
- package/dist/styles/focus-outline.js +7 -1
- package/dist/styles/menu-opening-animation.d.ts +2 -0
- package/dist/styles/menu-opening-animation.js +26 -0
- package/dist/styles/variables.css +1 -1
- package/dist/styles/visually-hidden.d.ts +1 -1
- package/dist/styles/visually-hidden.js +14 -1
- package/dist/tab.group.d.ts +6 -6
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.styles.js +46 -5
- package/dist/tab.group.test.basics.js +9 -2
- package/dist/tab.group.test.interactions.js +70 -93
- package/dist/tab.js +1 -1
- package/dist/tab.panel.styles.js +3 -9
- package/dist/tab.styles.js +6 -13
- package/dist/tab.test.basics.js +15 -17
- package/dist/tabs.stories.d.ts +1 -0
- package/dist/tag.d.ts +3 -6
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +2 -4
- package/dist/tag.test.basics.js +28 -27
- package/dist/tag.test.events.js +3 -3
- package/dist/tag.test.focus.js +4 -4
- package/dist/textarea.d.ts +5 -4
- package/dist/textarea.stories.d.ts +0 -4
- package/dist/textarea.styles.d.ts +1 -1
- package/dist/textarea.styles.js +63 -67
- package/dist/textarea.test.basics.js +52 -52
- package/dist/toasts.d.ts +5 -0
- package/dist/toasts.styles.js +1 -1
- package/dist/toggle.d.ts +3 -3
- package/dist/toggle.js +1 -1
- package/dist/toggle.stories.d.ts +1 -1
- package/dist/toggle.styles.js +2 -1
- package/dist/toggle.test.interactions.js +37 -0
- package/dist/tooltip.d.ts +2 -2
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +22 -18
- package/dist/tooltip.test.interactions.js +6 -6
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.d.ts +3 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.d.ts +3 -1
- package/dist/translations/ja.js +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.item.d.ts +0 -3
- package/dist/tree.item.icon-button.d.ts +1 -0
- package/dist/tree.item.icon-button.js +1 -1
- package/dist/tree.item.icon-button.test.basics.js +9 -0
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +2 -0
- package/dist/tree.item.menu.js +1 -1
- package/dist/tree.item.menu.test.basics.js +15 -0
- package/dist/tree.item.styles.js +13 -3
- package/dist/tree.item.test.basics.d.ts +2 -1
- package/dist/tree.item.test.basics.js +16 -4
- package/dist/tree.js +1 -1
- package/dist/tree.test.focus.js +91 -4
- package/package.json +2 -1
- package/dist/button.test.form.d.ts +0 -1
- package/dist/button.test.form.js +0 -50
- package/dist/input.test.translations.js +0 -38
- package/dist/tag.test.translations.d.ts +0 -1
- package/dist/tag.test.translations.js +0 -25
- package/dist/textarea.test.translations.d.ts +0 -1
- package/dist/textarea.test.translations.js +0 -34
- /package/dist/{input.test.translations.d.ts → library/localize.test.d.ts} +0 -0
package/dist/menu.test.events.js
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
import './menu.js';
|
3
3
|
import './menu.link.js';
|
4
4
|
import './menu.options.js';
|
5
|
-
import { expect, fixture, html, oneEvent } from '@open-wc/testing';
|
6
|
-
|
5
|
+
import { assert, expect, fixture, html, oneEvent } from '@open-wc/testing';
|
6
|
+
import { sendKeys } from '@web/test-runner-commands';
|
7
|
+
import sinon from 'sinon';
|
8
|
+
it('dispatches one link "click" event when a link is selected via click', async () => {
|
7
9
|
const component = await fixture(html `<glide-core-menu open>
|
8
10
|
<button slot="target">Target</button>
|
9
11
|
|
@@ -11,21 +13,113 @@ it('dispatches a "click" event when a link is clicked', async () => {
|
|
11
13
|
<glide-core-menu-link label="Link"></glide-core-menu-link>
|
12
14
|
</glide-core-menu-options>
|
13
15
|
</glide-core-menu>`);
|
14
|
-
|
16
|
+
const spy = sinon.spy();
|
17
|
+
const link = component.querySelector('glide-core-menu-link');
|
18
|
+
assert(link);
|
19
|
+
link.addEventListener('click', spy);
|
20
|
+
setTimeout(() => link.click());
|
15
21
|
const event = await oneEvent(component, 'click');
|
16
22
|
expect(event instanceof PointerEvent).to.be.true;
|
17
23
|
expect(event.bubbles).to.be.true;
|
24
|
+
expect(event.target).to.equal(link);
|
25
|
+
expect(spy.callCount).to.equal(1);
|
18
26
|
});
|
19
|
-
it('dispatches
|
27
|
+
it('dispatches one button "click" event when a button is selected via click', async () => {
|
20
28
|
const component = await fixture(html `<glide-core-menu open>
|
21
29
|
<button slot="target">Target</button>
|
22
30
|
|
23
31
|
<glide-core-menu-options>
|
24
|
-
<glide-core-menu-button label="
|
32
|
+
<glide-core-menu-button label="Button"></glide-core-menu-button>
|
25
33
|
</glide-core-menu-options>
|
26
34
|
</glide-core-menu>`);
|
27
|
-
|
28
|
-
const
|
35
|
+
const spy = sinon.spy();
|
36
|
+
const button = component.querySelector('glide-core-menu-button');
|
37
|
+
assert(button);
|
38
|
+
button.addEventListener('click', spy);
|
39
|
+
setTimeout(() => button.click());
|
40
|
+
const event = await oneEvent(button, 'click');
|
41
|
+
expect(event instanceof PointerEvent).to.be.true;
|
42
|
+
expect(event.bubbles).to.be.true;
|
43
|
+
expect(event.target).to.equal(button);
|
44
|
+
expect(spy.callCount).to.equal(1);
|
45
|
+
});
|
46
|
+
it('dispatches one link "click" event when a link is selected via Space', async () => {
|
47
|
+
const component = await fixture(html `<glide-core-menu open>
|
48
|
+
<button slot="target">Target</button>
|
49
|
+
|
50
|
+
<glide-core-menu-options>
|
51
|
+
<glide-core-menu-link label="Link"></glide-core-menu-link>
|
52
|
+
</glide-core-menu-options>
|
53
|
+
</glide-core-menu>`);
|
54
|
+
const spy = sinon.spy();
|
55
|
+
const link = component.querySelector('glide-core-menu-link');
|
56
|
+
assert(link);
|
57
|
+
link.addEventListener('click', spy);
|
58
|
+
component.focus();
|
59
|
+
sendKeys({ press: 'Space' });
|
60
|
+
const event = await oneEvent(link, 'click');
|
61
|
+
expect(event instanceof PointerEvent).to.be.true;
|
62
|
+
expect(event.bubbles).to.be.true;
|
63
|
+
expect(event.target).to.equal(link);
|
64
|
+
expect(spy.callCount).to.equal(1);
|
65
|
+
});
|
66
|
+
it('dispatches one button "click" event when a button is selected via Space', async () => {
|
67
|
+
const component = await fixture(html `<glide-core-menu open>
|
68
|
+
<button slot="target">Target</button>
|
69
|
+
|
70
|
+
<glide-core-menu-options>
|
71
|
+
<glide-core-menu-button label="Button"></glide-core-menu-button>
|
72
|
+
</glide-core-menu-options>
|
73
|
+
</glide-core-menu>`);
|
74
|
+
const spy = sinon.spy();
|
75
|
+
const button = component.querySelector('glide-core-menu-button');
|
76
|
+
assert(button);
|
77
|
+
button.addEventListener('click', spy);
|
78
|
+
component.focus();
|
79
|
+
sendKeys({ press: 'Space' });
|
80
|
+
const event = await oneEvent(button, 'click');
|
81
|
+
expect(event instanceof PointerEvent).to.be.true;
|
82
|
+
expect(event.bubbles).to.be.true;
|
83
|
+
expect(event.target).to.equal(button);
|
84
|
+
expect(spy.callCount).to.equal(1);
|
85
|
+
});
|
86
|
+
it('dispatches one link "click" event when a link is selected via Enter', async () => {
|
87
|
+
const component = await fixture(html `<glide-core-menu open>
|
88
|
+
<button slot="target">Target</button>
|
89
|
+
|
90
|
+
<glide-core-menu-options>
|
91
|
+
<glide-core-menu-link label="Link"></glide-core-menu-link>
|
92
|
+
</glide-core-menu-options>
|
93
|
+
</glide-core-menu>`);
|
94
|
+
const spy = sinon.spy();
|
95
|
+
const link = component.querySelector('glide-core-menu-link');
|
96
|
+
assert(link);
|
97
|
+
link.addEventListener('click', spy);
|
98
|
+
component.focus();
|
99
|
+
sendKeys({ press: 'Enter' });
|
100
|
+
const event = await oneEvent(link, 'click');
|
101
|
+
expect(event instanceof PointerEvent).to.be.true;
|
102
|
+
expect(event.bubbles).to.be.true;
|
103
|
+
expect(event.target).to.equal(link);
|
104
|
+
expect(spy.callCount).to.equal(1);
|
105
|
+
});
|
106
|
+
it('dispatches one button "click" event when a button is selected via Enter', async () => {
|
107
|
+
const component = await fixture(html `<glide-core-menu open>
|
108
|
+
<button slot="target">Target</button>
|
109
|
+
|
110
|
+
<glide-core-menu-options>
|
111
|
+
<glide-core-menu-button label="Button"></glide-core-menu-button>
|
112
|
+
</glide-core-menu-options>
|
113
|
+
</glide-core-menu>`);
|
114
|
+
const spy = sinon.spy();
|
115
|
+
const button = component.querySelector('glide-core-menu-button');
|
116
|
+
assert(button);
|
117
|
+
button.addEventListener('click', spy);
|
118
|
+
component.focus();
|
119
|
+
sendKeys({ press: 'Enter' });
|
120
|
+
const event = await oneEvent(button, 'click');
|
29
121
|
expect(event instanceof PointerEvent).to.be.true;
|
30
122
|
expect(event.bubbles).to.be.true;
|
123
|
+
expect(event.target).to.equal(button);
|
124
|
+
expect(spy.callCount).to.equal(1);
|
31
125
|
});
|
package/dist/menu.test.focus.js
CHANGED
@@ -69,7 +69,7 @@ it('remains open when an option is focused', async () => {
|
|
69
69
|
expect(component.open).to.be.true;
|
70
70
|
expect(defaultSlot?.checkVisibility()).to.be.true;
|
71
71
|
});
|
72
|
-
it('sets
|
72
|
+
it('sets an inactive option as active when focused', async () => {
|
73
73
|
const component = await fixture(html `<glide-core-menu open>
|
74
74
|
<button slot="target">Target</button>
|
75
75
|
|
@@ -81,12 +81,35 @@ it('sets the focused option as active', async () => {
|
|
81
81
|
// Wait for Floating UI.
|
82
82
|
await aTimeout(0);
|
83
83
|
component.focus();
|
84
|
-
const
|
84
|
+
const button = component.querySelector('glide-core-menu-button');
|
85
85
|
const link = component.querySelector('glide-core-menu-link');
|
86
86
|
const options = component.querySelector('glide-core-menu-options');
|
87
87
|
link?.focus();
|
88
88
|
await elementUpdated(component);
|
89
|
-
expect(target?.privateActive).to.be.false;
|
90
89
|
expect(link?.privateActive).to.be.true;
|
90
|
+
expect(button?.privateActive).to.be.false;
|
91
91
|
expect(options?.getAttribute('aria-activedescendant')).to.equal(link?.id);
|
92
92
|
});
|
93
|
+
// Kind of an odd test. There's a comment in `#onDefaultSlotFocusin` that
|
94
|
+
// explains it.
|
95
|
+
it('sets an already active option as active when focused', async () => {
|
96
|
+
const component = await fixture(html `<glide-core-menu open>
|
97
|
+
<button slot="target">Target</button>
|
98
|
+
|
99
|
+
<glide-core-menu-options>
|
100
|
+
<glide-core-menu-button label="Button"></glide-core-menu-button>
|
101
|
+
<glide-core-menu-link label="Link"></glide-core-menu-link>
|
102
|
+
</glide-core-menu-options>
|
103
|
+
</glide-core-menu>`);
|
104
|
+
// Wait for Floating UI.
|
105
|
+
await aTimeout(0);
|
106
|
+
component.focus();
|
107
|
+
const button = component.querySelector('glide-core-menu-button');
|
108
|
+
const link = component.querySelector('glide-core-menu-link');
|
109
|
+
const options = component.querySelector('glide-core-menu-options');
|
110
|
+
button?.focus();
|
111
|
+
await elementUpdated(component);
|
112
|
+
expect(button?.privateActive).to.be.true;
|
113
|
+
expect(link?.privateActive).to.be.false;
|
114
|
+
expect(options?.getAttribute('aria-activedescendant')).to.equal(button?.id);
|
115
|
+
});
|
@@ -412,7 +412,7 @@ it('closes when something outside of it is clicked', async () => {
|
|
412
412
|
expect(options?.getAttribute('aria-activedescendant')).to.equal('');
|
413
413
|
expect(target?.ariaExpanded).to.equal('false');
|
414
414
|
});
|
415
|
-
it('closes on Escape
|
415
|
+
it('closes on Escape', async () => {
|
416
416
|
const component = await fixture(html `<glide-core-menu open>
|
417
417
|
<button slot="target">Target</button>
|
418
418
|
|
@@ -422,7 +422,7 @@ it('closes on Escape when the button has focus', async () => {
|
|
422
422
|
</glide-core-menu>`);
|
423
423
|
// Wait for it to open
|
424
424
|
await aTimeout(0);
|
425
|
-
component.
|
425
|
+
component.focus();
|
426
426
|
await sendKeys({ press: 'Escape' });
|
427
427
|
const defaultSlot = component?.shadowRoot?.querySelector('slot:not([name])');
|
428
428
|
const options = component.querySelector('glide-core-menu-options');
|
@@ -712,6 +712,7 @@ it('activates the first option on Meta + ArrowUp', async () => {
|
|
712
712
|
links[1].dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
713
713
|
await sendKeys({ down: 'Meta' });
|
714
714
|
await sendKeys({ press: 'ArrowUp' });
|
715
|
+
await sendKeys({ up: 'Meta' });
|
715
716
|
expect(links[0].privateActive).to.be.true;
|
716
717
|
expect(links[1].privateActive).to.be.false;
|
717
718
|
expect(options?.getAttribute('aria-activedescendant')).to.equal(links[0].id);
|
@@ -872,6 +873,7 @@ it('does not wrap on Meta + ArrowUp', async () => {
|
|
872
873
|
await aTimeout(0);
|
873
874
|
await sendKeys({ down: 'Meta' });
|
874
875
|
await sendKeys({ press: 'ArrowUp' });
|
876
|
+
await sendKeys({ up: 'Meta' });
|
875
877
|
const link = component.querySelector('glide-core-menu-link');
|
876
878
|
expect(link?.privateActive).to.be.true;
|
877
879
|
});
|
@@ -910,5 +912,6 @@ it('does not wrap on ArrowDown', async () => {
|
|
910
912
|
options[1].dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
911
913
|
await sendKeys({ down: 'Meta' });
|
912
914
|
await sendKeys({ press: 'ArrowDown' });
|
915
|
+
await sendKeys({ up: 'Meta' });
|
913
916
|
expect(options[1].privateActive).to.be.true;
|
914
917
|
});
|
package/dist/modal.d.ts
CHANGED
@@ -10,10 +10,6 @@ declare global {
|
|
10
10
|
*
|
11
11
|
* @event close - Emitted when the Modal closes.
|
12
12
|
*
|
13
|
-
* @function showModal - A method on the `glide-core-modal` component to open the Modal programmatically.
|
14
|
-
*
|
15
|
-
* @function close - A method on the `glide-core-modal` component to close the Modal programmatically.
|
16
|
-
*
|
17
13
|
* @slot - The content of the modal.
|
18
14
|
*
|
19
15
|
* @slot header-actions - A slot for placing additional header actions. These are co-located with the close button.
|
@@ -36,9 +32,6 @@ export default class GlideCoreModal extends LitElement {
|
|
36
32
|
showBackButton: boolean;
|
37
33
|
/** Fixed-size options for the Modal. */
|
38
34
|
size?: 'small' | 'medium' | 'large' | 'xlarge';
|
39
|
-
/**
|
40
|
-
* Event called by consumers to programmatically close the Modal.
|
41
|
-
*/
|
42
35
|
close(): void;
|
43
36
|
connectedCallback(): void;
|
44
37
|
disconnectedCallback(): void;
|
@@ -8,28 +8,28 @@ it('registers', async () => {
|
|
8
8
|
expect(window.customElements.get('glide-core-modal-icon-button')).to.equal(GlideCoreModalIconButton);
|
9
9
|
});
|
10
10
|
it('is accessible', async () => {
|
11
|
-
const
|
12
|
-
await expect(
|
11
|
+
const component = await fixture(html `<glide-core-modal-icon-button>Test</glide-core-modal-icon-button>`);
|
12
|
+
await expect(component).to.be.accessible();
|
13
13
|
});
|
14
14
|
it('renders and sets default attributes', async () => {
|
15
|
-
const
|
15
|
+
const component = await fixture(html `
|
16
16
|
<glide-core-modal-icon-button>Test</glide-core-modal-icon-button>
|
17
17
|
`);
|
18
|
-
expect(
|
19
|
-
const buttonElement =
|
18
|
+
expect(component).to.be.ok;
|
19
|
+
const buttonElement = component.shadowRoot?.querySelector('glide-core-icon-button');
|
20
20
|
expect(buttonElement).to.be.not.null;
|
21
21
|
expect(buttonElement).to.have.attribute('variant', 'tertiary');
|
22
22
|
});
|
23
23
|
it('adds an accessible label when given', async () => {
|
24
|
-
const
|
24
|
+
const component = await fixture(html `<glide-core-modal-icon-button label="test-label"
|
25
25
|
>Test</glide-core-modal-icon-button
|
26
26
|
>`);
|
27
|
-
const buttonElement =
|
27
|
+
const buttonElement = component.shadowRoot?.querySelector('glide-core-icon-button');
|
28
28
|
expect(buttonElement).to.have.attribute('label', 'test-label');
|
29
29
|
});
|
30
30
|
it('does not add an acceessible label when not given', async () => {
|
31
|
-
const
|
32
|
-
const buttonElement =
|
31
|
+
const component = await fixture(html `<glide-core-modal-icon-button>Test</glide-core-modal-icon-button>`);
|
32
|
+
const buttonElement = component.shadowRoot?.querySelector('glide-core-icon-button');
|
33
33
|
expect(buttonElement).to.have.attribute('label', '');
|
34
34
|
});
|
35
35
|
it('throws if it does not have a default slot', async () => {
|
package/dist/modal.stories.d.ts
CHANGED
package/dist/modal.styles.js
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export default[css`
|
2
|
+
${focusOutline(".body:focus-visible")}
|
3
|
+
`,css`
|
2
4
|
/* When browser support improves, we can have nicer animations with https://caniuse.com/mdn-css_at-rules_starting-style */
|
3
5
|
@keyframes backdrop-fade-in {
|
4
6
|
from {
|
@@ -130,10 +132,6 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
130
132
|
&:focus {
|
131
133
|
outline: none;
|
132
134
|
}
|
133
|
-
|
134
|
-
&:focus-visible {
|
135
|
-
${focusOutline};
|
136
|
-
}
|
137
135
|
}
|
138
136
|
|
139
137
|
.footer {
|
@@ -9,41 +9,41 @@ it('registers', async () => {
|
|
9
9
|
expect(window.customElements.get('glide-core-modal-tertiary-icon')).to.equal(GlideCoreModalTertiaryIcon);
|
10
10
|
});
|
11
11
|
it('is accessible', async () => {
|
12
|
-
const
|
13
|
-
await expect(
|
12
|
+
const component = await fixture(html `<glide-core-modal-tertiary-icon>Test</glide-core-modal-tertiary-icon>`);
|
13
|
+
await expect(component).to.be.accessible();
|
14
14
|
});
|
15
15
|
it('renders and sets default attributes', async () => {
|
16
|
-
const
|
16
|
+
const component = await fixture(html `
|
17
17
|
<glide-core-modal-tertiary-icon>Test</glide-core-modal-tertiary-icon>
|
18
18
|
`);
|
19
|
-
expect(
|
20
|
-
const spanTag =
|
19
|
+
expect(component).to.be.ok;
|
20
|
+
const spanTag = component.shadowRoot?.querySelector('span');
|
21
21
|
expect(spanTag?.getAttribute('tabindex')).to.equal('0');
|
22
|
-
const
|
23
|
-
expect(
|
22
|
+
const tooltip = component.shadowRoot?.querySelector('glide-core-tooltip');
|
23
|
+
expect(tooltip).to.not.be.null;
|
24
24
|
});
|
25
25
|
it('adds an accessible label when given', async () => {
|
26
|
-
const
|
26
|
+
const component = await fixture(html `<glide-core-modal-tertiary-icon label="test-label"
|
27
27
|
>Test</glide-core-modal-tertiary-icon
|
28
28
|
>`);
|
29
|
-
const spanElement =
|
29
|
+
const spanElement = component.shadowRoot?.querySelector('span');
|
30
30
|
expect(spanElement).to.have.attribute('aria-label', 'test-label');
|
31
31
|
});
|
32
32
|
it('does not add an acceessible label when not given', async () => {
|
33
|
-
const
|
34
|
-
const spanElement =
|
33
|
+
const component = await fixture(html `<glide-core-modal-tertiary-icon>Test</glide-core-modal-tertiary-icon>`);
|
34
|
+
const spanElement = component.shadowRoot?.querySelector('span');
|
35
35
|
expect(spanElement).to.not.have.attribute('aria-label');
|
36
36
|
});
|
37
37
|
it('sets the tooltip placement when attribute "tooltip-placement" is given', async () => {
|
38
|
-
const
|
38
|
+
const component = await fixture(html `<glide-core-modal-tertiary-icon tooltip-placement="right"
|
39
39
|
>Test</glide-core-modal-tertiary-icon
|
40
40
|
>`);
|
41
|
-
const toolTip =
|
41
|
+
const toolTip = component.shadowRoot?.querySelector('glide-core-tooltip');
|
42
42
|
expect(toolTip).to.have.attribute('placement', 'right');
|
43
43
|
});
|
44
44
|
it('sets the tooltip placement to "bottom" when attribute "tooltip-placement" is not given', async () => {
|
45
|
-
const
|
46
|
-
const toolTip =
|
45
|
+
const component = await fixture(html `<glide-core-modal-tertiary-icon>Test</glide-core-modal-tertiary-icon>`);
|
46
|
+
const toolTip = component.shadowRoot?.querySelector('glide-core-tooltip');
|
47
47
|
expect(toolTip).to.have.attribute('placement', 'bottom');
|
48
48
|
});
|
49
49
|
it('throws if it does not have a default slot', async () => {
|
@@ -3,47 +3,36 @@ import { expect, fixture, html } from '@open-wc/testing';
|
|
3
3
|
import GlideCoreModal from './modal.js';
|
4
4
|
GlideCoreModal.shadowRootOptions.mode = 'open';
|
5
5
|
it('is accessible', async () => {
|
6
|
-
const
|
7
|
-
|
8
|
-
</glide-core-modal>`);
|
9
|
-
await expect(element).to.be.accessible();
|
6
|
+
const component = await fixture(html `<glide-core-modal label="Label">Content</glide-core-modal>`);
|
7
|
+
await expect(component).to.be.accessible();
|
10
8
|
});
|
11
9
|
it('focuses the dialog upon opening', async () => {
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const dialogElement = element.shadowRoot?.querySelector('dialog');
|
17
|
-
expect(element.shadowRoot?.activeElement).to.equal(dialogElement);
|
10
|
+
const component = await fixture(html `<glide-core-modal label="Label">Content</glide-core-modal>`);
|
11
|
+
component.showModal();
|
12
|
+
const dialogElement = component.shadowRoot?.querySelector('dialog');
|
13
|
+
expect(component.shadowRoot?.activeElement).to.equal(dialogElement);
|
18
14
|
});
|
19
15
|
it('sets the tabindex on the dialog to "-1"', async () => {
|
20
|
-
const
|
21
|
-
|
22
|
-
|
23
|
-
element.showModal();
|
24
|
-
const dialogElement = element.shadowRoot?.querySelector('dialog');
|
16
|
+
const component = await fixture(html `<glide-core-modal label="Label">Content</glide-core-modal>`);
|
17
|
+
component.showModal();
|
18
|
+
const dialogElement = component.shadowRoot?.querySelector('dialog');
|
25
19
|
expect(dialogElement?.getAttribute('tabindex')).to.equal('-1');
|
26
20
|
});
|
27
21
|
it('sets the "toolbar" role on the header-actions section', async () => {
|
28
|
-
const
|
29
|
-
|
30
|
-
|
31
|
-
element.showModal();
|
32
|
-
const toolbar = element.shadowRoot?.querySelector('[role="toolbar"');
|
22
|
+
const component = await fixture(html `<glide-core-modal label="Label">Content</glide-core-modal>`);
|
23
|
+
component.showModal();
|
24
|
+
const toolbar = component.shadowRoot?.querySelector('[role="toolbar"');
|
33
25
|
expect(toolbar).to.be.ok;
|
34
26
|
});
|
35
27
|
it('sets proper aria attributes and roles on the article', async () => {
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
element.showModal();
|
40
|
-
const content = element.shadowRoot?.querySelector('[role="region"');
|
28
|
+
const component = await fixture(html `<glide-core-modal label="Label">Content</glide-core-modal>`);
|
29
|
+
component.showModal();
|
30
|
+
const content = component.shadowRoot?.querySelector('[role="region"');
|
41
31
|
expect(content).to.be.ok;
|
42
32
|
expect(content?.tagName).to.equal('ARTICLE');
|
43
33
|
expect(content?.getAttribute('aria-labelledby')).to.equal('heading');
|
44
34
|
expect(content?.getAttribute('tabindex')).to.equal('0');
|
45
|
-
|
46
|
-
const label = element.shadowRoot?.querySelector('#heading');
|
35
|
+
const label = component.shadowRoot?.querySelector('#heading');
|
47
36
|
expect(label).to.be.ok;
|
48
37
|
expect(label?.tagName).to.equal('H2');
|
49
38
|
});
|