@spectrum-web-components/overlay 0.33.2 → 0.33.3-overlay.65

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.
Files changed (155) hide show
  1. package/README.md +227 -152
  2. package/custom-elements.json +1387 -527
  3. package/package.json +48 -22
  4. package/sp-overlay.d.ts +6 -0
  5. package/sp-overlay.dev.js +5 -0
  6. package/{active-overlay.dev.js.map → sp-overlay.dev.js.map} +3 -3
  7. package/sp-overlay.js +2 -0
  8. package/{active-overlay.js.map → sp-overlay.js.map} +4 -4
  9. package/src/Overlay.d.ts +29 -0
  10. package/src/Overlay.dev.js +91 -0
  11. package/src/Overlay.dev.js.map +7 -0
  12. package/src/Overlay.js +2 -0
  13. package/src/Overlay.js.map +7 -0
  14. package/src/OverlayBase.d.ts +124 -0
  15. package/src/OverlayBase.dev.js +744 -0
  16. package/src/OverlayBase.dev.js.map +7 -0
  17. package/src/OverlayBase.js +31 -0
  18. package/src/OverlayBase.js.map +7 -0
  19. package/src/OverlayDialog.d.ts +8 -0
  20. package/src/OverlayDialog.dev.js +160 -0
  21. package/src/OverlayDialog.dev.js.map +7 -0
  22. package/src/OverlayDialog.js +2 -0
  23. package/src/OverlayDialog.js.map +7 -0
  24. package/src/OverlayNoPopover.d.ts +8 -0
  25. package/src/OverlayNoPopover.dev.js +149 -0
  26. package/src/OverlayNoPopover.dev.js.map +7 -0
  27. package/src/OverlayNoPopover.js +2 -0
  28. package/src/OverlayNoPopover.js.map +7 -0
  29. package/src/OverlayPopover.d.ts +8 -0
  30. package/src/OverlayPopover.dev.js +199 -0
  31. package/src/OverlayPopover.dev.js.map +7 -0
  32. package/src/OverlayPopover.js +2 -0
  33. package/src/OverlayPopover.js.map +7 -0
  34. package/src/OverlayStack.d.ts +29 -0
  35. package/src/OverlayStack.dev.js +122 -0
  36. package/src/OverlayStack.dev.js.map +7 -0
  37. package/src/OverlayStack.js +2 -0
  38. package/src/OverlayStack.js.map +7 -0
  39. package/src/OverlayTrigger.d.ts +23 -31
  40. package/src/OverlayTrigger.dev.js +135 -245
  41. package/src/OverlayTrigger.dev.js.map +3 -3
  42. package/src/OverlayTrigger.js +52 -22
  43. package/src/OverlayTrigger.js.map +3 -3
  44. package/src/PlacementController.d.ts +36 -0
  45. package/src/PlacementController.dev.js +191 -0
  46. package/src/PlacementController.dev.js.map +7 -0
  47. package/src/PlacementController.js +2 -0
  48. package/src/PlacementController.js.map +7 -0
  49. package/src/VirtualTrigger.dev.js +0 -2
  50. package/src/VirtualTrigger.dev.js.map +2 -2
  51. package/src/VirtualTrigger.js +1 -1
  52. package/src/VirtualTrigger.js.map +3 -3
  53. package/src/fullSizePlugin.d.ts +12 -0
  54. package/src/fullSizePlugin.dev.js +39 -0
  55. package/src/fullSizePlugin.dev.js.map +7 -0
  56. package/src/fullSizePlugin.js +2 -0
  57. package/src/fullSizePlugin.js.map +7 -0
  58. package/src/index.d.ts +2 -3
  59. package/src/index.dev.js +2 -3
  60. package/src/index.dev.js.map +2 -2
  61. package/src/index.js +1 -1
  62. package/src/index.js.map +2 -2
  63. package/src/loader.d.ts +2 -2
  64. package/src/loader.dev.js +2 -19
  65. package/src/loader.dev.js.map +2 -2
  66. package/src/loader.js +1 -1
  67. package/src/loader.js.map +3 -3
  68. package/src/overlay-base.css.dev.js +9 -0
  69. package/src/overlay-base.css.dev.js.map +7 -0
  70. package/src/overlay-base.css.js +6 -0
  71. package/src/overlay-base.css.js.map +7 -0
  72. package/src/overlay-trigger.css.dev.js +1 -1
  73. package/src/overlay-trigger.css.dev.js.map +1 -1
  74. package/src/overlay-trigger.css.js +1 -1
  75. package/src/overlay-trigger.css.js.map +1 -1
  76. package/src/overlay-types.d.ts +6 -4
  77. package/src/overlay-types.dev.js +1 -0
  78. package/src/overlay-types.dev.js.map +3 -3
  79. package/src/overlay-types.js +1 -1
  80. package/src/overlay-types.js.map +3 -3
  81. package/src/topLayerOverTransforms.d.ts +23 -0
  82. package/src/topLayerOverTransforms.dev.js +170 -0
  83. package/src/topLayerOverTransforms.dev.js.map +7 -0
  84. package/src/topLayerOverTransforms.js +2 -0
  85. package/src/topLayerOverTransforms.js.map +7 -0
  86. package/stories/overlay-element.stories.js +247 -0
  87. package/stories/overlay-element.stories.js.map +7 -0
  88. package/stories/overlay-story-components.js +9 -8
  89. package/stories/overlay-story-components.js.map +2 -2
  90. package/stories/overlay.stories.js +780 -683
  91. package/stories/overlay.stories.js.map +2 -2
  92. package/sync/overlay-trigger.d.ts +4 -0
  93. package/sync/overlay-trigger.dev.js +1 -4
  94. package/sync/overlay-trigger.dev.js.map +2 -2
  95. package/sync/overlay-trigger.js +1 -1
  96. package/sync/overlay-trigger.js.map +3 -3
  97. package/test/benchmark/basic-test.js +1 -1
  98. package/test/benchmark/basic-test.js.map +1 -1
  99. package/test/index.js +407 -376
  100. package/test/index.js.map +3 -3
  101. package/test/overlay-element.test-vrt.js +5 -0
  102. package/test/overlay-element.test-vrt.js.map +7 -0
  103. package/test/overlay-element.test.js +664 -0
  104. package/test/overlay-element.test.js.map +7 -0
  105. package/test/overlay-lifecycle.test.js +34 -106
  106. package/test/overlay-lifecycle.test.js.map +2 -2
  107. package/test/overlay-trigger-click.test.js +11 -5
  108. package/test/overlay-trigger-click.test.js.map +2 -2
  109. package/test/overlay-trigger-extended.test.js +1 -6
  110. package/test/overlay-trigger-extended.test.js.map +2 -2
  111. package/test/overlay-trigger-hover-click.test.js +23 -23
  112. package/test/overlay-trigger-hover-click.test.js.map +2 -2
  113. package/test/overlay-trigger-hover.test.js +40 -34
  114. package/test/overlay-trigger-hover.test.js.map +2 -2
  115. package/test/overlay-trigger-longpress.test.js +98 -80
  116. package/test/overlay-trigger-longpress.test.js.map +2 -2
  117. package/test/overlay-trigger-sync.test.js +1 -1
  118. package/test/overlay-trigger-sync.test.js.map +2 -2
  119. package/test/overlay-trigger.test.js +1 -1
  120. package/test/overlay-trigger.test.js.map +2 -2
  121. package/test/overlay-update.test.js +4 -4
  122. package/test/overlay-update.test.js.map +2 -2
  123. package/test/{overlay.test.js → overlay-v1.test.js} +267 -249
  124. package/test/overlay-v1.test.js.map +7 -0
  125. package/test/overlay-v2.test.js +720 -0
  126. package/test/overlay-v2.test.js.map +7 -0
  127. package/active-overlay.d.ts +0 -6
  128. package/active-overlay.dev.js +0 -5
  129. package/active-overlay.js +0 -2
  130. package/src/ActiveOverlay.d.ts +0 -84
  131. package/src/ActiveOverlay.dev.js +0 -517
  132. package/src/ActiveOverlay.dev.js.map +0 -7
  133. package/src/ActiveOverlay.js +0 -16
  134. package/src/ActiveOverlay.js.map +0 -7
  135. package/src/active-overlay.css.dev.js +0 -13
  136. package/src/active-overlay.css.dev.js.map +0 -7
  137. package/src/active-overlay.css.js +0 -10
  138. package/src/active-overlay.css.js.map +0 -7
  139. package/src/overlay-stack.d.ts +0 -50
  140. package/src/overlay-stack.dev.js +0 -515
  141. package/src/overlay-stack.dev.js.map +0 -7
  142. package/src/overlay-stack.js +0 -34
  143. package/src/overlay-stack.js.map +0 -7
  144. package/src/overlay-utils.d.ts +0 -3
  145. package/src/overlay-utils.dev.js +0 -31
  146. package/src/overlay-utils.dev.js.map +0 -7
  147. package/src/overlay-utils.js +0 -2
  148. package/src/overlay-utils.js.map +0 -7
  149. package/src/overlay.d.ts +0 -59
  150. package/src/overlay.dev.js +0 -127
  151. package/src/overlay.dev.js.map +0 -7
  152. package/src/overlay.js +0 -2
  153. package/src/overlay.js.map +0 -7
  154. package/test/overlay.test.js.map +0 -7
  155. /package/src/{active-overlay.css.d.ts → overlay-base.css.d.ts} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["overlay-element.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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n oneEvent,\n} from '@open-wc/testing';\nimport { OverlayBase } from '@spectrum-web-components/overlay/src/OverlayBase.js';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { Theme } from '@spectrum-web-components/theme';\nimport { TemplateResult } from '@spectrum-web-components/base';\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/button/sp-button.js';\n\nimport { sendMouse } from '../../../test/plugins/browser.js';\nimport { Button } from '@spectrum-web-components/button';\n\nconst OVERLAY_TYPES = ['modal', 'page', 'hint', 'auto', 'manual'] as const;\ntype OverlayTypes = typeof OVERLAY_TYPES[number];\n\nasync function styledFixture<T extends Element>(\n story: TemplateResult\n): Promise<T> {\n const test = await fixture<Theme>(html`\n <sp-theme theme=\"spectrum\" scale=\"medium\" color=\"light\">\n ${story}\n </sp-theme>\n `);\n return test.children[0] as T;\n}\n\ndescribe('sp-overlay', () => {\n function opensDeclaratively(overlayType: OverlayTypes): void {\n it(`as [type=\"'${overlayType}'\"]`, async () => {\n const el = await styledFixture<OverlayBase>(html`\n <sp-overlay open type=${overlayType}>\n <sp-tooltip>Content</sp-tooltip>\n </sp-overlay>\n `);\n const content = el.children[0] as Tooltip;\n let opened = oneEvent(el, 'sp-opened');\n await opened;\n\n expect(content.open).to.be.true;\n const closed = oneEvent(el, 'sp-closed');\n el.open = false;\n await closed;\n\n expect(content.open).to.be.false;\n opened = oneEvent(el, 'sp-opened');\n el.open = true;\n await opened;\n\n expect(content.open).to.be.true;\n });\n }\n\n describe('[type=\"modal\"]', () => {\n opensDeclaratively('modal');\n describe('interaction with other non-ancestor overlays', function () {\n beforeEach(async function () {\n this.fixture = await styledFixture<OverlayBase>(html`\n <div>\n ${OVERLAY_TYPES.map(\n (type) => html`\n <sp-overlay type=${type}>\n <sp-tooltip>${type} Content</sp-tooltip>\n </sp-overlay>\n `\n )}\n </div>\n `);\n\n this.modal = this.fixture.querySelector(\n '[type=\"modal\"]'\n ) as OverlayBase;\n this.page = this.fixture.querySelector(\n '[type=\"page\"]'\n ) as OverlayBase;\n this.hint = this.fixture.querySelector(\n '[type=\"hint\"]'\n ) as OverlayBase;\n this.auto = this.fixture.querySelector(\n '[type=\"auto\"]'\n ) as OverlayBase;\n this.manual = this.fixture.querySelector(\n '[type=\"manual\"]'\n ) as OverlayBase;\n\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n afterEach(async function () {\n const closed = oneEvent(this.modal, 'sp-closed');\n this.modal.open = false;\n await closed;\n });\n it('closes \"page\" overlays when opening', async function () {\n let opened = oneEvent(this.page, 'sp-opened');\n this.page.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.modal, 'sp-opened');\n const closed = oneEvent(this.page, 'sp-closed');\n this.modal.open = true;\n await opened;\n await closed;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n it('closes \"hint\" overlays when opening', async function () {\n let opened = oneEvent(this.hint, 'sp-opened');\n this.hint.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.true;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.modal, 'sp-opened');\n const closed = oneEvent(this.hint, 'sp-closed');\n this.modal.open = true;\n await opened;\n await closed;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n it('closes \"auto\" overlays when opening', async function () {\n let opened = oneEvent(this.auto, 'sp-opened');\n this.auto.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.true;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.modal, 'sp-opened');\n const closed = oneEvent(this.auto, 'sp-closed');\n this.modal.open = true;\n await opened;\n await closed;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n it('does not close \"manual\" overlays when opening', async function () {\n let opened = oneEvent(this.manual, 'sp-opened');\n this.manual.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n\n opened = oneEvent(this.modal, 'sp-opened');\n this.modal.open = true;\n await opened;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n });\n });\n });\n describe('[type=\"page\"]', () => {\n opensDeclaratively('page');\n describe('interaction with other non-ancestor overlays', function () {\n beforeEach(async function () {\n this.fixture = await styledFixture<OverlayBase>(html`\n <div>\n ${OVERLAY_TYPES.map(\n (type) => html`\n <sp-overlay type=${type}>\n <sp-tooltip>${type} Content</sp-tooltip>\n </sp-overlay>\n `\n )}\n </div>\n `);\n\n this.modal = this.fixture.querySelector(\n '[type=\"modal\"]'\n ) as OverlayBase;\n this.page = this.fixture.querySelector(\n '[type=\"page\"]'\n ) as OverlayBase;\n this.hint = this.fixture.querySelector(\n '[type=\"hint\"]'\n ) as OverlayBase;\n this.auto = this.fixture.querySelector(\n '[type=\"auto\"]'\n ) as OverlayBase;\n this.manual = this.fixture.querySelector(\n '[type=\"manual\"]'\n ) as OverlayBase;\n\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n afterEach(async function () {\n const closed = oneEvent(this.page, 'sp-closed');\n this.page.open = false;\n await closed;\n });\n it('closes \"page\" overlays when opening', async function () {\n let opened = oneEvent(this.modal, 'sp-opened');\n this.modal.open = true;\n await opened;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.page, 'sp-opened');\n const closed = oneEvent(this.modal, 'sp-closed');\n this.page.open = true;\n await opened;\n await closed;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n it('closes \"hint\" overlays when opening', async function () {\n let opened = oneEvent(this.hint, 'sp-opened');\n this.hint.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.true;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.page, 'sp-opened');\n const closed = oneEvent(this.hint, 'sp-closed');\n this.page.open = true;\n await opened;\n await closed;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n it('closes \"auto\" overlays when opening', async function () {\n let opened = oneEvent(this.auto, 'sp-opened');\n this.auto.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.true;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.page, 'sp-opened');\n const closed = oneEvent(this.auto, 'sp-closed');\n this.page.open = true;\n await opened;\n await closed;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n it('does not close \"manual\" overlays when opening', async function () {\n let opened = oneEvent(this.manual, 'sp-opened');\n this.manual.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n\n opened = oneEvent(this.page, 'sp-opened');\n this.page.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n });\n });\n });\n\n describe('[type=\"hint\"]', () => {\n opensDeclaratively('hint');\n\n it('closes other `[type=hint]` overlays when opening', async () => {\n const test = await styledFixture<OverlayBase>(html`\n <div>\n ${[1, 2].map(\n (overlay) => html`\n <sp-overlay type=\"hint\" class=\"hint-${overlay}\">\n <sp-tooltip>Hint ${overlay} Content</sp-tooltip>\n </sp-overlay>\n `\n )}\n </div>\n `);\n const hint1 = test.querySelector('.hint-1') as OverlayBase;\n const hint2 = test.querySelector('.hint-2') as OverlayBase;\n\n expect(hint1.open).to.be.false;\n expect(hint2.open).to.be.false;\n\n let opened = oneEvent(hint1, 'sp-opened');\n hint1.open = true;\n await opened;\n\n expect(hint1.open).to.be.true;\n expect(hint2.open).to.be.false;\n\n opened = oneEvent(hint2, 'sp-opened');\n let closed = oneEvent(hint1, 'sp-closed');\n hint2.open = true;\n await opened;\n await closed;\n\n expect(hint1.open).to.be.false;\n expect(hint2.open).to.be.true;\n\n opened = oneEvent(hint1, 'sp-opened');\n closed = oneEvent(hint2, 'sp-closed');\n hint1.open = true;\n await opened;\n await closed;\n\n expect(hint1.open).to.be.true;\n expect(hint2.open).to.be.false;\n });\n it('stays open when pointer enters overlay from trigger element', async () => {\n const test = await styledFixture(\n html`\n <div>\n <sp-button id=\"test-button\">\n This is a button.\n </sp-button>\n <sp-overlay\n trigger=\"test-button@hover\"\n placement=\"bottom\"\n offset=\"-10\"\n >\n <sp-tooltip>Help text.</sp-tooltip>\n </sp-overlay>\n </div>\n `\n );\n\n const button = test.querySelector('sp-button') as Button;\n const overlay = test.querySelector(\n 'sp-overlay'\n ) as unknown as OverlayBase;\n const el = test.querySelector('sp-tooltip') as Tooltip;\n const buttonRect = button.getBoundingClientRect();\n const buttonPoint = [\n buttonRect.x + buttonRect.width / 2,\n buttonRect.y + buttonRect.height - 2,\n ] as [number, number];\n\n await elementUpdated(overlay);\n // This test is possibly weird in its over simplicity for this contexts...\n await expect(button).to.be.accessible();\n // Pointer enter the button to trigger the tooltip\n let opened = oneEvent(button, 'sp-opened');\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: buttonPoint,\n },\n ],\n });\n await nextFrame();\n await nextFrame();\n await nextFrame();\n await nextFrame();\n expect(overlay.open).to.be.true;\n // Pointer leave the button to close the tooltip, but...\n // Pointer enter the tooltip to keep the tooltip open\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width / 2,\n buttonRect.y + buttonRect.height - 1,\n ],\n },\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width / 2,\n buttonRect.y + buttonRect.height,\n ],\n },\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width / 2,\n buttonRect.y + buttonRect.height + 1,\n ],\n },\n ],\n });\n await nextFrame();\n await nextFrame();\n expect(overlay.open).to.be.true;\n await opened;\n\n expect(el.open).to.be.true;\n await expect(button).to.be.accessible();\n\n let closed = oneEvent(button, 'sp-closed');\n // point enter the button to trigger the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: buttonPoint,\n },\n ],\n });\n // pointer leave the button to close the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width * 2,\n buttonRect.y + buttonRect.height * 2,\n ] as [number, number],\n },\n ],\n });\n await closed;\n\n expect(el.open).to.be.false;\n\n opened = oneEvent(button, 'sp-opened');\n // pointer enter the button to trigger the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: buttonPoint,\n },\n ],\n });\n await opened;\n await elementUpdated(el);\n closed = oneEvent(button, 'sp-closed');\n // pointer leave the button to close the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width * 2,\n buttonRect.y + buttonRect.height * 2,\n ] as [number, number],\n },\n ],\n });\n await closed;\n });\n it('stays open when pointer enters overlay from trigger element', async () => {\n const button = await styledFixture(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed placement=\"bottom\">\n Help text.\n </sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n const buttonRect = button.getBoundingClientRect();\n const buttonPoint = [\n buttonRect.x + buttonRect.width / 2,\n buttonRect.y + buttonRect.height / 2,\n ] as [number, number];\n\n await elementUpdated(el);\n // This test is possibly weird in its over simplicity for this contexts...\n await expect(button).to.be.accessible();\n // Pointer enter the button to trigger the tooltip\n let opened = oneEvent(button, 'sp-opened');\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: buttonPoint,\n },\n ],\n });\n // It takes this many frame for the overlay content to actual be queryable.\n // We're trying to do work _before_ `sp-opened` so it's a little tricky.\n // Is it possible to do this work _after_ `sp-opened` for more stability?\n // Try futzing with the `offset` values of the `sp-overlay`?\n await nextFrame();\n await nextFrame();\n await nextFrame();\n await nextFrame();\n const tooltipRect = (\n el.shadowRoot.querySelector('#tooltip') as HTMLDivElement\n ).getBoundingClientRect();\n const tooltipPoint = [\n tooltipRect.x + tooltipRect.width / 2,\n tooltipRect.y + tooltipRect.height / 2,\n ] as [number, number];\n // Pointer leave the button to close the tooltip, but...\n // Pointer enter the tooltip to keep the tooltip open\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: tooltipPoint,\n },\n ],\n });\n await opened;\n\n expect(el.open).to.be.true;\n await expect(button).to.be.accessible();\n\n let closed = oneEvent(button, 'sp-closed');\n // point enter the button to trigger the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: buttonPoint,\n },\n ],\n });\n // pointer leave the button to close the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width * 2,\n buttonRect.y + buttonRect.height * 2,\n ] as [number, number],\n },\n ],\n });\n await closed;\n\n expect(el.open).to.be.false;\n\n opened = oneEvent(button, 'sp-opened');\n // pointer enter the button to trigger the tooltip\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: buttonPoint,\n },\n ],\n });\n await opened;\n expect(el.open).to.be.true;\n\n closed = oneEvent(button, 'sp-closed');\n // pointer leave the button to close the tooltip\n sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n buttonRect.x + buttonRect.width * 2,\n buttonRect.y + buttonRect.height * 2,\n ] as [number, number],\n },\n ],\n });\n await closed;\n expect(el.open).to.be.false;\n });\n });\n describe('[type=\"auto\"]', () => {\n opensDeclaratively('auto');\n });\n describe('[type=\"manual\"]', () => {\n opensDeclaratively('manual');\n describe('interaction with other non-ancestor overlays', function () {\n beforeEach(async function () {\n this.fixture = await styledFixture<OverlayBase>(html`\n <div>\n ${OVERLAY_TYPES.map(\n (type) => html`\n <sp-overlay type=${type}>\n <sp-tooltip>${type} Content</sp-tooltip>\n </sp-overlay>\n `\n )}\n </div>\n `);\n\n this.modal = this.fixture.querySelector(\n '[type=\"modal\"]'\n ) as OverlayBase;\n this.page = this.fixture.querySelector(\n '[type=\"page\"]'\n ) as OverlayBase;\n this.hint = this.fixture.querySelector(\n '[type=\"hint\"]'\n ) as OverlayBase;\n this.auto = this.fixture.querySelector(\n '[type=\"auto\"]'\n ) as OverlayBase;\n this.manual = this.fixture.querySelector(\n '[type=\"manual\"]'\n ) as OverlayBase;\n\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n });\n afterEach(async function () {\n const closed = oneEvent(this.manual, 'sp-closed');\n this.manual.open = false;\n await closed;\n });\n it('does not close \"modal\" overlays when opening', async function () {\n let opened = oneEvent(this.modal, 'sp-opened');\n this.modal.open = true;\n await opened;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.manual, 'sp-opened');\n this.manual.open = true;\n await opened;\n expect(this.modal.open).to.be.true;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n });\n it('does not close \"modal\" overlays when opening', async function () {\n let opened = oneEvent(this.page, 'sp-opened');\n this.page.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.manual, 'sp-opened');\n this.manual.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.true;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n });\n it('does not close \"hint\" overlays when opening', async function () {\n let opened = oneEvent(this.hint, 'sp-opened');\n this.hint.open = true;\n await opened;\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.true;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.manual, 'sp-opened');\n this.manual.open = true;\n await opened;\n\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.true;\n expect(this.auto.open).to.be.false;\n expect(this.manual.open).to.be.true;\n });\n it('does not close \"auto\" overlays when opening', async function () {\n let opened = oneEvent(this.auto, 'sp-opened');\n this.auto.open = true;\n await opened;\n\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.true;\n expect(this.manual.open).to.be.false;\n\n opened = oneEvent(this.manual, 'sp-opened');\n this.manual.open = true;\n await opened;\n\n expect(this.modal.open).to.be.false;\n expect(this.page.open).to.be.false;\n expect(this.hint.open).to.be.false;\n expect(this.auto.open).to.be.true;\n expect(this.manual.open).to.be.true;\n });\n });\n });\n});\n"],
