@spectrum-web-components/dialog 1.0.0 → 1.0.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.
@@ -1,320 +0,0 @@
1
- "use strict";
2
- import {
3
- elementUpdated,
4
- expect,
5
- fixture,
6
- oneEvent,
7
- waitUntil
8
- } from "@open-wc/testing";
9
- import { spy, stub } from "sinon";
10
- import "@spectrum-web-components/theme/sp-theme.js";
11
- import "@spectrum-web-components/theme/src/themes.js";
12
- import "@spectrum-web-components/dialog/sp-dialog-wrapper.js";
13
- import {
14
- lazyHero,
15
- longContent,
16
- wrapperButtons,
17
- wrapperButtonsUnderlay,
18
- wrapperDismissable,
19
- wrapperDismissableUnderlayError,
20
- wrapperFullscreen,
21
- wrapperHeadlineVisibilityNone,
22
- wrapperLabeledHero,
23
- wrapperWithHeadline,
24
- wrapperWithHeadlineNoDivider
25
- } from "../stories/dialog-wrapper.stories.js";
26
- import { html } from "@spectrum-web-components/base";
27
- import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
28
- import { sendMouse } from "../../../test/plugins/browser.js";
29
- import { nextFrame } from "@spectrum-web-components/overlay/src/AbstractOverlay.js";
30
- async function styledFixture(story) {
31
- const test = await fixture(html`
32
- <sp-theme system="spectrum" scale="medium" color="dark">
33
- ${story}
34
- </sp-theme>
35
- `);
36
- return test.children[0];
37
- }
38
- describe("Dialog Wrapper", () => {
39
- testForLitDevWarnings(
40
- async () => await styledFixture(wrapperDismissable())
41
- );
42
- it("loads wrapped dialog accessibly", async () => {
43
- const el = await styledFixture(wrapperDismissable());
44
- await elementUpdated(el);
45
- await expect(el).to.be.accessible();
46
- });
47
- it("loads labeled hero dialog accessibly", async () => {
48
- const el = await styledFixture(wrapperLabeledHero());
49
- await elementUpdated(el);
50
- await expect(el).to.be.accessible();
51
- });
52
- it("loads fullscreen wrapped dialog accessibly", async () => {
53
- const el = await styledFixture(wrapperFullscreen());
54
- await elementUpdated(el);
55
- await expect(el).to.be.accessible();
56
- });
57
- xit("loads with underlay and no headline accessibly", async () => {
58
- const el = await styledFixture(wrapperButtonsUnderlay());
59
- await elementUpdated(el);
60
- el.headline = "";
61
- await elementUpdated(el);
62
- await expect(el).to.be.accessible();
63
- });
64
- it("opens and closes", async () => {
65
- const closeSpy = spy();
66
- const openedSpy = spy();
67
- const test = await styledFixture(html`
68
- <div @sp-opened=${() => openedSpy()}>${longContent()}</div>
69
- `);
70
- const overlayTrigger = test.querySelector(
71
- "overlay-trigger"
72
- );
73
- const el = test.querySelector("sp-dialog-wrapper");
74
- el.addEventListener("close", () => closeSpy());
75
- await waitUntil(
76
- () => openedSpy.calledOnce,
77
- "click content projected to overlay",
78
- { timeout: 2e3 }
79
- );
80
- expect(el.open).to.be.true;
81
- const closed = oneEvent(overlayTrigger, "sp-closed");
82
- overlayTrigger.open = void 0;
83
- await closed;
84
- expect(el.open).to.be.false;
85
- expect(closeSpy.callCount).to.equal(1);
86
- });
87
- it("opens and closes when element is recycled", async () => {
88
- const closeSpy = spy();
89
- const openedSpy = spy();
90
- const test = await styledFixture(html`
91
- <div @sp-opened=${() => openedSpy()}>${longContent()}</div>
92
- `);
93
- const overlayTrigger = test.querySelector(
94
- "overlay-trigger"
95
- );
96
- const el = test.querySelector("sp-dialog-wrapper");
97
- el.addEventListener("close", () => closeSpy());
98
- await waitUntil(
99
- () => openedSpy.calledOnce,
100
- "click content projected to overlay",
101
- { timeout: 2e3 }
102
- );
103
- expect(el.open).to.be.true;
104
- const closed = oneEvent(overlayTrigger, "sp-closed");
105
- overlayTrigger.open = void 0;
106
- await closed;
107
- expect(el.open).to.be.false;
108
- expect(closeSpy.callCount).to.equal(1);
109
- });
110
- it("shows header divider when there's a header", async () => {
111
- const wrapper = await styledFixture(
112
- wrapperWithHeadline()
113
- );
114
- await elementUpdated(wrapper);
115
- const dialog = wrapper.shadowRoot.querySelector("sp-dialog");
116
- const divider = dialog.shadowRoot.querySelector(
117
- "sp-divider.divider"
118
- );
119
- expect(divider).to.be.not.null;
120
- });
121
- it(`hides header divider when there's a header but "no-divider"`, async () => {
122
- const wrapper = await styledFixture(
123
- wrapperWithHeadlineNoDivider()
124
- );
125
- await elementUpdated(wrapper);
126
- await expect(wrapper).to.be.accessible();
127
- const dialog = wrapper.shadowRoot.querySelector("sp-dialog");
128
- const divider = dialog.shadowRoot.querySelector(
129
- "sp-divider.divider"
130
- );
131
- expect(divider).to.be.null;
132
- });
133
- it("hides header divider when there's no header", async () => {
134
- const wrapper = await styledFixture(
135
- wrapperHeadlineVisibilityNone()
136
- );
137
- await elementUpdated(wrapper);
138
- await expect(wrapper).to.be.accessible();
139
- const dialog = wrapper.shadowRoot.querySelector("sp-dialog");
140
- const divider = dialog.shadowRoot.querySelector(
141
- "sp-divider.divider"
142
- );
143
- expect(divider).to.be.null;
144
- });
145
- it("dismisses via clicking the underlay when [dismissable]", async () => {
146
- const test = await styledFixture(
147
- wrapperDismissableUnderlayError()
148
- );
149
- const el = test.querySelector("sp-dialog-wrapper");
150
- await elementUpdated(el);
151
- expect(el.open).to.be.true;
152
- el.dismissable = true;
153
- const underlay = el.shadowRoot.querySelector("sp-underlay");
154
- underlay.click();
155
- await elementUpdated(el);
156
- expect(el.open).to.be.false;
157
- });
158
- it("does not dismiss via clicking the underlay :not([dismissable])", async () => {
159
- const el = await styledFixture(wrapperButtonsUnderlay());
160
- await elementUpdated(el);
161
- expect(el.open).to.be.true;
162
- const underlay = el.shadowRoot.querySelector("sp-underlay");
163
- underlay.click();
164
- await elementUpdated(el);
165
- expect(el.open).to.be.true;
166
- });
167
- it("dismisses", async () => {
168
- const el = await styledFixture(wrapperDismissable());
169
- await elementUpdated(el);
170
- expect(el.open).to.be.true;
171
- const root = el.shadowRoot ? el.shadowRoot : el;
172
- const dialog = root.querySelector("sp-dialog");
173
- const dialogRoot = dialog.shadowRoot ? dialog.shadowRoot : dialog;
174
- const dismissButton = dialogRoot.querySelector(
175
- ".close-button"
176
- );
177
- expect(dismissButton.ariaLabel).to.be.equals("Close");
178
- dismissButton.click();
179
- await elementUpdated(el);
180
- expect(el.open).to.be.false;
181
- });
182
- it("manages entry focus - buttons", async () => {
183
- var _a;
184
- const el = await styledFixture(wrapperButtons());
185
- await elementUpdated(el);
186
- expect(el.open).to.be.true;
187
- expect(document.activeElement !== el, "no focused").to.be.true;
188
- const button = el.shadowRoot.querySelector("sp-button");
189
- el.focus();
190
- await elementUpdated(el);
191
- expect(
192
- document.activeElement === el,
193
- `focused generally, ${document.activeElement}`
194
- ).to.be.true;
195
- expect(
196
- button.getRootNode().activeElement === button,
197
- `focused specifically, ${(_a = button.getRootNode().activeElement) == null ? void 0 : _a.outerHTML}`
198
- ).to.be.true;
199
- });
200
- it("dispatches `confirm`, `cancel` and `secondary`", async () => {
201
- const confirmSpy = spy();
202
- const cancelSpy = spy();
203
- const secondarySpy = spy();
204
- const handleConfirm = () => confirmSpy();
205
- const handleCancel = () => cancelSpy();
206
- const handleSecondary = () => secondarySpy();
207
- const el = await styledFixture(wrapperButtons());
208
- el.addEventListener("confirm", handleConfirm);
209
- el.addEventListener("cancel", handleCancel);
210
- el.addEventListener("secondary", handleSecondary);
211
- await elementUpdated(el);
212
- expect(confirmSpy.called).to.be.false;
213
- expect(cancelSpy.called).to.be.false;
214
- expect(secondarySpy.called).to.be.false;
215
- const accentButton = el.shadowRoot.querySelector(
216
- '[variant="accent"]'
217
- );
218
- const primaryButton = el.shadowRoot.querySelector(
219
- '[variant="primary"]'
220
- );
221
- const secondaryButton = el.shadowRoot.querySelector(
222
- '[variant="secondary"]'
223
- );
224
- accentButton.click();
225
- await elementUpdated(el);
226
- expect(confirmSpy.called, "dispatched `confirm`").to.be.true;
227
- expect(secondarySpy.called).to.be.false;
228
- expect(cancelSpy.called).to.be.false;
229
- primaryButton.click();
230
- await elementUpdated(el);
231
- expect(confirmSpy.callCount).to.equal(1);
232
- expect(secondarySpy.called, "dispatched `cancel`").to.be.true;
233
- expect(cancelSpy.called).to.be.false;
234
- secondaryButton.click();
235
- await elementUpdated(el);
236
- expect(confirmSpy.callCount).to.equal(1);
237
- expect(secondarySpy.callCount).to.equal(1);
238
- expect(cancelSpy.called, "dispatched `secondary`").to.be.true;
239
- });
240
- describe("dev mode", () => {
241
- let consoleWarnStub;
242
- before(() => {
243
- consoleWarnStub = stub(console, "warn");
244
- });
245
- afterEach(() => {
246
- consoleWarnStub.resetHistory();
247
- });
248
- after(() => {
249
- consoleWarnStub.restore();
250
- });
251
- it("warns in Dev Mode when accessible attributes are not leveraged", async () => {
252
- const el = await fixture(html`
253
- <sp-dialog-wrapper></sp-dialog-wrapper>
254
- `);
255
- await elementUpdated(el);
256
- expect(consoleWarnStub.called).to.be.true;
257
- const spyCall = consoleWarnStub.getCall(0);
258
- expect(
259
- spyCall.args.at(0).includes("accessible"),
260
- "confirm accessibility-centric message"
261
- ).to.be.true;
262
- expect(spyCall.args.at(-1), "confirm `data` shape").to.deep.equal({
263
- data: {
264
- localName: "sp-dialog-wrapper",
265
- type: "accessibility",
266
- level: "default"
267
- }
268
- });
269
- });
270
- });
271
- it("manages content element tabindex on resize observer time", async () => {
272
- const imgReadyPromise = new Promise((res) => {
273
- const img = document.createElement("img");
274
- img.onload = res;
275
- img.src = lazyHero.args.src;
276
- });
277
- const test = await styledFixture(lazyHero(lazyHero.args));
278
- const dialog = document.querySelector(
279
- "sp-dialog-wrapper"
280
- );
281
- const button = document.querySelector("sp-button");
282
- const rect = button.getBoundingClientRect();
283
- const contentElement = dialog.dialog.contentElement;
284
- expect(contentElement.hasAttribute("tabindex")).to.be.false;
285
- await elementUpdated(dialog);
286
- const opened = oneEvent(test, "sp-opened");
287
- await sendMouse({
288
- steps: [
289
- {
290
- position: [
291
- rect.left + rect.width / 2,
292
- rect.top + rect.height / 2
293
- ],
294
- type: "click"
295
- }
296
- ]
297
- });
298
- await opened;
299
- await elementUpdated(dialog);
300
- await imgReadyPromise;
301
- await nextFrame();
302
- await nextFrame();
303
- expect(contentElement.hasAttribute("tabindex")).to.be.true;
304
- });
305
- });
306
- describe("dev mode", () => {
307
- let consoleWarnStub;
308
- before(() => {
309
- window.__swc.verbose = true;
310
- consoleWarnStub = stub(console, "warn");
311
- });
312
- afterEach(() => {
313
- consoleWarnStub.resetHistory();
314
- });
315
- after(() => {
316
- window.__swc.verbose = false;
317
- consoleWarnStub.restore();
318
- });
319
- });
320
- //# sourceMappingURL=dialog-wrapper.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["dialog-wrapper.test.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n elementUpdated,\n expect,\n fixture,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\nimport { SinonStub, spy, stub } from 'sinon';\n\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/dialog/sp-dialog-wrapper.js';\nimport { Dialog, DialogWrapper } from '@spectrum-web-components/dialog';\nimport { Button } from '@spectrum-web-components/button';\nimport { Underlay } from '@spectrum-web-components/underlay';\nimport {\n lazyHero,\n longContent,\n wrapperButtons,\n wrapperButtonsUnderlay,\n wrapperDismissable,\n wrapperDismissableUnderlayError,\n wrapperFullscreen,\n wrapperHeadlineVisibilityNone,\n wrapperLabeledHero,\n wrapperWithHeadline,\n wrapperWithHeadlineNoDivider,\n} from '../stories/dialog-wrapper.stories.js';\nimport { OverlayTrigger } from '@spectrum-web-components/overlay';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { Theme } from '@spectrum-web-components/theme';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { Divider } from '@spectrum-web-components/divider/src/Divider.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\nimport { nextFrame } from '@spectrum-web-components/overlay/src/AbstractOverlay.js';\n\nasync function styledFixture<T extends Element>(\n story: TemplateResult\n): Promise<T> {\n const test = await fixture<Theme>(html`\n <sp-theme system=\"spectrum\" scale=\"medium\" color=\"dark\">\n ${story}\n </sp-theme>\n `);\n return test.children[0] as T;\n}\n\ndescribe('Dialog Wrapper', () => {\n testForLitDevWarnings(\n async () => await styledFixture<DialogWrapper>(wrapperDismissable())\n );\n it('loads wrapped dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads labeled hero dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperLabeledHero());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads fullscreen wrapped dialog accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperFullscreen());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n xit('loads with underlay and no headline accessibly', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtonsUnderlay());\n await elementUpdated(el);\n el.headline = '';\n await elementUpdated(el);\n await expect(el).to.be.accessible();\n });\n it('opens and closes', async () => {\n const closeSpy = spy();\n const openedSpy = spy();\n const test = await styledFixture<OverlayTrigger>(html`\n <div @sp-opened=${() => openedSpy()}>${longContent()}</div>\n `);\n const overlayTrigger = test.querySelector(\n 'overlay-trigger'\n ) as OverlayTrigger;\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n el.addEventListener('close', () => closeSpy());\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n\n expect(el.open).to.be.true;\n const closed = oneEvent(overlayTrigger, 'sp-closed');\n overlayTrigger.open = undefined;\n await closed;\n\n expect(el.open).to.be.false;\n expect(closeSpy.callCount).to.equal(1);\n });\n it('opens and closes when element is recycled', async () => {\n const closeSpy = spy();\n const openedSpy = spy();\n const test = await styledFixture<OverlayTrigger>(html`\n <div @sp-opened=${() => openedSpy()}>${longContent()}</div>\n `);\n const overlayTrigger = test.querySelector(\n 'overlay-trigger'\n ) as OverlayTrigger;\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n el.addEventListener('close', () => closeSpy());\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n\n expect(el.open).to.be.true;\n const closed = oneEvent(overlayTrigger, 'sp-closed');\n overlayTrigger.open = undefined;\n await closed;\n\n expect(el.open).to.be.false;\n expect(closeSpy.callCount).to.equal(1);\n });\n it(\"shows header divider when there's a header\", async () => {\n const wrapper = await styledFixture<DialogWrapper>(\n wrapperWithHeadline()\n );\n await elementUpdated(wrapper);\n\n const dialog = wrapper.shadowRoot.querySelector('sp-dialog') as Dialog;\n const divider = dialog.shadowRoot.querySelector(\n 'sp-divider.divider'\n ) as Divider;\n\n expect(divider).to.be.not.null;\n });\n it('hides header divider when there\\'s a header but \"no-divider\"', async () => {\n const wrapper = await styledFixture<DialogWrapper>(\n wrapperWithHeadlineNoDivider()\n );\n await elementUpdated(wrapper);\n\n await expect(wrapper).to.be.accessible();\n\n const dialog = wrapper.shadowRoot.querySelector('sp-dialog') as Dialog;\n const divider = dialog.shadowRoot.querySelector(\n 'sp-divider.divider'\n ) as Divider;\n\n expect(divider).to.be.null;\n });\n it(\"hides header divider when there's no header\", async () => {\n const wrapper = await styledFixture<DialogWrapper>(\n wrapperHeadlineVisibilityNone()\n );\n await elementUpdated(wrapper);\n\n await expect(wrapper).to.be.accessible();\n\n const dialog = wrapper.shadowRoot.querySelector('sp-dialog') as Dialog;\n const divider = dialog.shadowRoot.querySelector(\n 'sp-divider.divider'\n ) as Divider;\n\n expect(divider).to.be.null;\n });\n it('dismisses via clicking the underlay when [dismissable]', async () => {\n const test = await styledFixture<DialogWrapper>(\n wrapperDismissableUnderlayError()\n );\n const el = test.querySelector('sp-dialog-wrapper') as DialogWrapper;\n await elementUpdated(el);\n expect(el.open).to.be.true;\n el.dismissable = true;\n const underlay = el.shadowRoot.querySelector('sp-underlay') as Underlay;\n underlay.click();\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('does not dismiss via clicking the underlay :not([dismissable])', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtonsUnderlay());\n await elementUpdated(el);\n expect(el.open).to.be.true;\n const underlay = el.shadowRoot.querySelector('sp-underlay') as Underlay;\n underlay.click();\n await elementUpdated(el);\n expect(el.open).to.be.true;\n });\n it('dismisses', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperDismissable());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n\n const root = el.shadowRoot ? el.shadowRoot : el;\n const dialog = root.querySelector('sp-dialog') as Dialog;\n const dialogRoot = dialog.shadowRoot ? dialog.shadowRoot : dialog;\n const dismissButton = dialogRoot.querySelector(\n '.close-button'\n ) as HTMLButtonElement;\n expect(dismissButton.ariaLabel).to.be.equals('Close');\n dismissButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('manages entry focus - buttons', async () => {\n const el = await styledFixture<DialogWrapper>(wrapperButtons());\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(document.activeElement !== el, 'no focused').to.be.true;\n\n const button = el.shadowRoot.querySelector('sp-button') as Button;\n\n el.focus();\n await elementUpdated(el);\n expect(\n document.activeElement === el,\n `focused generally, ${document.activeElement}`\n ).to.be.true;\n expect(\n (button.getRootNode() as Document).activeElement === button,\n `focused specifically, ${\n (button.getRootNode() as Document).activeElement?.outerHTML\n }`\n ).to.be.true;\n });\n it('dispatches `confirm`, `cancel` and `secondary`', async () => {\n const confirmSpy = spy();\n const cancelSpy = spy();\n const secondarySpy = spy();\n const handleConfirm = (): void => confirmSpy();\n const handleCancel = (): void => cancelSpy();\n const handleSecondary = (): void => secondarySpy();\n const el = await styledFixture<DialogWrapper>(wrapperButtons());\n el.addEventListener('confirm', handleConfirm);\n el.addEventListener('cancel', handleCancel);\n el.addEventListener('secondary', handleSecondary);\n\n await elementUpdated(el);\n expect(confirmSpy.called).to.be.false;\n expect(cancelSpy.called).to.be.false;\n expect(secondarySpy.called).to.be.false;\n\n const accentButton = el.shadowRoot.querySelector(\n '[variant=\"accent\"]'\n ) as Button;\n const primaryButton = el.shadowRoot.querySelector(\n '[variant=\"primary\"]'\n ) as Button;\n const secondaryButton = el.shadowRoot.querySelector(\n '[variant=\"secondary\"]'\n ) as Button;\n\n accentButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.called, 'dispatched `confirm`').to.be.true;\n expect(secondarySpy.called).to.be.false;\n expect(cancelSpy.called).to.be.false;\n\n primaryButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.callCount).to.equal(1);\n expect(secondarySpy.called, 'dispatched `cancel`').to.be.true;\n expect(cancelSpy.called).to.be.false;\n\n secondaryButton.click();\n\n await elementUpdated(el);\n expect(confirmSpy.callCount).to.equal(1);\n expect(secondarySpy.callCount).to.equal(1);\n expect(cancelSpy.called, 'dispatched `secondary`').to.be.true;\n });\n\n describe('dev mode', () => {\n let consoleWarnStub!: SinonStub;\n before(() => {\n consoleWarnStub = stub(console, 'warn');\n });\n afterEach(() => {\n consoleWarnStub.resetHistory();\n });\n after(() => {\n consoleWarnStub.restore();\n });\n it('warns in Dev Mode when accessible attributes are not leveraged', async () => {\n const el = await fixture<DialogWrapper>(html`\n <sp-dialog-wrapper></sp-dialog-wrapper>\n `);\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n expect(\n spyCall.args.at(0).includes('accessible'),\n 'confirm accessibility-centric message'\n ).to.be.true;\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-dialog-wrapper',\n type: 'accessibility',\n level: 'default',\n },\n });\n });\n });\n\n it('manages content element tabindex on resize observer time', async () => {\n const imgReadyPromise = new Promise((res) => {\n const img = document.createElement('img');\n img.onload = res;\n img.src = lazyHero.args.src;\n });\n const test = await styledFixture(lazyHero(lazyHero.args));\n const dialog = document.querySelector(\n 'sp-dialog-wrapper'\n ) as DialogWrapper;\n const button = document.querySelector('sp-button') as Button;\n const rect = button.getBoundingClientRect();\n const contentElement = (\n (dialog as unknown as { dialog: Dialog }).dialog as unknown as {\n contentElement: HTMLElement;\n }\n ).contentElement;\n expect(contentElement.hasAttribute('tabindex')).to.be.false;\n await elementUpdated(dialog);\n const opened = oneEvent(test, 'sp-opened');\n await sendMouse({\n steps: [\n {\n position: [\n rect.left + rect.width / 2,\n rect.top + rect.height / 2,\n ],\n type: 'click',\n },\n ],\n });\n await opened;\n await elementUpdated(dialog);\n await imgReadyPromise;\n // Resize observer timing.\n await nextFrame();\n await nextFrame();\n expect(contentElement.hasAttribute('tabindex')).to.be.true;\n });\n});\n\ndescribe('dev mode', () => {\n let consoleWarnStub!: ReturnType<typeof stub>;\n before(() => {\n window.__swc.verbose = true;\n consoleWarnStub = stub(console, 'warn');\n });\n afterEach(() => {\n consoleWarnStub.resetHistory();\n });\n after(() => {\n window.__swc.verbose = false;\n consoleWarnStub.restore();\n });\n});\n"],
5
- "mappings": ";AAYA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAoB,KAAK,YAAY;AAErC,OAAO;AACP,OAAO;AACP,OAAO;AAIP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,YAA4B;AAErC,SAAS,6BAA6B;AAEtC,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAE1B,eAAe,cACX,OACU;AACV,QAAM,OAAO,MAAM,QAAe;AAAA;AAAA,cAExB,KAAK;A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C;AAED,SAAS,YAAY,MAAM;AACvB,MAAI;AACJ,SAAO,MAAM;AACT,WAAO,MAAM,UAAU;AACvB,sBAAkB,KAAK,SAAS,MAAM;AAAA,EAC1C,CAAC;AACD,YAAU,MAAM;AACZ,oBAAgB,aAAa;AAAA,EACjC,CAAC;AACD,QAAM,MAAM;AACR,WAAO,MAAM,UAAU;AACvB,oBAAgB,QAAQ;AAAA,EAC5B,CAAC;AACL,CAAC;",
6
- "names": []
7
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
- import * as stories from "../stories/dialog.stories.js";
3
- import { regressVisuals } from "../../../test/visual/test.js";
4
- regressVisuals("DialogStories", stories);
5
- //# sourceMappingURL=dialog.test-vrt.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["dialog.test-vrt.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/dialog.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('DialogStories', stories as unknown as TestsType);\n"],
5
- "mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,iBAAiB,OAA+B;",
6
- "names": []
7
- }
@@ -1,221 +0,0 @@
1
- "use strict";
2
- import {
3
- elementUpdated,
4
- expect,
5
- fixture,
6
- html,
7
- nextFrame
8
- } from "@open-wc/testing";
9
- import "@spectrum-web-components/dialog/sp-dialog.js";
10
- import { Dialog } from "@spectrum-web-components/dialog";
11
- import {
12
- alertError,
13
- dismissable,
14
- fullscreen,
15
- small
16
- } from "../stories/dialog.stories.js";
17
- import { spy, stub } from "sinon";
18
- import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
19
- describe("Dialog", () => {
20
- testForLitDevWarnings(async () => await fixture(small()));
21
- it("loads `[size=small]` dialog accessibly", async () => {
22
- const el = await fixture(small());
23
- await elementUpdated(el);
24
- await expect(el).to.be.accessible();
25
- });
26
- it("loads `[size=alert]` dialog accessibly", async () => {
27
- const el = await fixture(alertError());
28
- await elementUpdated(el);
29
- await expect(el).to.be.accessible();
30
- });
31
- it("loads `[dismissable]` dialog accessibly", async () => {
32
- const el = await fixture(dismissable());
33
- await elementUpdated(el);
34
- await expect(el).to.be.accessible();
35
- });
36
- it("loads `[mode=fullscreen]` dialog accessibly", async () => {
37
- const el = await fixture(fullscreen());
38
- await elementUpdated(el);
39
- await expect(el).to.be.accessible();
40
- });
41
- it("loads dialog without footer accessibly", async () => {
42
- const el = await fixture(small());
43
- await elementUpdated(el);
44
- await expect(el).to.be.accessible();
45
- });
46
- it("does not recycle applied content ids", async () => {
47
- var _a, _b, _c;
48
- const el = await fixture(html`
49
- <sp-dialog size="s">
50
- <h2 slot="heading">Disclaimer</h2>
51
- </sp-dialog>
52
- `);
53
- await elementUpdated(el);
54
- await expect(el).to.be.accessible();
55
- const paragraph = document.createElement("p");
56
- paragraph.textContent = "Added paragraph.";
57
- (_a = el.querySelector("p")) == null ? void 0 : _a.remove();
58
- el.insertAdjacentElement("beforeend", paragraph);
59
- await nextFrame();
60
- await elementUpdated(el);
61
- await expect(el).to.be.accessible();
62
- (_b = paragraph.querySelector("p")) == null ? void 0 : _b.remove();
63
- await nextFrame();
64
- await elementUpdated(el);
65
- await expect(el).to.be.accessible();
66
- el.insertAdjacentElement("beforeend", paragraph);
67
- await nextFrame();
68
- await elementUpdated(el);
69
- await expect(el).to.be.accessible();
70
- const heading = document.createElement("h2");
71
- heading.slot = "heading";
72
- heading.textContent = "New heading";
73
- (_c = el.querySelector("h2")) == null ? void 0 : _c.remove();
74
- el.insertAdjacentElement("afterbegin", heading);
75
- await nextFrame();
76
- await elementUpdated(el);
77
- await expect(el).to.be.accessible();
78
- });
79
- it("closes", async () => {
80
- const closeSpy = spy();
81
- const el = await fixture(dismissable());
82
- el.addEventListener("close", () => closeSpy());
83
- await elementUpdated(el);
84
- const closeButton = el.shadowRoot ? el.shadowRoot.querySelector(".close-button") : el.querySelector(".close-button ");
85
- expect(closeButton.ariaLabel).to.be.equals("Close");
86
- closeButton.click();
87
- await elementUpdated(el);
88
- expect(closeSpy.calledOnce).to.be.true;
89
- });
90
- it("allows hero override", async () => {
91
- class Override extends Dialog {
92
- get hasHero() {
93
- return true;
94
- }
95
- renderHero() {
96
- return html`
97
- <div id="hero-container"></div>
98
- `;
99
- }
100
- }
101
- customElements.define("hero-dialog", Override);
102
- const el = await fixture(html`
103
- <hero-dialog></hero-dialog>
104
- `);
105
- const container = el.shadowRoot.querySelector("#hero-container");
106
- expect(container).to.not.be.null;
107
- });
108
- it("allows heading override", async () => {
109
- class Override extends Dialog {
110
- renderHeading() {
111
- return html`
112
- <h2 id="heading-container">Test</h2>
113
- `;
114
- }
115
- }
116
- customElements.define("heading-dialog", Override);
117
- const el = await fixture(html`
118
- <heading-dialog></heading-dialog>
119
- `);
120
- const container = el.shadowRoot.querySelector("#heading-container");
121
- expect(container).to.not.be.null;
122
- });
123
- it("allows content override", async () => {
124
- class Override extends Dialog {
125
- renderContent() {
126
- return html`
127
- <p id="content-container">Test</p>
128
- `;
129
- }
130
- }
131
- customElements.define("content-dialog", Override);
132
- const el = await fixture(html`
133
- <content-dialog></content-dialog>
134
- `);
135
- const container = el.shadowRoot.querySelector("#content-container");
136
- expect(container).to.not.be.null;
137
- });
138
- it("allows footer override", async () => {
139
- class Override extends Dialog {
140
- get hasFooter() {
141
- return true;
142
- }
143
- renderFooter() {
144
- return html`
145
- <p id="footer-container">Test</p>
146
- `;
147
- }
148
- }
149
- customElements.define("footer-dialog", Override);
150
- const el = await fixture(html`
151
- <footer-dialog></footer-dialog>
152
- `);
153
- const container = el.shadowRoot.querySelector("#footer-container");
154
- expect(container).to.not.be.null;
155
- });
156
- it("allows button override", async () => {
157
- class Override extends Dialog {
158
- get hasButtons() {
159
- return true;
160
- }
161
- renderButtons() {
162
- return html`
163
- <p id="button-container">Test</p>
164
- `;
165
- }
166
- }
167
- customElements.define("button-dialog", Override);
168
- const el = await fixture(html`
169
- <button-dialog></button-dialog>
170
- `);
171
- const container = el.shadowRoot.querySelector("#button-container");
172
- expect(container).to.not.be.null;
173
- });
174
- it("allows dismiss override", async () => {
175
- class Override extends Dialog {
176
- renderDismiss() {
177
- return html`
178
- <p id="dismiss-container">Test</p>
179
- `;
180
- }
181
- }
182
- customElements.define("dismiss-dialog", Override);
183
- const el = await fixture(html`
184
- <dismiss-dialog dismissable></dismiss-dialog>
185
- `);
186
- const container = el.shadowRoot.querySelector("#dismiss-container");
187
- expect(container).to.not.be.null;
188
- });
189
- });
190
- describe("dev mode", () => {
191
- let consoleWarnStub;
192
- before(() => {
193
- window.__swc.verbose = true;
194
- consoleWarnStub = stub(console, "warn");
195
- });
196
- afterEach(() => {
197
- consoleWarnStub.resetHistory();
198
- });
199
- after(() => {
200
- window.__swc.verbose = false;
201
- consoleWarnStub.restore();
202
- });
203
- it("warns that `error` is deprecated", async () => {
204
- const el = await fixture(alertError());
205
- await elementUpdated(el);
206
- expect(consoleWarnStub.called).to.be.true;
207
- const spyCall = consoleWarnStub.getCall(0);
208
- expect(
209
- spyCall.args.at(0).includes('"error"'),
210
- "confirm error-centric message"
211
- ).to.be.true;
212
- expect(spyCall.args.at(-1), "confirm `data` shape").to.deep.equal({
213
- data: {
214
- localName: "sp-dialog",
215
- type: "api",
216
- level: "deprecation"
217
- }
218
- });
219
- });
220
- });
221
- //# sourceMappingURL=dialog.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["dialog.test.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n} from '@open-wc/testing';\nimport { TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/dialog/sp-dialog.js';\nimport { Dialog } from '@spectrum-web-components/dialog';\nimport {\n alertError,\n dismissable,\n fullscreen,\n small,\n} from '../stories/dialog.stories.js';\nimport { spy, stub } from 'sinon';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Dialog', () => {\n testForLitDevWarnings(async () => await fixture<Dialog>(small()));\n it('loads `[size=small]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(small());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[size=alert]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(alertError());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[dismissable]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(dismissable());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads `[mode=fullscreen]` dialog accessibly', async () => {\n const el = await fixture<Dialog>(fullscreen());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('loads dialog without footer accessibly', async () => {\n const el = await fixture<Dialog>(small());\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('does not recycle applied content ids', async () => {\n const el = await fixture<Dialog>(html`\n <sp-dialog size=\"s\">\n <h2 slot=\"heading\">Disclaimer</h2>\n </sp-dialog>\n `);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n const paragraph = document.createElement('p');\n paragraph.textContent = 'Added paragraph.';\n\n el.querySelector('p')?.remove();\n el.insertAdjacentElement('beforeend', paragraph);\n\n // Slotchange time exists outside of the standard update lifecycle\n await nextFrame();\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n paragraph.querySelector('p')?.remove();\n\n // Slotchange time exists outside of the standard update lifecycle\n await nextFrame();\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n el.insertAdjacentElement('beforeend', paragraph);\n\n // Slotchange time exists outside of the standard update lifecycle\n await nextFrame();\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n const heading = document.createElement('h2');\n heading.slot = 'heading';\n heading.textContent = 'New heading';\n\n el.querySelector('h2')?.remove();\n el.insertAdjacentElement('afterbegin', heading);\n\n // Slotchange time exists outside of the standard update lifecycle\n await nextFrame();\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('closes', async () => {\n const closeSpy = spy();\n const el = await fixture<Dialog>(dismissable());\n el.addEventListener('close', () => closeSpy());\n await elementUpdated(el);\n\n const closeButton = (\n el.shadowRoot\n ? el.shadowRoot.querySelector('.close-button')\n : el.querySelector('.close-button ')\n ) as HTMLElement;\n\n expect(closeButton.ariaLabel).to.be.equals('Close');\n\n closeButton.click();\n\n await elementUpdated(el);\n expect(closeSpy.calledOnce).to.be.true;\n });\n it('allows hero override', async () => {\n class Override extends Dialog {\n protected override get hasHero(): boolean {\n return true;\n }\n protected override renderHero(): TemplateResult {\n return html`\n <div id=\"hero-container\"></div>\n `;\n }\n }\n\n customElements.define('hero-dialog', Override);\n\n const el = await fixture<Override>(html`\n <hero-dialog></hero-dialog>\n `);\n\n const container = el.shadowRoot.querySelector('#hero-container');\n expect(container).to.not.be.null;\n });\n it('allows heading override', async () => {\n class Override extends Dialog {\n protected override renderHeading(): TemplateResult {\n return html`\n <h2 id=\"heading-container\">Test</h2>\n `;\n }\n }\n\n customElements.define('heading-dialog', Override);\n\n const el = await fixture<Override>(html`\n <heading-dialog></heading-dialog>\n `);\n\n const container = el.shadowRoot.querySelector('#heading-container');\n expect(container).to.not.be.null;\n });\n it('allows content override', async () => {\n class Override extends Dialog {\n protected override renderContent(): TemplateResult {\n return html`\n <p id=\"content-container\">Test</p>\n `;\n }\n }\n\n customElements.define('content-dialog', Override);\n\n const el = await fixture<Override>(html`\n <content-dialog></content-dialog>\n `);\n\n const container = el.shadowRoot.querySelector('#content-container');\n expect(container).to.not.be.null;\n });\n it('allows footer override', async () => {\n class Override extends Dialog {\n protected override get hasFooter(): boolean {\n return true;\n }\n protected override renderFooter(): TemplateResult {\n return html`\n <p id=\"footer-container\">Test</p>\n `;\n }\n }\n\n customElements.define('footer-dialog', Override);\n\n const el = await fixture<Override>(html`\n <footer-dialog></footer-dialog>\n `);\n\n const container = el.shadowRoot.querySelector('#footer-container');\n expect(container).to.not.be.null;\n });\n it('allows button override', async () => {\n class Override extends Dialog {\n protected override get hasButtons(): boolean {\n return true;\n }\n protected override renderButtons(): TemplateResult {\n return html`\n <p id=\"button-container\">Test</p>\n `;\n }\n }\n\n customElements.define('button-dialog', Override);\n\n const el = await fixture<Override>(html`\n <button-dialog></button-dialog>\n `);\n\n const container = el.shadowRoot.querySelector('#button-container');\n expect(container).to.not.be.null;\n });\n it('allows dismiss override', async () => {\n class Override extends Dialog {\n protected override renderDismiss(): TemplateResult {\n return html`\n <p id=\"dismiss-container\">Test</p>\n `;\n }\n }\n\n customElements.define('dismiss-dialog', Override);\n\n const el = await fixture<Override>(html`\n <dismiss-dialog dismissable></dismiss-dialog>\n `);\n\n const container = el.shadowRoot.querySelector('#dismiss-container');\n expect(container).to.not.be.null;\n });\n});\n\ndescribe('dev mode', () => {\n let consoleWarnStub!: ReturnType<typeof stub>;\n before(() => {\n window.__swc.verbose = true;\n consoleWarnStub = stub(console, 'warn');\n });\n afterEach(() => {\n consoleWarnStub.resetHistory();\n });\n after(() => {\n window.__swc.verbose = false;\n consoleWarnStub.restore();\n });\n\n it('warns that `error` is deprecated', async () => {\n const el = await fixture<Dialog>(alertError());\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n expect(\n (spyCall.args.at(0) as string).includes('\"error\"'),\n 'confirm error-centric message'\n ).to.be.true;\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-dialog',\n type: 'api',\n level: 'deprecation',\n },\n });\n });\n});\n"],
5
- "mappings": ";AAYA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAGP,OAAO;AACP,SAAS,cAAc;AACvB;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,KAAK,YAAY;AAC1B,SAAS,6BAA6B;AAEtC,SAAS,UAAU,MAAM;AACrB,wBAAsB,YAAY,MAAM,QAAgB,MAAM,CAAC,CAAC;AAChE,KAAG,0CAA0C,YAAY;AACrD,UAAM,KAAK,MAAM,QAAgB,MAAM,CAAC;AAExC,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,0CAA0C,YAAY;AACrD,UAAM,KAAK,MAAM,QAAgB,WAAW,CAAC;AAE7C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,2CAA2C,YAAY;AACtD,UAAM,KAAK,MAAM,QAAgB,YAAY,CAAC;AAE9C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,+CAA+C,YAAY;AAC1D,UAAM,KAAK,MAAM,QAAgB,WAAW,CAAC;AAE7C,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,C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