|
1 | 1 | import { expect } from '@esm-bundle/chai'; |
2 | | -import { fixtureSync } from '@vaadin/testing-helpers'; |
| 2 | +import { fixtureSync, nextRender, tabKeyDown } from '@vaadin/testing-helpers'; |
3 | 3 | import '@vaadin/tooltip'; |
4 | 4 | import { Button } from '@vaadin/button'; |
5 | 5 | import { Checkbox } from '@vaadin/checkbox'; |
@@ -110,3 +110,71 @@ import { mouseenter, mouseleave } from '@vaadin/tooltip/test/helpers.js'; |
110 | 110 | }); |
111 | 111 | }); |
112 | 112 | }); |
| 113 | + |
| 114 | +[ |
| 115 | + { |
| 116 | + tagName: ComboBox.is, |
| 117 | + setup: (comboBox) => { |
| 118 | + comboBox.items = [1, 2, 3]; |
| 119 | + }, |
| 120 | + open: (comboBox) => comboBox.open(), |
| 121 | + }, |
| 122 | + { |
| 123 | + tagName: DatePicker.is, |
| 124 | + open: (datePicker) => datePicker.open(), |
| 125 | + }, |
| 126 | + // DateTimePicker -> DatePicker |
| 127 | + { |
| 128 | + tagName: DateTimePicker.is, |
| 129 | + open: (dateTimePicker) => dateTimePicker.__datePicker.open(), |
| 130 | + }, |
| 131 | + // DateTimePicker -> TimePicker |
| 132 | + { |
| 133 | + tagName: DateTimePicker.is, |
| 134 | + open: (dateTimePicker) => dateTimePicker.__timePicker.open(), |
| 135 | + }, |
| 136 | + { |
| 137 | + tagName: TimePicker.is, |
| 138 | + open: (timePicker) => timePicker.open(), |
| 139 | + }, |
| 140 | + { |
| 141 | + tagName: Select.is, |
| 142 | + setup: (select) => { |
| 143 | + select.items = [ |
| 144 | + { label: '1', value: 1 }, |
| 145 | + { label: '2', value: 2 }, |
| 146 | + { label: '3', value: 3 }, |
| 147 | + ]; |
| 148 | + }, |
| 149 | + open: (select) => { |
| 150 | + select.opened = true; |
| 151 | + }, |
| 152 | + }, |
| 153 | +].forEach(({ tagName, setup, open }) => { |
| 154 | + describe(`${tagName} overlay with slotted tooltip`, () => { |
| 155 | + let element, tooltip, tooltipOverlay; |
| 156 | + |
| 157 | + beforeEach(() => { |
| 158 | + element = fixtureSync(` |
| 159 | + <${tagName}> |
| 160 | + <vaadin-tooltip slot="tooltip" text="Tooltip text"></vaadin-tooltip> |
| 161 | + </${tagName}> |
| 162 | + `); |
| 163 | + if (setup) { |
| 164 | + setup(element); |
| 165 | + } |
| 166 | + tooltip = element.querySelector('vaadin-tooltip'); |
| 167 | + tooltipOverlay = tooltip.shadowRoot.querySelector('vaadin-tooltip-overlay'); |
| 168 | + }); |
| 169 | + |
| 170 | + it(`should close tooltip when opening ${tagName} overlay`, async () => { |
| 171 | + tabKeyDown(element); |
| 172 | + element.focus(); |
| 173 | + expect(tooltipOverlay.opened).to.be.true; |
| 174 | + |
| 175 | + open(element); |
| 176 | + await nextRender(); |
| 177 | + expect(tooltipOverlay.opened).to.be.false; |
| 178 | + }); |
| 179 | + }); |
| 180 | +}); |
0 commit comments