5
+ "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AAEP,OAAO;AAGP,OAAO;AACP,OAAO;AACP,OAAO;AAEP,SAAS,iBAAiB;AAG1B,MAAM,gBAAgB,CAAC,SAAS,QAAQ,QAAQ,QAAQ,QAAQ;AAGhE,eAAe,cACX,OACU;AACV,QAAM,OAAO,MAAM,QAAe;AAAA;AAAA,cAExB;AAAA;AAAA,KAET;AACD,SAAO,KAAK,SAAS,CAAC;AAC1B;AAEA,SAAS,cAAc,MAAM;AACzB,WAAS,mBAAmB,aAAiC;AACzD,OAAG,cAAc,kBAAkB,YAAY;AAC3C,YAAM,KAAK,MAAM,cAA2B;AAAA,wCAChB;AAAA;AAAA;AAAA,aAG3B;AACD,YAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,UAAI,SAAS,SAAS,IAAI,WAAW;AACrC,YAAM;AAEN,aAAO,QAAQ,IAAI,EAAE,GAAG,GAAG;AAC3B,YAAM,SAAS,SAAS,IAAI,WAAW;AACvC,SAAG,OAAO;AACV,YAAM;AAEN,aAAO,QAAQ,IAAI,EAAE,GAAG,GAAG;AAC3B,eAAS,SAAS,IAAI,WAAW;AACjC,SAAG,OAAO;AACV,YAAM;AAEN,aAAO,QAAQ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,KAAK,MAAM,WAAW;AAC5C,aAAK,KAAK,OAAO;AACjB,cAAM;AAEN,eAAO,KAAK,MAAM,IAAI,EAAE,GAAG,GAAG;AAC9B,eAAO,KAAK,KAAK,IAAI,EAAE,GAAG,GAAG;AAC7B,eAAO,KAAK,KAAK,IAAI,EAAE,GAAG,GAAG;AAC7B,eAAO,KAAK,KAAK,IAAI,EAAE,GAAG,GAAG;AAC7B,eAAO,KAAK,OAAO,IAAI,EAAE,GAAG,GAAG;AAE/B,iBAAS,SAAS,KAAK,QAAQ,WAAW;AAC1C,aAAK,OAAO,OAAO;AACnB,cAAM;AAEN,eAAO,KAAK,MAAM,IAAI,EAAE,GAAG,GAAG;AAC9B,eAAO,KAAK,KAAK,IAAI,EAAE,GAAG,GAAG;AAC7B,eAAO,KAAK,KAAK,IAAI,EAAE,GAAG,GAAG;AAC7B,eAAO,KAAK,KAAK,IAAI,EAAE,GAAG,GAAG;AAC7B,eAAO,KAAK,OAAO,IAAI,EAAE,GAAG,GAAG;AAAA,MACnC,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC;AACL,CAAC;",
6
+ "names": []
7
+ }
@@ -4,15 +4,15 @@ import {
4
4
  expect,
5
5
  fixture,
6
6
  html,
7
- oneEvent,
8
- waitUntil
7
+ nextFrame,
8
+ oneEvent
9
9
  } from "@open-wc/testing";
10
10
  import "@spectrum-web-components/tooltip/sp-tooltip.js";
11
11
  import "@spectrum-web-components/action-button/sp-action-button.js";
12
12
  import "@spectrum-web-components/overlay/overlay-trigger.js";
13
13
  import { a11ySnapshot, findAccessibilityNode } from "@web/test-runner-commands";
14
- describe("Overlay Trigger - Lifecycle Methods", () => {
15
- it("calls the overlay lifecycle (willOpen/Close)", async () => {
14
+ describe("Overlay Trigger - accessible hover content management", () => {
15
+ it("accessibly describes trigger content with hover content", async () => {
16
16
  const el = await fixture(html`
17
17
  <overlay-trigger placement="right-start">
18
18
  <sp-action-button slot="trigger">
@@ -25,9 +25,9 @@ describe("Overlay Trigger - Lifecycle Methods", () => {
25
25
  `);
26
26
  await elementUpdated(el);
27
27
  expect(el.open).to.be.undefined;
28
- expect(el.childNodes.length).to.equal(5);
29
- const trigger = el.querySelector('[slot="trigger"]');
30
- let snapshot = await a11ySnapshot({});
28
+ const snapshot = await a11ySnapshot(
29
+ {}
30
+ );
31
31
  expect(
32
32
  findAccessibilityNode(
33
33
  snapshot,
@@ -35,60 +35,6 @@ describe("Overlay Trigger - Lifecycle Methods", () => {
35
35
  ),
36
36
  "`name`ed with no `description`"
37
37
  );
38
- const opened = oneEvent(el, "sp-opened");
39
- trigger.dispatchEvent(
40
- new FocusEvent("focusin", { bubbles: true, composed: true })
41
- );
42
- await opened;
43
- expect(el.open).to.equal("hover");
44
- snapshot = await a11ySnapshot({});
45
- expect(el.childNodes.length).to.equal(6);
46
- expect(
47
- findAccessibilityNode(
48
- snapshot,
49
- (node) => node.name === "Button with Tooltip" && node.description === "Described by this content on focus/hover."
50
- ),
51
- "`name`ed with `description`"
52
- );
53
- const closed = oneEvent(el, "sp-closed");
54
- trigger.dispatchEvent(
55
- new FocusEvent("focusout", { bubbles: true, composed: true })
56
- );
57
- await closed;
58
- await elementUpdated(el);
59
- await waitUntil(() => el.open === null);
60
- expect(el.childNodes.length).to.equal(5);
61
- });
62
- it("calls the overlay lifecycle (willOpen/openCanceled)", async () => {
63
- const el = await fixture(html`
64
- <overlay-trigger placement="right-start">
65
- <sp-action-button slot="trigger">
66
- Button with Tooltip
67
- </sp-action-button>
68
- <sp-tooltip slot="hover-content" delayed>
69
- Described by this content on focus/hover. 2
70
- </sp-tooltip>
71
- </overlay-trigger>
72
- `);
73
- await elementUpdated(el);
74
- expect(el.open).to.be.undefined;
75
- expect(el.childNodes.length, "always").to.equal(5);
76
- const trigger = el.querySelector('[slot="trigger"]');
77
- trigger.dispatchEvent(
78
- new FocusEvent("focusin", { bubbles: true, composed: true })
79
- );
80
- await elementUpdated(el);
81
- trigger.dispatchEvent(
82
- new FocusEvent("focusout", { bubbles: true, composed: true })
83
- );
84
- await elementUpdated(el);
85
- await waitUntil(() => {
86
- return el.open === null;
87
- }, "open");
88
- await elementUpdated(el);
89
- await waitUntil(() => {
90
- return el.childNodes.length === 5;
91
- }, "children");
92
38
  });
93
39
  it("gardens `aria-describedby` in its target", async () => {
94
40
  const el = await fixture(html`
@@ -103,27 +49,18 @@ describe("Overlay Trigger - Lifecycle Methods", () => {
103
49
  <div id="descriptor">I'm a description!</div>
104
50
  `);
105
51
  const trigger = el.querySelector('[slot="trigger"]');
106
- const tooltip = el.querySelector("sp-tooltip");
107
- await elementUpdated(el);
108
- expect(trigger.getAttribute("aria-describedby")).to.equal("descriptor");
109
- expect(el.open).to.be.undefined;
110
- expect(el.childNodes.length, "always").to.equal(5);
111
- const opened = oneEvent(el, "sp-opened");
112
- trigger.dispatchEvent(
113
- new FocusEvent("focusin", { bubbles: true, composed: true })
52
+ const tooptip = el.querySelector(
53
+ '[slot="hover-content"]'
114
54
  );
115
- await opened;
55
+ await elementUpdated(el);
116
56
  expect(trigger.getAttribute("aria-describedby")).to.equal(
117
- `descriptor ${tooltip._tooltipId}`
57
+ `descriptor ${tooptip.id}`
118
58
  );
119
- const closed = oneEvent(el, "sp-closed");
120
- trigger.dispatchEvent(
121
- new FocusEvent("focusout", { bubbles: true, composed: true })
122
- );
123
- await closed;
59
+ trigger.remove();
60
+ await nextFrame();
124
61
  expect(trigger.getAttribute("aria-describedby")).to.equal("descriptor");
125
62
  });
126
- it("adds and removes `aria-describedby` attribute", async () => {
63
+ it("applies `aria-describedby` attribute", async () => {
127
64
  const el = await fixture(html`
128
65
  <overlay-trigger placement="right-start">
129
66
  <sp-action-button slot="trigger">
@@ -135,57 +72,48 @@ describe("Overlay Trigger - Lifecycle Methods", () => {
135
72
  </overlay-trigger>
136
73
  `);
137
74
  const trigger = el.querySelector('[slot="trigger"]');
138
- const tooltip = el.querySelector("sp-tooltip");
139
- await elementUpdated(el);
140
- expect(trigger.hasAttribute("aria-describedby")).to.be.false;
141
- expect(el.open).to.be.undefined;
142
- expect(el.childNodes.length, "always").to.equal(5);
143
- const opened = oneEvent(el, "sp-opened");
144
- trigger.dispatchEvent(
145
- new FocusEvent("focusin", { bubbles: true, composed: true })
146
- );
147
- await opened;
148
- expect(trigger.getAttribute("aria-describedby")).to.equal(
149
- `${tooltip._tooltipId}`
150
- );
151
- const closed = oneEvent(el, "sp-closed");
152
- trigger.dispatchEvent(
153
- new FocusEvent("focusout", { bubbles: true, composed: true })
75
+ const tooptip = el.querySelector(
76
+ '[slot="hover-content"]'
154
77
  );
155
- await closed;
156
- expect(trigger.hasAttribute("aria-describedby")).to.be.false;
78
+ await elementUpdated(el);
79
+ expect(trigger.getAttribute("aria-describedby")).to.equal(tooptip.id);
80
+ trigger.remove();
81
+ await nextFrame();
82
+ expect(trigger.getAttribute("aria-describedby")).to.be.null;
157
83
  });
158
84
  it("does not duplicate `aria-describedby` attribute", async () => {
159
85
  const el = await fixture(html`
160
- <overlay-trigger placement="right-start">
86
+ <div>
161
87
  <sp-action-button slot="trigger">
162
88
  Button with Tooltip
163
89
  </sp-action-button>
164
- <sp-tooltip slot="hover-content" delayed>
165
- Described by this content on focus/hover. 2
166
- </sp-tooltip>
167
- </overlay-trigger>
90
+ <overlay-trigger placement="right-start">
91
+ <sp-tooltip slot="hover-content" delayed>
92
+ Described by this content on focus/hover. 2
93
+ </sp-tooltip>
94
+ </overlay-trigger>
95
+ </div>
168
96
  `);
169
97
  const trigger = el.querySelector('[slot="trigger"]');
170
98
  const tooltip = el.querySelector("sp-tooltip");
171
- const tooltipId = tooltip._tooltipId;
172
- trigger.setAttribute("aria-describedby", tooltipId);
99
+ const overlay = el.querySelector("overlay-trigger");
100
+ trigger.setAttribute("aria-describedby", tooltip.id);
101
+ overlay.append(trigger);
173
102
  await elementUpdated(el);
174
- expect(trigger.getAttribute("aria-describedby")).to.equal(tooltipId);
103
+ expect(trigger.getAttribute("aria-describedby")).to.equal(tooltip.id);
175
104
  expect(el.open).to.be.undefined;
176
- expect(el.childNodes.length, "always").to.equal(5);
177
105
  const opened = oneEvent(el, "sp-opened");
178
106
  trigger.dispatchEvent(
179
107
  new FocusEvent("focusin", { bubbles: true, composed: true })
180
108
  );
181
109
  await opened;
182
- expect(trigger.getAttribute("aria-describedby")).to.equal(tooltipId);
110
+ expect(trigger.getAttribute("aria-describedby")).to.equal(tooltip.id);
183
111
  const closed = oneEvent(el, "sp-closed");
184
112
  trigger.dispatchEvent(
185
113
  new FocusEvent("focusout", { bubbles: true, composed: true })
186
114
  );
187
115
  await closed;
188
- expect(trigger.getAttribute("aria-describedby")).to.equal(tooltipId);
116
+ expect(trigger.getAttribute("aria-describedby")).to.equal(tooltip.id);
189
117
  });
190
118
  });
191
119
  //# sourceMappingURL=overlay-lifecycle.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-lifecycle.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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport { OverlayTrigger } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { a11ySnapshot, findAccessibilityNode } from '@web/test-runner-commands';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\n\ndescribe('Overlay Trigger - Lifecycle Methods', () => {\n it('calls the overlay lifecycle (willOpen/Close)', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\">\n Described by this content on focus/hover. 1\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length).to.equal(5);\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n type DescribedNode = {\n name: string;\n description: string;\n };\n let snapshot = (await a11ySnapshot({})) as unknown as DescribedNode & {\n children: DescribedNode[];\n };\n expect(\n findAccessibilityNode<DescribedNode>(\n snapshot,\n (node) =>\n node.name === 'Button with Tooltip' &&\n typeof node.description === 'undefined'\n ),\n '`name`ed with no `description`'\n );\n const opened = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await opened;\n\n expect(el.open).to.equal('hover');\n snapshot = (await a11ySnapshot({})) as unknown as DescribedNode & {\n children: DescribedNode[];\n };\n\n expect(el.childNodes.length).to.equal(6);\n expect(\n findAccessibilityNode<DescribedNode>(\n snapshot,\n (node) =>\n node.name === 'Button with Tooltip' &&\n node.description ===\n 'Described by this content on focus/hover.'\n ),\n '`name`ed with `description`'\n );\n\n const closed = oneEvent(el, 'sp-closed');\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await closed;\n await elementUpdated(el);\n\n await waitUntil(() => el.open === null);\n expect(el.childNodes.length).to.equal(5);\n });\n it('calls the overlay lifecycle (willOpen/openCanceled)', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length, 'always').to.equal(5);\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await elementUpdated(el);\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await elementUpdated(el);\n\n await waitUntil(() => {\n return el.open === null;\n }, 'open');\n await elementUpdated(el);\n await waitUntil(() => {\n return el.childNodes.length === 5;\n }, 'children');\n });\n it('gardens `aria-describedby` in its target', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\" aria-describedby=\"descriptor\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n <div id=\"descriptor\">I'm a description!</div>\n `);\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n const tooltip = el.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(trigger.getAttribute('aria-describedby')).to.equal('descriptor');\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length, 'always').to.equal(5);\n\n const opened = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await opened;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(\n `descriptor ${\n (tooltip as unknown as { _tooltipId: string })._tooltipId\n }`\n );\n\n const closed = oneEvent(el, 'sp-closed');\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await closed;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal('descriptor');\n });\n it('adds and removes `aria-describedby` attribute', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n const tooltip = el.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(trigger.hasAttribute('aria-describedby')).to.be.false;\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length, 'always').to.equal(5);\n\n const opened = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await opened;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(\n `${(tooltip as unknown as { _tooltipId: string })._tooltipId}`\n );\n\n const closed = oneEvent(el, 'sp-closed');\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await closed;\n\n expect(trigger.hasAttribute('aria-describedby')).to.be.false;\n });\n it('does not duplicate `aria-describedby` attribute', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n const tooltip = el.querySelector('sp-tooltip') as Tooltip;\n const tooltipId = (tooltip as unknown as { _tooltipId: string })\n ._tooltipId;\n trigger.setAttribute('aria-describedby', tooltipId);\n\n await elementUpdated(el);\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooltipId);\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length, 'always').to.equal(5);\n\n const opened = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await opened;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooltipId);\n\n const closed = oneEvent(el, 'sp-closed');\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await closed;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooltipId);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DAAmD,YAAY;AAC9D,UAAM,KAAK,MAAM,QAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SASxC;AAED,UAAM,UAAU,GAAG,cAAc,kBAAkB;AACnD,UAAM,UAAU,GAAG,cAAc,YAAY;AAC7C,UAAM,YAAa,QACd;AACL,YAAQ,aAAa,oBAAoB,SAAS;AAElD,UAAM,eAAe,EAAE;AAEvB,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,MAAM,SAAS;AACnE,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AACtB,WAAO,GAAG,WAAW,QAAQ,QAAQ,EAAE,GAAG,MAAM,CAAC;AAEjD,UAAM,SAAS,SAAS,IAAI,WAAW;AACvC,YAAQ;AAAA,MACJ,IAAI,WAAW,WAAW,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC;AAAA,IAC/D;AACA,UAAM;AAEN,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,MAAM,SAAS;AAEnE,UAAM,SAAS,SAAS,IAAI,WAAW;AACvC,YAAQ;AAAA,MACJ,IAAI,WAAW,YAAY,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC;AAAA,IAChE;AACA,UAAM;AAEN,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,MAAM,SAAS;AAAA,EACvE,CAAC;AACL,CAAC;",
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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n oneEvent,\n} from '@open-wc/testing';\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport { OverlayTrigger } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { a11ySnapshot, findAccessibilityNode } from '@web/test-runner-commands';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\n\ndescribe('Overlay Trigger - accessible hover content management', () => {\n it('accessibly describes trigger content with hover content', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\">\n Described by this content on focus/hover. 1\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n type DescribedNode = {\n name: string;\n description: string;\n };\n const snapshot = (await a11ySnapshot(\n {}\n )) as unknown as DescribedNode & {\n children: DescribedNode[];\n };\n expect(\n findAccessibilityNode<DescribedNode>(\n snapshot,\n (node) =>\n node.name === 'Button with Tooltip' &&\n typeof node.description === 'undefined'\n ),\n '`name`ed with no `description`'\n );\n });\n it('gardens `aria-describedby` in its target', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\" aria-describedby=\"descriptor\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n <div id=\"descriptor\">I'm a description!</div>\n `);\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n const tooptip = el.querySelector(\n '[slot=\"hover-content\"]'\n ) as HTMLElement;\n\n await elementUpdated(el);\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(\n `descriptor ${tooptip.id}`\n );\n\n trigger.remove();\n\n // slot change timing\n await nextFrame();\n\n expect(trigger.getAttribute('aria-describedby')).to.equal('descriptor');\n });\n it('applies `aria-describedby` attribute', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n const tooptip = el.querySelector(\n '[slot=\"hover-content\"]'\n ) as HTMLElement;\n\n await elementUpdated(el);\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooptip.id);\n\n trigger.remove();\n\n // slot change timing\n await nextFrame();\n\n expect(trigger.getAttribute('aria-describedby')).to.be.null;\n });\n it('does not duplicate `aria-describedby` attribute', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <div>\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <overlay-trigger placement=\"right-start\">\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n </div>\n `);\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n const tooltip = el.querySelector('sp-tooltip') as Tooltip;\n const overlay = el.querySelector('overlay-trigger') as OverlayTrigger;\n\n trigger.setAttribute('aria-describedby', tooltip.id);\n overlay.append(trigger);\n\n await elementUpdated(el);\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooltip.id);\n expect(el.open).to.be.undefined;\n\n const opened = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await opened;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooltip.id);\n\n const closed = oneEvent(el, 'sp-closed');\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await closed;\n\n expect(trigger.getAttribute('aria-describedby')).to.equal(tooltip.id);\n });\n});\n"],
5
+ "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAA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M,QAAQ,EAAE;AAEpE,YAAQ,OAAO;AAGf,UAAM,UAAU;AAEhB,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,GAAG;AAAA,EAC3D,CAAC;AACD,KAAG,mDAAmD,YAAY;AAC9D,UAAM,KAAK,MAAM,QAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAWxC;AAED,UAAM,UAAU,GAAG,cAAc,kBAAkB;AACnD,UAAM,UAAU,GAAG,cAAc,YAAY;AAC7C,UAAM,UAAU,GAAG,cAAc,iBAAiB;AAElD,YAAQ,aAAa,oBAAoB,QAAQ,EAAE;AACnD,YAAQ,OAAO,OAAO;AAEtB,UAAM,eAAe,EAAE;AACvB,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,MAAM,QAAQ,EAAE;AACpE,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AAEtB,UAAM,SAAS,SAAS,IAAI,WAAW;AACvC,YAAQ;AAAA,MACJ,IAAI,WAAW,WAAW,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC;AAAA,IAC/D;AACA,UAAM;AAEN,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,MAAM,QAAQ,EAAE;AAEpE,UAAM,SAAS,SAAS,IAAI,WAAW;AACvC,YAAQ;AAAA,MACJ,IAAI,WAAW,YAAY,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC;AAAA,IAChE;AACA,UAAM;AAEN,WAAO,QAAQ,aAAa,kBAAkB,CAAC,EAAE,GAAG,MAAM,QAAQ,EAAE;AAAA,EACxE,CAAC;AACL,CAAC;",
6
6
  "names": []
7
7
  }
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  elementUpdated,
4
4
  expect,
5
- fixture,
6
5
  html,
6
+ nextFrame,
7
7
  oneEvent,
8
8
  waitUntil
9
9
  } from "@open-wc/testing";
10
10
  import "@spectrum-web-components/popover/sp-popover.js";
11
11
  import "@spectrum-web-components/action-button/sp-action-button.js";
12
12
  import "@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js";
13
- import "@spectrum-web-components/popover/sp-popover.js";
14
13
  import "@spectrum-web-components/overlay/overlay-trigger.js";
15
14
  import { spy } from "sinon";
15
+ import { fixture, isInteractive } from "../../../test/testing-helpers.js";
16
16
  describe("Overlay Trigger - Click", () => {
17
17
  it("displays `click` declaratively", async () => {
18
18
  const openedSpy = spy();
@@ -32,12 +32,14 @@ describe("Overlay Trigger - Click", () => {
32
32
  </overlay-trigger>
33
33
  `)()
34
34
  );
35
- await elementUpdated(el);
36
35
  await waitUntil(
37
- () => openedSpy.calledOnce,
36
+ () => {
37
+ return openedSpy.calledOnce;
38
+ },
38
39
  "click content projected to overlay",
39
40
  { timeout: 2e3 }
40
41
  );
42
+ await nextFrame();
41
43
  el.removeAttribute("open");
42
44
  await elementUpdated(el);
43
45
  await waitUntil(() => closedSpy.calledOnce, "click content returned", {
@@ -67,18 +69,22 @@ describe("Overlay Trigger - Click", () => {
67
69
  <sp-popover slot="click-content" tip></sp-popover>
68
70
  </overlay-trigger>
69
71
  `);
72
+ await nextFrame();
73
+ const popover = el.querySelector("sp-popover");
70
74
  expect(el.open).to.be.undefined;
71
75
  await elementUpdated(el);
72
76
  const opened = oneEvent(el, "sp-opened");
73
77
  el.open = "click";
74
78
  await opened;
75
79
  expect(el.open).to.equal("click");
80
+ expect(await isInteractive(popover)).to.be.true;
76
81
  const closed = oneEvent(el, "sp-closed");
77
82
  if (document.scrollingElement) {
78
83
  document.scrollingElement.scrollTop = 100;
79
84
  }
80
85
  await closed;
81
- expect(el.open).to.be.null;
86
+ expect(el.open).to.be.undefined;
87
+ expect(await isInteractive(popover)).to.be.false;
82
88
  });
83
89
  }
84
90
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-trigger-click.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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport {\n OverlayTrigger,\n TriggerInteractions,\n} from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { spy } from 'sinon';\nimport { ActionButton } from '@spectrum-web-components/action-button';\n\ndescribe('Overlay Trigger - Click', () => {\n it('displays `click` declaratively', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger\n placement=\"right-start\"\n open=\"click\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'click content returned', {\n timeout: 2000,\n });\n });\n describe('closes on scroll', () => {\n afterEach(() => {\n if (document.scrollingElement) {\n document.scrollingElement.scrollTop = 0;\n }\n });\n (['click', 'replace', 'inline'] as TriggerInteractions[]).map(\n (interaction) => {\n it(`closes \"${interaction}\" overlay on scroll`, async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger\n placement=\"right-start\"\n type=${interaction}\n >\n <sp-action-button\n slot=\"trigger\"\n style=\"margin: 50vh 0 100vh;\"\n >\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `);\n expect(el.open).to.be.undefined;\n\n await elementUpdated(el);\n const opened = oneEvent(el, 'sp-opened');\n el.open = 'click';\n await opened;\n\n expect(el.open).to.equal('click');\n\n const closed = oneEvent(el, 'sp-closed');\n if (document.scrollingElement) {\n document.scrollingElement.scrollTop = 100;\n }\n await closed;\n\n expect(el.open).to.be.null;\n });\n }\n );\n });\n it('opens a second time', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger\n placement=\"right-start\"\n type=\"modal\"\n open=\"click\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `);\n await elementUpdated(el);\n const trigger = el.querySelector('[slot=trigger]') as ActionButton;\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n expect(el.open).to.equal('click');\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'click content returned', {\n timeout: 2000,\n });\n\n expect(el.open).to.be.null;\n\n trigger.click();\n await waitUntil(\n () => openedSpy.callCount === 2,\n 'click content projected to overlay, again',\n { timeout: 2000 }\n );\n expect(el.open).to.equal('click');\n });\n});\n"],
5
- "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,OAAO;AACP,OAAO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C1C;AACA,gBAAM;AAEN,iBAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AAAA,QAC1B,CAAC;AAAA,MACL;AAAA,IACJ;AAAA,EACJ,CAAC;AACD,KAAG,uBAAuB,YAAY;AAClC,UAAM,YAAY,IAAI;AACtB,UAAM,YAAY,IAAI;AACtB,UAAM,KAAK,MAAM,QAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,6BAKpB,MAAM,UAAU;AAAA,6BAChB,MAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAOpC;AACD,UAAM,eAAe,EAAE;AACvB,UAAM,UAAU,GAAG,cAAc,gBAAgB;AAEjD,UAAM;AAAA,MACF,MAAM,UAAU;AAAA,MAChB;AAAA,MACA,EAAE,SAAS,IAAK;AAAA,IACpB;AACA,WAAO,GAAG,IAAI,EAAE,GAAG,MAAM,OAAO;AAEhC,OAAG,gBAAgB,MAAM;AACzB,UAAM,eAAe,EAAE;AAEvB,UAAM,UAAU,MAAM,UAAU,YAAY,0BAA0B;AAAA,MAClE,SAAS;AAAA,IACb,CAAC;AAED,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AAEtB,YAAQ,MAAM;AACd,UAAM;AAAA,MACF,MAAM,UAAU,cAAc;AAAA,MAC9B;AAAA,MACA,EAAE,SAAS,IAAK;AAAA,IACpB;AACA,WAAO,GAAG,IAAI,EAAE,GAAG,MAAM,OAAO;AAAA,EACpC,CAAC;AACL,CAAC;",
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*/\nimport {\n elementUpdated,\n expect,\n html,\n nextFrame,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\nimport type { Popover } from '@spectrum-web-components/popover';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\nimport {\n OverlayTrigger,\n TriggerInteractionsV1,\n} from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { spy } from 'sinon';\nimport { ActionButton } from '@spectrum-web-components/action-button';\nimport { fixture, isInteractive } from '../../../test/testing-helpers.js';\n\ndescribe('Overlay Trigger - Click', () => {\n it('displays `click` declaratively', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger\n placement=\"right-start\"\n open=\"click\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n\n await waitUntil(\n () => {\n return openedSpy.calledOnce;\n },\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n\n await nextFrame();\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'click content returned', {\n timeout: 2000,\n });\n });\n describe('closes on scroll', () => {\n afterEach(() => {\n if (document.scrollingElement) {\n document.scrollingElement.scrollTop = 0;\n }\n });\n (['click', 'replace', 'inline'] as TriggerInteractionsV1[]).map(\n (interaction) => {\n it(`closes \"${interaction}\" overlay on scroll`, async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger\n placement=\"right-start\"\n type=${interaction}\n >\n <sp-action-button\n slot=\"trigger\"\n style=\"margin: 50vh 0 100vh;\"\n >\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `);\n await nextFrame();\n const popover = el.querySelector('sp-popover') as Popover;\n expect(el.open).to.be.undefined;\n\n await elementUpdated(el);\n const opened = oneEvent(el, 'sp-opened');\n el.open = 'click';\n await opened;\n\n expect(el.open).to.equal('click');\n expect(await isInteractive(popover)).to.be.true;\n\n const closed = oneEvent(el, 'sp-closed');\n if (document.scrollingElement) {\n document.scrollingElement.scrollTop = 100;\n }\n await closed;\n\n expect(el.open).to.be.undefined;\n expect(await isInteractive(popover)).to.be.false;\n });\n }\n );\n });\n it('opens a second time', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger\n placement=\"right-start\"\n type=\"modal\"\n open=\"click\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `);\n await elementUpdated(el);\n const trigger = el.querySelector('[slot=trigger]') as ActionButton;\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n expect(el.open).to.equal('click');\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'click content returned', {\n timeout: 2000,\n });\n\n expect(el.open).to.be.null;\n\n trigger.click();\n await waitUntil(\n () => openedSpy.callCount === 2,\n 'click content projected to overlay, again',\n { timeout: 2000 }\n );\n expect(el.open).to.equal('click');\n });\n});\n"],
5
+ "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AACP,OAAO;AACP,OAAO;AAKP,OAAO;AACP,SAAS,WAAW;AAEpB,SAAS,SAAS,qBAAqB;AAEvC,SAAS,2BAA2B,MAAM;AACtC,KAAG,kCAAk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B,qBAAS,iBAAiB,YAAY;AAAA,UAC1C;AACA,gBAAM;AAEN,iBAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AACtB,iBAAO,MAAM,cAAc,OAAO,CAAC,EAAE,GAAG,GAAG;AAAA,QAC/C,CAAC;AAAA,MACL;AAAA,IACJ;AAAA,EACJ,CAAC;AACD,KAAG,uBAAuB,YAAY;AAClC,UAAM,YAAY,IAAI;AACtB,UAAM,YAAY,IAAI;AACtB,UAAM,KAAK,MAAM,QAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,6BAKpB,MAAM,UAAU;AAAA,6BAChB,MAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAOpC;AACD,UAAM,eAAe,EAAE;AACvB,UAAM,UAAU,GAAG,cAAc,gBAAgB;AAEjD,UAAM;AAAA,MACF,MAAM,UAAU;AAAA,MAChB;AAAA,MACA,EAAE,SAAS,IAAK;AAAA,IACpB;AACA,WAAO,GAAG,IAAI,EAAE,GAAG,MAAM,OAAO;AAEhC,OAAG,gBAAgB,MAAM;AACzB,UAAM,eAAe,EAAE;AAEvB,UAAM,UAAU,MAAM,UAAU,YAAY,0BAA0B;AAAA,MAClE,SAAS;AAAA,IACb,CAAC;AAED,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AAEtB,YAAQ,MAAM;AACd,UAAM;AAAA,MACF,MAAM,UAAU,cAAc;AAAA,MAC9B;AAAA,MACA,EAAE,SAAS,IAAK;AAAA,IACpB;AACA,WAAO,GAAG,IAAI,EAAE,GAAG,MAAM,OAAO;AAAA,EACpC,CAAC;AACL,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  import {
3
- elementUpdated,
4
3
  expect,
5
4
  fixture,
6
5
  html,
@@ -99,7 +98,7 @@ describe("Overlay Trigger - extended", () => {
99
98
  await nextFrame();
100
99
  expect(popover.placement).to.equal("bottom");
101
100
  });
102
- it("occludes content behind the overlay", async () => {
101
+ it.skip("occludes content behind the overlay", async () => {
103
102
  ({ overlayTrigger, button, popover } = await initTest());
104
103
  const textfield = document.createElement("sp-textfield");
105
104
  document.body.append(textfield);
@@ -197,10 +196,6 @@ describe("Overlay Trigger - extended", () => {
197
196
  const open = oneEvent(overlayTrigger, "sp-opened");
198
197
  button.click();
199
198
  await open;
200
- const activeOverlay = document.querySelector(
201
- "active-overlay"
202
- );
203
- await elementUpdated(activeOverlay);
204
199
  expect(overlayTrigger.open).to.equal("click");
205
200
  expect(popover.placement).to.equal("bottom");
206
201
  expect(scrollingArea.scrollTop).to.equal(distance);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-trigger-extended.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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\n\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport {\n ActiveOverlay,\n OverlayTrigger,\n} from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/button/sp-button.js';\nimport { Button } from '@spectrum-web-components/button';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport { Popover } from '@spectrum-web-components/popover';\nimport '@spectrum-web-components/textfield/sp-textfield.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\nconst initTest = async (\n styles = html``\n): Promise<{\n overlayTrigger: OverlayTrigger;\n button: Button;\n popover: Popover;\n}> => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div class=\"container\">\n <style>\n .container {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n </style>\n ${styles}\n <overlay-trigger type=\"modal\" id=\"trigger\" placement=\"top\">\n <sp-button\n id=\"outer-button\"\n variant=\"primary\"\n slot=\"trigger\"\n >\n Show Popover\n </sp-button>\n <sp-popover\n id=\"outer-popover\"\n slot=\"click-content\"\n direction=\"bottom\"\n tip\n open\n tabindex=\"0\"\n placement=\"top\"\n >\n <sp-dialog no-divider>\n This is the overlay content.\n </sp-dialog>\n </sp-popover>\n </overlay-trigger>\n </div>\n `\n );\n return {\n overlayTrigger: test.querySelector('overlay-trigger') as OverlayTrigger,\n button: test.querySelector('sp-button') as Button,\n popover: test.querySelector('sp-popover') as Popover,\n };\n};\n\ndescribe('Overlay Trigger - extended', () => {\n let overlayTrigger!: OverlayTrigger;\n let button!: Button;\n let popover!: Popover;\n\n afterEach(async () => {\n if (overlayTrigger.open) {\n const closed = oneEvent(overlayTrigger, 'sp-closed');\n overlayTrigger.open = undefined;\n await closed;\n }\n });\n\n it('manages `placement` on open', async () => {\n ({ overlayTrigger, button, popover } = await initTest());\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n\n expect(popover.placement).to.equal('bottom');\n\n const close = oneEvent(overlayTrigger, 'sp-closed');\n overlayTrigger.open = undefined;\n await close;\n\n expect(popover.placement).to.equal('top');\n });\n\n it('manages `placement` on scroll', async () => {\n ({ overlayTrigger, button, popover } = await initTest(html`\n <style>\n sp-button {\n margin: 100vh 0;\n transform: translateY(-100%);\n }\n </style>\n `));\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n\n expect(popover.placement).to.equal('top');\n\n const { scrollHeight } = document.documentElement;\n document.documentElement.scrollTop = scrollHeight / 2;\n\n // one frame for scroll to trigger\n await nextFrame();\n // one frame for the UI to update\n await nextFrame();\n // _then_ we test...\n expect(popover.placement).to.equal('bottom');\n });\n\n it('occludes content behind the overlay', async () => {\n ({ overlayTrigger, button, popover } = await initTest());\n const textfield = document.createElement('sp-textfield');\n document.body.append(textfield);\n\n const boundingRect = textfield.getBoundingClientRect();\n expect(document.activeElement).to.not.equal(textfield);\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n expect(document.activeElement).to.equal(textfield);\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n\n expect(overlayTrigger.open).to.equal('click');\n expect(popover.placement).to.equal('bottom');\n\n const close = oneEvent(overlayTrigger, 'sp-closed');\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n await close;\n expect(overlayTrigger.open).to.be.null;\n expect(document.activeElement).to.not.equal(textfield);\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n expect(document.activeElement).to.equal(textfield);\n textfield.remove();\n });\n\n xit('occludes wheel interactions behind the overlay', async () => {\n /**\n * This test \"passes\" when tested manually in browser, but\n * not when leveraged in the automated test process.\n *\n * xit for now...\n **/\n ({ overlayTrigger, button, popover } = await initTest());\n const scrollingArea = document.createElement('div');\n Object.assign(scrollingArea.style, {\n width: '100px',\n height: '100px',\n overflow: 'auto',\n });\n const content = Array(100).fill(\n 'This is content within my box that will scroll.'\n );\n scrollingArea.textContent = content.join(' ');\n document.body.append(scrollingArea);\n await nextFrame();\n\n const boundingRect = scrollingArea.getBoundingClientRect();\n expect(scrollingArea.scrollTop).to.equal(0);\n const distance = 1;\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n await sendMouse({\n steps: [\n {\n type: 'wheel',\n position: [0, distance],\n },\n ],\n });\n // wait for scroll to complete\n await waitUntil(\n () => scrollingArea.scrollTop === distance,\n `scroll went to ${distance}`\n );\n expect(scrollingArea.scrollTop).to.equal(distance);\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n const activeOverlay = document.querySelector(\n 'active-overlay'\n ) as ActiveOverlay;\n await elementUpdated(activeOverlay);\n\n expect(overlayTrigger.open).to.equal('click');\n expect(popover.placement).to.equal('bottom');\n expect(scrollingArea.scrollTop).to.equal(distance);\n await sendMouse({\n steps: [\n {\n type: 'wheel',\n position: [0, -distance],\n },\n ],\n });\n // Awaiting here points out that this always fails in Firefox\n // and also was failing in WebKit without our knowing.\n await nextFrame();\n await nextFrame();\n await nextFrame();\n expect(\n scrollingArea.scrollTop,\n `scrollTop should be ${distance}.`\n ).to.equal(distance);\n scrollingArea.remove();\n });\n});\n"],
5
- "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AAKP,OAAO;AAEP,OAAO;AAEP,OAAO;AACP,SAAS,iBAAiB;AAE1B,MAAM,WAAW,OACb,SAAS,WAKP;AACF,QAAM,OAAO,MAAM;AAAA,IACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBASU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBd;AACA,SAAO;AAAA,IACH,gBAAgB,KAAK,cAAc,iBAAiB;AAAA,IACpD,QAAQ,KAAK,cAAc,WAAW;AAAA,IACtC,SAAS,KAAK,cAAc,YAAY;AAAA,EAC5C;AACJ;AAEA,SAAS,8BAA8B,MAAM;AACzC,M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UAAU;AAAA,MACZ,OAAO;AAAA,QACH;AAAA,UACI,MAAM;AAAA,UACN,UAAU,CAAC,GAAG,CAAC,QAAQ;AAAA,QAC3B;AAAA,MACJ;AAAA,IACJ,CAAC;AAGD,UAAM,UAAU;AAChB,UAAM,UAAU;AAChB,UAAM,UAAU;AAChB;AAAA,MACI,cAAc;AAAA,MACd,uBAAuB;AAAA,IAC3B,EAAE,GAAG,MAAM,QAAQ;AACnB,kBAAc,OAAO;AAAA,EACzB,CAAC;AACL,CAAC;",
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*/\nimport {\n expect,\n fixture,\n html,\n nextFrame,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\n\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { OverlayTrigger } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/button/sp-button.js';\nimport { Button } from '@spectrum-web-components/button';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport { Popover } from '@spectrum-web-components/popover';\nimport '@spectrum-web-components/textfield/sp-textfield.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\nconst initTest = async (\n styles = html``\n): Promise<{\n overlayTrigger: OverlayTrigger;\n button: Button;\n popover: Popover;\n}> => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div class=\"container\">\n <style>\n .container {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n </style>\n ${styles}\n <overlay-trigger type=\"modal\" id=\"trigger\" placement=\"top\">\n <sp-button\n id=\"outer-button\"\n variant=\"primary\"\n slot=\"trigger\"\n >\n Show Popover\n </sp-button>\n <sp-popover\n id=\"outer-popover\"\n slot=\"click-content\"\n direction=\"bottom\"\n tip\n open\n tabindex=\"0\"\n placement=\"top\"\n >\n <sp-dialog no-divider>\n This is the overlay content.\n </sp-dialog>\n </sp-popover>\n </overlay-trigger>\n </div>\n `\n );\n return {\n overlayTrigger: test.querySelector('overlay-trigger') as OverlayTrigger,\n button: test.querySelector('sp-button') as Button,\n popover: test.querySelector('sp-popover') as Popover,\n };\n};\n\ndescribe('Overlay Trigger - extended', () => {\n let overlayTrigger!: OverlayTrigger;\n let button!: Button;\n let popover!: Popover;\n\n afterEach(async () => {\n if (overlayTrigger.open) {\n const closed = oneEvent(overlayTrigger, 'sp-closed');\n overlayTrigger.open = undefined;\n await closed;\n }\n });\n\n it('manages `placement` on open', async () => {\n ({ overlayTrigger, button, popover } = await initTest());\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n\n expect(popover.placement).to.equal('bottom');\n\n const close = oneEvent(overlayTrigger, 'sp-closed');\n overlayTrigger.open = undefined;\n await close;\n\n expect(popover.placement).to.equal('top');\n });\n\n it('manages `placement` on scroll', async () => {\n ({ overlayTrigger, button, popover } = await initTest(html`\n <style>\n sp-button {\n margin: 100vh 0;\n transform: translateY(-100%);\n }\n </style>\n `));\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n\n expect(popover.placement).to.equal('top');\n\n const { scrollHeight } = document.documentElement;\n document.documentElement.scrollTop = scrollHeight / 2;\n\n // one frame for scroll to trigger\n await nextFrame();\n // one frame for the UI to update\n await nextFrame();\n // _then_ we test...\n expect(popover.placement).to.equal('bottom');\n });\n\n it.skip('occludes content behind the overlay', async () => {\n ({ overlayTrigger, button, popover } = await initTest());\n const textfield = document.createElement('sp-textfield');\n document.body.append(textfield);\n\n const boundingRect = textfield.getBoundingClientRect();\n expect(document.activeElement).to.not.equal(textfield);\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n expect(document.activeElement).to.equal(textfield);\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n\n expect(overlayTrigger.open).to.equal('click');\n expect(popover.placement).to.equal('bottom');\n\n const close = oneEvent(overlayTrigger, 'sp-closed');\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n await close;\n expect(overlayTrigger.open).to.be.null;\n expect(document.activeElement).to.not.equal(textfield);\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n expect(document.activeElement).to.equal(textfield);\n textfield.remove();\n });\n\n xit('occludes wheel interactions behind the overlay', async () => {\n /**\n * This test \"passes\" when tested manually in browser, but\n * not when leveraged in the automated test process.\n *\n * xit for now...\n **/\n ({ overlayTrigger, button, popover } = await initTest());\n const scrollingArea = document.createElement('div');\n Object.assign(scrollingArea.style, {\n width: '100px',\n height: '100px',\n overflow: 'auto',\n });\n const content = Array(100).fill(\n 'This is content within my box that will scroll.'\n );\n scrollingArea.textContent = content.join(' ');\n document.body.append(scrollingArea);\n await nextFrame();\n\n const boundingRect = scrollingArea.getBoundingClientRect();\n expect(scrollingArea.scrollTop).to.equal(0);\n const distance = 1;\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n await sendMouse({\n steps: [\n {\n type: 'wheel',\n position: [0, distance],\n },\n ],\n });\n // wait for scroll to complete\n await waitUntil(\n () => scrollingArea.scrollTop === distance,\n `scroll went to ${distance}`\n );\n expect(scrollingArea.scrollTop).to.equal(distance);\n\n expect(popover.placement).to.equal('top');\n\n const open = oneEvent(overlayTrigger, 'sp-opened');\n button.click();\n await open;\n // const activeOverlay = document.querySelector(\n // 'active-overlay'\n // ) as HTMLDivElement;\n // await elementUpdated(activeOverlay);\n\n expect(overlayTrigger.open).to.equal('click');\n expect(popover.placement).to.equal('bottom');\n expect(scrollingArea.scrollTop).to.equal(distance);\n await sendMouse({\n steps: [\n {\n type: 'wheel',\n position: [0, -distance],\n },\n ],\n });\n // Awaiting here points out that this always fails in Firefox\n // and also was failing in WebKit without our knowing.\n await nextFrame();\n await nextFrame();\n await nextFrame();\n expect(\n scrollingArea.scrollTop,\n `scrollTop should be ${distance}.`\n ).to.equal(distance);\n scrollingArea.remove();\n });\n});\n"],
5
+ "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AAEP,OAAO;AAEP,OAAO;AAEP,OAAO;AACP,SAAS,iBAAiB;AAE1B,MAAM,WAAW,OACb,SAAS,WAKP;AACF,QAAM,OAAO,MAAM;AAAA,IACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBASU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBd;AACA,SAAO;AAAA,IACH,gBAAgB,KAAK,cAAc,iBAAiB;AAAA,IACpD,QAAQ,KAAK,cAAc,WAAW;AAAA,IACtC,SAAS,KAAK,cAAc,YAAY;AAAA,EAC5C;AACJ;AAEA,SAAS,8BAA8B,MAAM;AACzC,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,YAAU,YAAY;AAClB,QAAI,eAAe,MAAM;AACrB,YAAM,SAAS,SAAS,gBAAgB,WAAW;AACnD,qBAAe,OAAO;AACtB,YAAM;AAAA,IACV;AAA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