@ukic/canary-web-components 2.0.0-canary.7 → 2.0.0-canary.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. package/dist/cjs/core.cjs.js +1 -1
  2. package/dist/cjs/helpers-93c5fc92.js +198 -0
  3. package/dist/cjs/helpers-93c5fc92.js.map +1 -0
  4. package/dist/cjs/{helpers-00b08718.js → helpers-b525d45a.js} +2 -2
  5. package/dist/cjs/helpers-b525d45a.js.map +1 -0
  6. package/dist/cjs/ic-accordion-group.cjs.entry.js +6 -2
  7. package/dist/cjs/ic-accordion-group.cjs.entry.js.map +1 -1
  8. package/dist/cjs/ic-accordion.cjs.entry.js +1 -1
  9. package/dist/cjs/ic-alert.cjs.entry.js +1 -1
  10. package/dist/cjs/ic-back-to-top.cjs.entry.js +1 -1
  11. package/dist/cjs/ic-badge.cjs.entry.js +4 -3
  12. package/dist/cjs/ic-badge.cjs.entry.js.map +1 -1
  13. package/dist/cjs/ic-breadcrumb-group.cjs.entry.js +1 -1
  14. package/dist/cjs/ic-breadcrumb.cjs.entry.js +1 -1
  15. package/dist/cjs/ic-button_3.cjs.entry.js +23 -12
  16. package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
  17. package/dist/cjs/ic-card.cjs.entry.js +5 -6
  18. package/dist/cjs/ic-card.cjs.entry.js.map +1 -1
  19. package/dist/cjs/ic-checkbox-group.cjs.entry.js +1 -1
  20. package/dist/cjs/ic-checkbox.cjs.entry.js +1 -1
  21. package/dist/cjs/ic-chip.cjs.entry.js +1 -1
  22. package/dist/cjs/ic-data-entity.cjs.entry.js +3 -6
  23. package/dist/cjs/ic-data-entity.cjs.entry.js.map +1 -1
  24. package/dist/cjs/ic-data-row.cjs.entry.js +21 -35
  25. package/dist/cjs/ic-data-row.cjs.entry.js.map +1 -1
  26. package/dist/cjs/ic-dialog.cjs.entry.js +1 -1
  27. package/dist/cjs/ic-divider.cjs.entry.js +1 -1
  28. package/dist/cjs/ic-empty-state.cjs.entry.js +1 -1
  29. package/dist/cjs/ic-footer-link-group.cjs.entry.js +1 -1
  30. package/dist/cjs/ic-footer-link.cjs.entry.js +1 -1
  31. package/dist/cjs/ic-footer.cjs.entry.js +1 -1
  32. package/dist/cjs/ic-hero.cjs.entry.js +1 -1
  33. package/dist/cjs/ic-horizontal-scroll.cjs.entry.js +1 -1
  34. package/dist/cjs/ic-input-component-container_3.cjs.entry.js +12 -10
  35. package/dist/cjs/ic-input-component-container_3.cjs.entry.js.map +1 -1
  36. package/dist/cjs/ic-input-label_2.cjs.entry.js +1 -1
  37. package/dist/cjs/ic-link.cjs.entry.js +1 -1
  38. package/dist/cjs/ic-menu-group.cjs.entry.js +1 -1
  39. package/dist/cjs/ic-menu-item.cjs.entry.js +1 -1
  40. package/dist/cjs/ic-menu-with-multi.cjs.entry.js +2599 -0
  41. package/dist/cjs/ic-menu-with-multi.cjs.entry.js.map +1 -0
  42. package/dist/cjs/ic-navigation-button.cjs.entry.js +1 -1
  43. package/dist/cjs/ic-navigation-group.cjs.entry.js +1 -1
  44. package/dist/cjs/ic-navigation-item.cjs.entry.js +1 -1
  45. package/dist/cjs/ic-navigation-menu.cjs.entry.js +1 -1
  46. package/dist/cjs/ic-page-header.cjs.entry.js +1 -1
  47. package/dist/cjs/ic-pagination-bar.cjs.entry.js +2 -18
  48. package/dist/cjs/ic-pagination-bar.cjs.entry.js.map +1 -1
  49. package/dist/cjs/ic-pagination_4.cjs.entry.js +21 -13
  50. package/dist/cjs/ic-pagination_4.cjs.entry.js.map +1 -1
  51. package/dist/cjs/ic-popover-menu.cjs.entry.js +1 -1
  52. package/dist/cjs/ic-popover-menu.cjs.entry.js.map +1 -1
  53. package/dist/cjs/ic-radio-group.cjs.entry.js +1 -1
  54. package/dist/cjs/ic-radio-option.cjs.entry.js +1 -1
  55. package/dist/cjs/ic-search-bar.cjs.entry.js +1 -1
  56. package/dist/cjs/ic-search-bar.cjs.entry.js.map +1 -1
  57. package/dist/cjs/ic-select-with-multi.cjs.entry.js +837 -0
  58. package/dist/cjs/ic-select-with-multi.cjs.entry.js.map +1 -0
  59. package/dist/cjs/ic-side-navigation.cjs.entry.js +1 -1
  60. package/dist/cjs/ic-status-tag.cjs.entry.js +1 -1
  61. package/dist/cjs/ic-step.cjs.entry.js +1 -1
  62. package/dist/cjs/ic-stepper.cjs.entry.js +1 -1
  63. package/dist/cjs/ic-switch.cjs.entry.js +1 -1
  64. package/dist/cjs/ic-tab-group.cjs.entry.js +1 -1
  65. package/dist/cjs/ic-tab-panel.cjs.entry.js +1 -1
  66. package/dist/cjs/ic-tab.cjs.entry.js +1 -1
  67. package/dist/cjs/ic-theme.cjs.entry.js +1 -1
  68. package/dist/cjs/ic-toast.cjs.entry.js +1 -1
  69. package/dist/cjs/ic-toggle-button-group.cjs.entry.js +184 -0
  70. package/dist/cjs/ic-toggle-button-group.cjs.entry.js.map +1 -0
  71. package/dist/cjs/ic-toggle-button.cjs.entry.js +6 -3
  72. package/dist/cjs/ic-toggle-button.cjs.entry.js.map +1 -1
  73. package/dist/cjs/ic-top-navigation.cjs.entry.js +1 -1
  74. package/dist/cjs/ic-typography.cjs.entry.js +1 -1
  75. package/dist/cjs/index-4cf27b16.js +12 -0
  76. package/dist/cjs/loader.cjs.js +1 -1
  77. package/dist/collection/collection-manifest.json +4 -1
  78. package/dist/collection/components/ic-menu-with-multi/ic-menu.css +701 -0
  79. package/dist/collection/components/ic-menu-with-multi/ic-menu.js +1458 -0
  80. package/dist/collection/components/ic-menu-with-multi/ic-menu.js.map +1 -0
  81. package/dist/collection/components/ic-menu-with-multi/test/basic/ic-menu.spec.js +880 -0
  82. package/dist/collection/components/ic-menu-with-multi/test/basic/ic-menu.spec.js.map +1 -0
  83. package/dist/collection/components/ic-select-with-multi/assets/Check.svg +3 -0
  84. package/dist/collection/components/ic-select-with-multi/assets/Clear.svg +3 -0
  85. package/dist/collection/components/ic-select-with-multi/assets/Expand.svg +3 -0
  86. package/dist/collection/components/ic-select-with-multi/ic-select.css +693 -0
  87. package/dist/collection/components/ic-select-with-multi/ic-select.js +1649 -0
  88. package/dist/collection/components/ic-select-with-multi/ic-select.js.map +1 -0
  89. package/dist/collection/components/ic-select-with-multi/story-data.js +216 -0
  90. package/dist/collection/components/ic-select-with-multi/story-data.js.map +1 -0
  91. package/dist/collection/components/ic-select-with-multi/test/a11y/ic-select.test.a11y.js +146 -0
  92. package/dist/collection/components/ic-select-with-multi/test/a11y/ic-select.test.a11y.js.map +1 -0
  93. package/dist/collection/components/ic-select-with-multi/test/basic/ic-select.e2e.js +2040 -0
  94. package/dist/collection/components/ic-select-with-multi/test/basic/ic-select.e2e.js.map +1 -0
  95. package/dist/collection/components/ic-select-with-multi/test/basic/ic-select.spec.js +1518 -0
  96. package/dist/collection/components/ic-select-with-multi/test/basic/ic-select.spec.js.map +1 -0
  97. package/dist/collection/utils/constants.js +28 -0
  98. package/dist/collection/utils/constants.js.map +1 -0
  99. package/dist/collection/utils/helpers.js +168 -5
  100. package/dist/collection/utils/helpers.js.map +1 -1
  101. package/dist/collection/utils/types.js +13 -0
  102. package/dist/collection/utils/types.js.map +1 -0
  103. package/dist/components/helpers.js +1 -1
  104. package/dist/components/helpers.js.map +1 -1
  105. package/dist/components/helpers2.js +183 -0
  106. package/dist/components/helpers2.js.map +1 -0
  107. package/dist/components/ic-accordion-group.js +7 -2
  108. package/dist/components/ic-accordion-group.js.map +1 -1
  109. package/dist/components/ic-badge.js +3 -2
  110. package/dist/components/ic-badge.js.map +1 -1
  111. package/dist/components/ic-button2.js +22 -11
  112. package/dist/components/ic-button2.js.map +1 -1
  113. package/dist/components/ic-card.js +5 -18
  114. package/dist/components/ic-card.js.map +1 -1
  115. package/dist/components/ic-data-entity.js +3 -6
  116. package/dist/components/ic-data-entity.js.map +1 -1
  117. package/dist/components/ic-data-row.js +20 -34
  118. package/dist/components/ic-data-row.js.map +1 -1
  119. package/dist/components/ic-input-component-container2.js +6 -5
  120. package/dist/components/ic-input-component-container2.js.map +1 -1
  121. package/dist/components/ic-menu-with-multi.d.ts +11 -0
  122. package/dist/components/ic-menu-with-multi.js +8 -0
  123. package/dist/components/ic-menu-with-multi.js.map +1 -0
  124. package/dist/components/ic-menu2.js +5 -4
  125. package/dist/components/ic-menu2.js.map +1 -1
  126. package/dist/components/ic-menu3.js +2665 -0
  127. package/dist/components/ic-menu3.js.map +1 -0
  128. package/dist/components/ic-pagination-bar2.js +1 -17
  129. package/dist/components/ic-pagination-bar2.js.map +1 -1
  130. package/dist/components/ic-popover-menu.js +1 -1
  131. package/dist/components/ic-popover-menu.js.map +1 -1
  132. package/dist/components/ic-search-bar.js.map +1 -1
  133. package/dist/components/ic-select-with-multi.d.ts +11 -0
  134. package/dist/components/ic-select-with-multi.js +962 -0
  135. package/dist/components/ic-select-with-multi.js.map +1 -0
  136. package/dist/components/ic-select2.js +22 -13
  137. package/dist/components/ic-select2.js.map +1 -1
  138. package/dist/components/ic-toggle-button-group.js +210 -0
  139. package/dist/components/ic-toggle-button-group.js.map +1 -0
  140. package/dist/components/ic-toggle-button.js +5 -2
  141. package/dist/components/ic-toggle-button.js.map +1 -1
  142. package/dist/core/core.css +8 -5
  143. package/dist/core/core.esm.js +1 -1
  144. package/dist/core/core.esm.js.map +1 -1
  145. package/dist/core/{p-9ce5f082.entry.js → p-045359e1.entry.js} +2 -2
  146. package/dist/core/{p-7276339a.entry.js → p-10fb4c46.entry.js} +2 -2
  147. package/dist/core/{p-d9342548.entry.js → p-169bfa51.entry.js} +2 -2
  148. package/dist/core/{p-5746577f.entry.js → p-1ca332ca.entry.js} +2 -2
  149. package/dist/core/{p-c345a874.entry.js → p-204ace96.entry.js} +2 -2
  150. package/dist/core/p-21150122.entry.js +2 -0
  151. package/dist/core/p-21150122.entry.js.map +1 -0
  152. package/dist/core/{p-f436630b.entry.js → p-2eac7dcc.entry.js} +2 -2
  153. package/dist/core/{p-b43bd4f3.entry.js → p-3803a5b5.entry.js} +2 -2
  154. package/dist/core/{p-24945ee5.entry.js → p-452985d9.entry.js} +2 -2
  155. package/dist/core/p-452985d9.entry.js.map +1 -0
  156. package/dist/core/{p-ca262cdc.entry.js → p-4753bac8.entry.js} +2 -2
  157. package/dist/core/{p-3d2fcf84.entry.js → p-4baa0916.entry.js} +2 -2
  158. package/dist/core/{p-79b71c18.entry.js → p-4f413fc0.entry.js} +2 -2
  159. package/dist/core/{p-051b8266.entry.js → p-595be57d.entry.js} +2 -2
  160. package/dist/core/{p-434780c8.entry.js → p-5ae93c16.entry.js} +2 -2
  161. package/dist/core/{p-ff1d23cd.entry.js → p-5e0c830b.entry.js} +2 -2
  162. package/dist/core/p-624d4f5f.entry.js +2 -0
  163. package/dist/core/p-624d4f5f.entry.js.map +1 -0
  164. package/dist/core/{p-c263542a.entry.js → p-6933f8e9.entry.js} +2 -2
  165. package/dist/core/{p-32f18701.entry.js → p-6c3044b6.entry.js} +2 -2
  166. package/dist/core/{p-da4f0a58.entry.js → p-73be1251.entry.js} +2 -2
  167. package/dist/core/{p-d49660e0.entry.js → p-75dac3d1.entry.js} +2 -2
  168. package/dist/core/{p-a3ab9f4c.entry.js → p-76915584.entry.js} +2 -2
  169. package/dist/core/p-76915584.entry.js.map +1 -0
  170. package/dist/core/{p-88971cea.entry.js → p-7ef8d616.entry.js} +2 -2
  171. package/dist/core/{p-9fd84c69.entry.js → p-81ddc39d.entry.js} +2 -2
  172. package/dist/core/{p-fbb1fba0.entry.js → p-869954a2.entry.js} +2 -2
  173. package/dist/core/{p-3c859b9e.entry.js → p-88d54b72.entry.js} +2 -2
  174. package/dist/core/{p-5e94fae8.entry.js → p-8b08d8fe.entry.js} +2 -2
  175. package/dist/core/p-8b08d8fe.entry.js.map +1 -0
  176. package/dist/core/{p-d78fd9f3.entry.js → p-917c5721.entry.js} +2 -2
  177. package/dist/core/{p-2094c844.entry.js → p-942282cd.entry.js} +2 -2
  178. package/dist/core/p-99cad6c2.js +2 -0
  179. package/dist/core/p-99cad6c2.js.map +1 -0
  180. package/dist/core/p-9caf19eb.js +2 -0
  181. package/dist/core/p-9caf19eb.js.map +1 -0
  182. package/dist/core/{p-966ab920.entry.js → p-a0f8efb2.entry.js} +2 -2
  183. package/dist/core/{p-7632acc6.entry.js → p-a31031a5.entry.js} +2 -2
  184. package/dist/core/{p-a7d52bd1.entry.js → p-a434c3d4.entry.js} +2 -2
  185. package/dist/core/{p-95d3cd52.entry.js → p-a43c12cd.entry.js} +2 -2
  186. package/dist/core/{p-aafb2c79.entry.js → p-a50c3b9e.entry.js} +2 -2
  187. package/dist/core/{p-28fb7cca.entry.js → p-ab09986c.entry.js} +2 -2
  188. package/dist/core/p-ab09986c.entry.js.map +1 -0
  189. package/dist/core/p-ac4e40a7.entry.js +2 -0
  190. package/dist/core/p-ac4e40a7.entry.js.map +1 -0
  191. package/dist/core/{p-7dfd61bb.entry.js → p-b82dcc29.entry.js} +2 -2
  192. package/dist/core/{p-337b6e05.entry.js → p-ba86928c.entry.js} +2 -2
  193. package/dist/core/{p-f827e4c0.entry.js → p-c125b65a.entry.js} +2 -2
  194. package/dist/core/{p-27aa95e7.entry.js → p-c34848da.entry.js} +2 -2
  195. package/dist/core/{p-3b9f3a07.entry.js → p-d8469ac0.entry.js} +2 -2
  196. package/dist/core/{p-a2f366c7.entry.js → p-db9c03c0.entry.js} +2 -2
  197. package/dist/core/{p-6de46cb7.entry.js → p-e0462b23.entry.js} +2 -2
  198. package/dist/core/p-e0462b23.entry.js.map +1 -0
  199. package/dist/core/p-e0a94f2d.entry.js +2 -0
  200. package/dist/core/p-e0a94f2d.entry.js.map +1 -0
  201. package/dist/core/{p-116b18fe.entry.js → p-e3997d60.entry.js} +2 -2
  202. package/dist/core/p-e79e0292.entry.js +2 -0
  203. package/dist/core/p-e79e0292.entry.js.map +1 -0
  204. package/dist/core/{p-0d181ac8.entry.js → p-e834344e.entry.js} +2 -2
  205. package/dist/core/p-f14454b1.entry.js +2 -0
  206. package/dist/core/{p-93c5b849.entry.js.map → p-f14454b1.entry.js.map} +1 -1
  207. package/dist/core/{p-a162744e.entry.js → p-f3c840cd.entry.js} +2 -2
  208. package/dist/core/{p-a162744e.entry.js.map → p-f3c840cd.entry.js.map} +1 -1
  209. package/dist/core/{p-7b849cb5.entry.js → p-f6888309.entry.js} +2 -2
  210. package/dist/core/p-f74a8752.entry.js +2 -0
  211. package/dist/core/p-f74a8752.entry.js.map +1 -0
  212. package/dist/core/{p-4df42c76.entry.js → p-f7a14c01.entry.js} +2 -2
  213. package/dist/core/{p-d5cc084b.entry.js → p-f843da01.entry.js} +2 -2
  214. package/dist/core/{p-d5cc084b.entry.js.map → p-f843da01.entry.js.map} +1 -1
  215. package/dist/core/{p-0f0509ee.entry.js → p-fc5611e2.entry.js} +2 -2
  216. package/dist/core/p-fc5611e2.entry.js.map +1 -0
  217. package/dist/core/p-fde45b29.entry.js +2 -0
  218. package/dist/core/p-fde45b29.entry.js.map +1 -0
  219. package/dist/esm/core.js +1 -1
  220. package/dist/esm/{helpers-d06dc4ed.js → helpers-12b4266a.js} +2 -2
  221. package/dist/esm/helpers-12b4266a.js.map +1 -0
  222. package/dist/esm/helpers-5271897c.js +183 -0
  223. package/dist/esm/helpers-5271897c.js.map +1 -0
  224. package/dist/esm/ic-accordion-group.entry.js +6 -2
  225. package/dist/esm/ic-accordion-group.entry.js.map +1 -1
  226. package/dist/esm/ic-accordion.entry.js +1 -1
  227. package/dist/esm/ic-alert.entry.js +1 -1
  228. package/dist/esm/ic-back-to-top.entry.js +1 -1
  229. package/dist/esm/ic-badge.entry.js +4 -3
  230. package/dist/esm/ic-badge.entry.js.map +1 -1
  231. package/dist/esm/ic-breadcrumb-group.entry.js +1 -1
  232. package/dist/esm/ic-breadcrumb.entry.js +1 -1
  233. package/dist/esm/ic-button_3.entry.js +23 -12
  234. package/dist/esm/ic-button_3.entry.js.map +1 -1
  235. package/dist/esm/ic-card.entry.js +5 -6
  236. package/dist/esm/ic-card.entry.js.map +1 -1
  237. package/dist/esm/ic-checkbox-group.entry.js +1 -1
  238. package/dist/esm/ic-checkbox.entry.js +1 -1
  239. package/dist/esm/ic-chip.entry.js +1 -1
  240. package/dist/esm/ic-data-entity.entry.js +3 -6
  241. package/dist/esm/ic-data-entity.entry.js.map +1 -1
  242. package/dist/esm/ic-data-row.entry.js +21 -35
  243. package/dist/esm/ic-data-row.entry.js.map +1 -1
  244. package/dist/esm/ic-dialog.entry.js +1 -1
  245. package/dist/esm/ic-divider.entry.js +1 -1
  246. package/dist/esm/ic-empty-state.entry.js +1 -1
  247. package/dist/esm/ic-footer-link-group.entry.js +1 -1
  248. package/dist/esm/ic-footer-link.entry.js +1 -1
  249. package/dist/esm/ic-footer.entry.js +1 -1
  250. package/dist/esm/ic-hero.entry.js +1 -1
  251. package/dist/esm/ic-horizontal-scroll.entry.js +1 -1
  252. package/dist/esm/ic-input-component-container_3.entry.js +12 -10
  253. package/dist/esm/ic-input-component-container_3.entry.js.map +1 -1
  254. package/dist/esm/ic-input-label_2.entry.js +1 -1
  255. package/dist/esm/ic-link.entry.js +1 -1
  256. package/dist/esm/ic-menu-group.entry.js +1 -1
  257. package/dist/esm/ic-menu-item.entry.js +1 -1
  258. package/dist/esm/ic-menu-with-multi.entry.js +2595 -0
  259. package/dist/esm/ic-menu-with-multi.entry.js.map +1 -0
  260. package/dist/esm/ic-navigation-button.entry.js +1 -1
  261. package/dist/esm/ic-navigation-group.entry.js +1 -1
  262. package/dist/esm/ic-navigation-item.entry.js +1 -1
  263. package/dist/esm/ic-navigation-menu.entry.js +1 -1
  264. package/dist/esm/ic-page-header.entry.js +1 -1
  265. package/dist/esm/ic-pagination-bar.entry.js +1 -17
  266. package/dist/esm/ic-pagination-bar.entry.js.map +1 -1
  267. package/dist/esm/ic-pagination_4.entry.js +21 -13
  268. package/dist/esm/ic-pagination_4.entry.js.map +1 -1
  269. package/dist/esm/ic-popover-menu.entry.js +1 -1
  270. package/dist/esm/ic-popover-menu.entry.js.map +1 -1
  271. package/dist/esm/ic-radio-group.entry.js +1 -1
  272. package/dist/esm/ic-radio-option.entry.js +1 -1
  273. package/dist/esm/ic-search-bar.entry.js +1 -1
  274. package/dist/esm/ic-search-bar.entry.js.map +1 -1
  275. package/dist/esm/ic-select-with-multi.entry.js +833 -0
  276. package/dist/esm/ic-select-with-multi.entry.js.map +1 -0
  277. package/dist/esm/ic-side-navigation.entry.js +1 -1
  278. package/dist/esm/ic-status-tag.entry.js +1 -1
  279. package/dist/esm/ic-step.entry.js +1 -1
  280. package/dist/esm/ic-stepper.entry.js +1 -1
  281. package/dist/esm/ic-switch.entry.js +1 -1
  282. package/dist/esm/ic-tab-group.entry.js +1 -1
  283. package/dist/esm/ic-tab-panel.entry.js +1 -1
  284. package/dist/esm/ic-tab.entry.js +1 -1
  285. package/dist/esm/ic-theme.entry.js +1 -1
  286. package/dist/esm/ic-toast.entry.js +1 -1
  287. package/dist/esm/ic-toggle-button-group.entry.js +180 -0
  288. package/dist/esm/ic-toggle-button-group.entry.js.map +1 -0
  289. package/dist/esm/ic-toggle-button.entry.js +6 -3
  290. package/dist/esm/ic-toggle-button.entry.js.map +1 -1
  291. package/dist/esm/ic-top-navigation.entry.js +1 -1
  292. package/dist/esm/ic-typography.entry.js +1 -1
  293. package/dist/esm/index-93509377.js +12 -0
  294. package/dist/esm/loader.js +1 -1
  295. package/dist/types/components/ic-menu-with-multi/ic-menu.d.ts +208 -0
  296. package/dist/types/components/ic-select-with-multi/ic-select.d.ts +289 -0
  297. package/dist/types/components/ic-select-with-multi/story-data.d.ts +32 -0
  298. package/dist/types/components/ic-select-with-multi/test/a11y/ic-select.test.a11y.d.ts +1 -0
  299. package/dist/types/components.d.ts +531 -0
  300. package/dist/types/utils/constants.d.ts +1 -0
  301. package/dist/types/utils/helpers.d.ts +61 -2
  302. package/dist/types/utils/types.d.ts +16 -0
  303. package/hydrate/index.js +6795 -2907
  304. package/package.json +3 -3
  305. package/dist/cjs/helpers-00b08718.js.map +0 -1
  306. package/dist/core/p-0f0509ee.entry.js.map +0 -1
  307. package/dist/core/p-24945ee5.entry.js.map +0 -1
  308. package/dist/core/p-28fb7cca.entry.js.map +0 -1
  309. package/dist/core/p-2aad58b6.js +0 -2
  310. package/dist/core/p-2aad58b6.js.map +0 -1
  311. package/dist/core/p-38314d45.entry.js +0 -2
  312. package/dist/core/p-38314d45.entry.js.map +0 -1
  313. package/dist/core/p-5e94fae8.entry.js.map +0 -1
  314. package/dist/core/p-6de46cb7.entry.js.map +0 -1
  315. package/dist/core/p-93c5b849.entry.js +0 -2
  316. package/dist/core/p-9fdd7d73.entry.js +0 -2
  317. package/dist/core/p-9fdd7d73.entry.js.map +0 -1
  318. package/dist/core/p-a3ab9f4c.entry.js.map +0 -1
  319. package/dist/core/p-c9b11488.entry.js +0 -2
  320. package/dist/core/p-c9b11488.entry.js.map +0 -1
  321. package/dist/core/p-f163a406.entry.js +0 -2
  322. package/dist/core/p-f163a406.entry.js.map +0 -1
  323. package/dist/esm/helpers-d06dc4ed.js.map +0 -1
  324. /package/dist/core/{p-9ce5f082.entry.js.map → p-045359e1.entry.js.map} +0 -0
  325. /package/dist/core/{p-7276339a.entry.js.map → p-10fb4c46.entry.js.map} +0 -0
  326. /package/dist/core/{p-d9342548.entry.js.map → p-169bfa51.entry.js.map} +0 -0
  327. /package/dist/core/{p-5746577f.entry.js.map → p-1ca332ca.entry.js.map} +0 -0
  328. /package/dist/core/{p-c345a874.entry.js.map → p-204ace96.entry.js.map} +0 -0
  329. /package/dist/core/{p-f436630b.entry.js.map → p-2eac7dcc.entry.js.map} +0 -0
  330. /package/dist/core/{p-b43bd4f3.entry.js.map → p-3803a5b5.entry.js.map} +0 -0
  331. /package/dist/core/{p-ca262cdc.entry.js.map → p-4753bac8.entry.js.map} +0 -0
  332. /package/dist/core/{p-3d2fcf84.entry.js.map → p-4baa0916.entry.js.map} +0 -0
  333. /package/dist/core/{p-79b71c18.entry.js.map → p-4f413fc0.entry.js.map} +0 -0
  334. /package/dist/core/{p-051b8266.entry.js.map → p-595be57d.entry.js.map} +0 -0
  335. /package/dist/core/{p-434780c8.entry.js.map → p-5ae93c16.entry.js.map} +0 -0
  336. /package/dist/core/{p-ff1d23cd.entry.js.map → p-5e0c830b.entry.js.map} +0 -0
  337. /package/dist/core/{p-c263542a.entry.js.map → p-6933f8e9.entry.js.map} +0 -0
  338. /package/dist/core/{p-32f18701.entry.js.map → p-6c3044b6.entry.js.map} +0 -0
  339. /package/dist/core/{p-da4f0a58.entry.js.map → p-73be1251.entry.js.map} +0 -0
  340. /package/dist/core/{p-d49660e0.entry.js.map → p-75dac3d1.entry.js.map} +0 -0
  341. /package/dist/core/{p-88971cea.entry.js.map → p-7ef8d616.entry.js.map} +0 -0
  342. /package/dist/core/{p-9fd84c69.entry.js.map → p-81ddc39d.entry.js.map} +0 -0
  343. /package/dist/core/{p-fbb1fba0.entry.js.map → p-869954a2.entry.js.map} +0 -0
  344. /package/dist/core/{p-3c859b9e.entry.js.map → p-88d54b72.entry.js.map} +0 -0
  345. /package/dist/core/{p-d78fd9f3.entry.js.map → p-917c5721.entry.js.map} +0 -0
  346. /package/dist/core/{p-2094c844.entry.js.map → p-942282cd.entry.js.map} +0 -0
  347. /package/dist/core/{p-966ab920.entry.js.map → p-a0f8efb2.entry.js.map} +0 -0
  348. /package/dist/core/{p-7632acc6.entry.js.map → p-a31031a5.entry.js.map} +0 -0
  349. /package/dist/core/{p-a7d52bd1.entry.js.map → p-a434c3d4.entry.js.map} +0 -0
  350. /package/dist/core/{p-95d3cd52.entry.js.map → p-a43c12cd.entry.js.map} +0 -0
  351. /package/dist/core/{p-aafb2c79.entry.js.map → p-a50c3b9e.entry.js.map} +0 -0
  352. /package/dist/core/{p-7dfd61bb.entry.js.map → p-b82dcc29.entry.js.map} +0 -0
  353. /package/dist/core/{p-337b6e05.entry.js.map → p-ba86928c.entry.js.map} +0 -0
  354. /package/dist/core/{p-f827e4c0.entry.js.map → p-c125b65a.entry.js.map} +0 -0
  355. /package/dist/core/{p-27aa95e7.entry.js.map → p-c34848da.entry.js.map} +0 -0
  356. /package/dist/core/{p-3b9f3a07.entry.js.map → p-d8469ac0.entry.js.map} +0 -0
  357. /package/dist/core/{p-a2f366c7.entry.js.map → p-db9c03c0.entry.js.map} +0 -0
  358. /package/dist/core/{p-116b18fe.entry.js.map → p-e3997d60.entry.js.map} +0 -0
  359. /package/dist/core/{p-0d181ac8.entry.js.map → p-e834344e.entry.js.map} +0 -0
  360. /package/dist/core/{p-7b849cb5.entry.js.map → p-f6888309.entry.js.map} +0 -0
  361. /package/dist/core/{p-4df42c76.entry.js.map → p-f7a14c01.entry.js.map} +0 -0
@@ -0,0 +1,2040 @@
1
+ import { newE2EPage } from "@stencil/core/testing";
2
+ beforeAll(() => {
3
+ jest.spyOn(console, "warn").mockImplementation(jest.fn());
4
+ });
5
+ const options = `[
6
+ { label: 'Test label 1', value: 'Test value 1' },
7
+ { label: 'Test label 2', value: 'Test value 2' },
8
+ { label: 'Test label 3', value: 'Test value 3' },
9
+ ]`;
10
+ const optionsWithDuplicate = `[
11
+ { label: 'Test label 1', value: 'Test value 1' },
12
+ { label: 'Test label 2', value: 'Test value 2' },
13
+ { label: 'Test label 3', value: 'Test value 3' },
14
+ { label: 'Parent',
15
+ children: [
16
+ { label: 'Test label 1', value: 'Test value 1' },
17
+ { label: 'Test label 2', value: 'Test value 2' },
18
+ { label: 'Test label 4', value: 'Test value 4' },
19
+ ]
20
+ },
21
+ { label: 'Test label 3', value: 'Test value 3' },
22
+ { label: 'Test label 3 diff label', value: 'Test value 3' },
23
+ ]`;
24
+ const largeOptions = `[
25
+ { label: 'Test label 1', value: 'Test value 1' },
26
+ { label: 'Test label 2', value: 'Test value 2' },
27
+ { label: 'Test label 3', value: 'Test value 3' },
28
+ { label: 'Test label 4', value: 'Test value 4' },
29
+ { label: 'Test label 5', value: 'Test value 5' },
30
+ { label: 'Test label 6', value: 'Test value 6' },
31
+ { label: 'Test label 7', value: 'Test value 7' },
32
+ { label: 'Test label 8', value: 'Test value 8' },
33
+ { label: 'Test label 9', value: 'Test value 9' },
34
+ { label: 'Test label 10', value: 'Test value 10' },
35
+ ]`;
36
+ const searchableOptions = `[
37
+ { label: "Cappuccino", value: "Cap" },
38
+ { label: "Latte", value: "Lat" },
39
+ { label: "Americano", value: "Ame" },
40
+ { label: "Filter", value: "Fil" },
41
+ { label: "Flat white", value: "Fla" },
42
+ { label: "Mocha", value: "Moc" },
43
+ { label: "Macchiato", value: "Mac" },
44
+ ]`;
45
+ const optionsWithDisabled = `[
46
+ { label: 'Test label 1', value: 'Test value 1', disabled: true },
47
+ { label: 'Test label 2', value: 'Test value 2' },
48
+ { label: 'Test label 3', value: 'Test value 3', disabled: true },
49
+ { label: 'Test label 4', value: 'Test value 4', disabled: true },
50
+ { label: 'Test label 5', value: 'Test value 5' },
51
+ ]`;
52
+ const optionsWithGroups = `[
53
+ { label: 'Test label 1', value: 'Test value 1' },
54
+ { label: 'Test label 2', value: 'Test value 2' },
55
+ { label: 'Group', children: [
56
+ { label: 'Test label 3', value: 'Test value 3' },
57
+ ] },
58
+ ]`;
59
+ const getTestSelect = (options) => `<ic-select-with-multi label="IC Select Test"></ic-select-with-multi>
60
+ <script>
61
+ var select = document.querySelector('ic-select-with-multi');
62
+ select.options = ${options};
63
+ select.addEventListener('icChange', function (event) {
64
+ option = event.detail.value;
65
+ select.value = option;
66
+ });
67
+ </script>`;
68
+ const getTestSelectFormReset = (options) => `<form><ic-select-with-multi label="IC Select Test"></ic-select-with-multi><button type="reset" id="resetButton">Reset</button></form>
69
+ <script>
70
+ var select = document.querySelector('ic-select-with-multi');
71
+ select.options = ${options};
72
+ select.addEventListener('icChange', function (event) {
73
+ option = event.detail.value;
74
+ select.value = option;
75
+ });
76
+ </script>`;
77
+ const getTestSelectSearchableFormReset = (options) => `<form><ic-select-with-multi label="IC Select Test" searchable></ic-select-with-multi><button type="reset" id="resetButton">Reset</button></form>
78
+ <script>
79
+ var select = document.querySelector('ic-select-with-multi');
80
+ select.options = ${options};
81
+ select.value = 'Test value 1';
82
+ select.addEventListener('icChange', function (event) {
83
+ option = event.detail.value;
84
+ select.value = option;
85
+ });
86
+ </script>`;
87
+ const getTestSearchableSelect = (options) => `<ic-select-with-multi label="IC Select Test" searchable></ic-select-with-multi><button>Button</button>
88
+ <script>
89
+ var select = document.querySelector('ic-select-with-multi');
90
+ select.options = ${options};
91
+ </script>`;
92
+ const getTestSearchableSelectAsync = () => `<ic-select-with-multi label="IC Select Test" searchable disable-filter="true" value="Test value"></ic-select-with-multi>
93
+ <script>
94
+ var select = document.querySelector('ic-select-with-multi');
95
+ select.options = [];
96
+ window.setTimeout(() => {
97
+ select.options = []
98
+ }, 800)
99
+ </script>`;
100
+ const getTestSelectAsync = (firstDataset, secondDataset) => `<ic-select-with-multi label="IC Select Test" value="Test value"></ic-select-with-multi>
101
+ <script>
102
+ var select = document.querySelector('ic-select-with-multi');
103
+ select.options = ${firstDataset};
104
+ window.setTimeout(() => {
105
+ select.options = ${secondDataset}
106
+ }, 1500)
107
+ </script>`;
108
+ const getTestMultiSelect = (options) => `<ic-select-with-multi label="IC Select Test" multiple="true"></ic-select-with-multi>
109
+ <script>
110
+ var select = document.querySelector('ic-select-with-multi');
111
+ select.options = ${options};
112
+ select.addEventListener('icChange', function (event) {
113
+ option = event.detail.value;
114
+ select.value = option;
115
+ });
116
+ </script>`;
117
+ const getMenuVisibility = async (page) => {
118
+ return await page.evaluate(() => {
119
+ const menu = document
120
+ .querySelector("ic-select-with-multi")
121
+ .shadowRoot.querySelector("ic-menu-with-multi #ic-select-input-0-menu");
122
+ return window.getComputedStyle(menu).visibility;
123
+ });
124
+ };
125
+ const focusAndTypeIntoInput = async (value, page) => {
126
+ await page.$eval("ic-select-with-multi", (el) => {
127
+ const input = el.shadowRoot.querySelector("input");
128
+ input.focus();
129
+ });
130
+ value.split("").forEach(async (char) => {
131
+ await page.keyboard.press(char);
132
+ });
133
+ };
134
+ describe("ic-select-with-multi", () => {
135
+ describe("custom", () => {
136
+ it("should render", async () => {
137
+ const page = await newE2EPage();
138
+ await page.setContent(getTestSelect(options));
139
+ await page.waitForChanges();
140
+ const select = await page.find("ic-select-with-multi");
141
+ expect(select).not.toBeNull();
142
+ });
143
+ it("should render when no options are provided", async () => {
144
+ const page = await newE2EPage();
145
+ await page.setContent(`<ic-select-with-multi label="IC Select Test"></ic-select-with-multi>`);
146
+ await page.waitForChanges();
147
+ const select = await page.find("ic-select-with-multi");
148
+ expect(select).not.toBeNull();
149
+ });
150
+ it("should open, set focus on menu and set aria-expanded to 'true' when input clicked", async () => {
151
+ const page = await newE2EPage();
152
+ await page.setContent(getTestSelect(options));
153
+ await page.waitForChanges();
154
+ expect(await getMenuVisibility(page)).toBe("hidden");
155
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
156
+ await select.click();
157
+ await page.waitForChanges();
158
+ expect(await getMenuVisibility(page)).toBe("visible");
159
+ expect(select.getAttribute("aria-expanded")).toBeTruthy();
160
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
161
+ expect(activeElId).toBe("ic-select-input-0-menu");
162
+ });
163
+ it("should render options correctly", async () => {
164
+ const page = await newE2EPage();
165
+ await page.setContent(getTestSelect(options));
166
+ await page.waitForChanges();
167
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
168
+ await select.click();
169
+ await page.waitForChanges();
170
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
171
+ const menuOptions = await menu.findAll("li");
172
+ expect(menuOptions).toHaveLength(3);
173
+ expect(menuOptions[0]).toEqualText("Test label 1");
174
+ expect(menuOptions[1]).toEqualText("Test label 2");
175
+ expect(menuOptions[2]).toEqualText("Test label 3");
176
+ });
177
+ it("should deduplicate options and warn about duplicate", async () => {
178
+ const page = await newE2EPage();
179
+ await page.setContent(getTestSelect(optionsWithDuplicate));
180
+ await page.waitForChanges();
181
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
182
+ await select.click();
183
+ await page.waitForChanges();
184
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
185
+ const menuOptions = await menu.findAll("li");
186
+ expect(menuOptions).toHaveLength(4);
187
+ expect(menuOptions[0]).toEqualText("Test label 1");
188
+ expect(menuOptions[1]).toEqualText("Test label 2");
189
+ expect(menuOptions[2]).toEqualText("Test label 3");
190
+ expect(menuOptions[3]).toEqualText("Test label 4");
191
+ // We can't test for ic-warn being called because it's already called seven times over 'hiddeninputvalue' changing
192
+ });
193
+ it("should call icChange when the selected option is changed", async () => {
194
+ const page = await newE2EPage();
195
+ await page.setContent(getTestSelect(options));
196
+ await page.waitForChanges();
197
+ const icChange = await page.spyOnEvent("icChange");
198
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
199
+ await select.press("ArrowDown");
200
+ await select.press("Enter");
201
+ await page.waitForChanges();
202
+ expect(icChange).toHaveReceivedEventDetail({
203
+ value: "Test value 1",
204
+ });
205
+ });
206
+ describe("when no option is selected", () => {
207
+ it("should open menu, apply focus style on first option and set as value when Down Arrow is pressed", async () => {
208
+ const page = await newE2EPage();
209
+ await page.setContent(getTestSelect(options));
210
+ await page.waitForChanges();
211
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
212
+ await select.press("ArrowDown");
213
+ await page.waitForChanges();
214
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
215
+ expect(await getMenuVisibility(page)).toBe("visible");
216
+ const firstOption = await menu.findAll("li");
217
+ expect(firstOption[0]).toHaveClass("focused-option");
218
+ expect(select).toEqualText("Test label 1");
219
+ });
220
+ it("should open menu when Space is pressed", async () => {
221
+ const page = await newE2EPage();
222
+ await page.setContent(getTestSelect(options));
223
+ await page.waitForChanges();
224
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
225
+ await select.press(" ");
226
+ await page.waitForChanges();
227
+ expect(await getMenuVisibility(page)).toBe("visible");
228
+ });
229
+ it("should open menu when Enter is pressed", async () => {
230
+ const page = await newE2EPage();
231
+ await page.setContent(getTestSelect(options));
232
+ await page.waitForChanges();
233
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
234
+ await select.press("Enter");
235
+ await page.waitForChanges();
236
+ await page.waitForTimeout(1000);
237
+ expect(await getMenuVisibility(page)).toBe("visible");
238
+ });
239
+ it("should open menu, apply focus style on last option and set as value when Up Arrow is pressed", async () => {
240
+ const page = await newE2EPage();
241
+ await page.setContent(getTestSelect(options));
242
+ await page.waitForChanges();
243
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
244
+ await select.press("ArrowUp");
245
+ await page.waitForChanges();
246
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
247
+ expect(await getMenuVisibility(page)).toBe("visible");
248
+ const lastOption = await menu.findAll("li");
249
+ expect(lastOption[2]).toHaveClass("focused-option");
250
+ expect(select).toEqualText("Test label 3");
251
+ });
252
+ it("should keep menu closed when Backspace, Home, End and Escape are pressed", async () => {
253
+ const page = await newE2EPage();
254
+ await page.setContent(getTestSelect(options));
255
+ await page.waitForChanges();
256
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
257
+ await select.press("Backspace");
258
+ await page.waitForChanges();
259
+ expect(await getMenuVisibility(page)).toBe("hidden");
260
+ await select.press("Home");
261
+ await page.waitForChanges();
262
+ expect(await getMenuVisibility(page)).toBe("hidden");
263
+ await select.press("End");
264
+ await page.waitForChanges();
265
+ expect(await getMenuVisibility(page)).toBe("hidden");
266
+ await select.press("Escape");
267
+ await page.waitForChanges();
268
+ expect(await getMenuVisibility(page)).toBe("hidden");
269
+ });
270
+ });
271
+ describe("when an option is selected", () => {
272
+ it("should move focus to next option and set as value when Down Arrow is pressed", async () => {
273
+ const page = await newE2EPage();
274
+ await page.setContent(getTestSelect(options));
275
+ await page.waitForChanges();
276
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
277
+ await select.press("ArrowDown");
278
+ await select.press("ArrowDown");
279
+ await page.waitForChanges();
280
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
281
+ const secondOption = await menu.findAll("li");
282
+ expect(secondOption[1]).toHaveClass("focused-option");
283
+ expect(select).toEqualText("Test label 2");
284
+ });
285
+ it("should move focus to first option and set as value when focus is on last option and Down Arrow is pressed", async () => {
286
+ const page = await newE2EPage();
287
+ await page.setContent(getTestSelect(options));
288
+ await page.waitForChanges();
289
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
290
+ await select.press("ArrowUp");
291
+ await select.press("ArrowDown");
292
+ await page.waitForChanges();
293
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
294
+ const firstOption = await menu.findAll("li");
295
+ expect(firstOption[0]).toHaveClass("focused-option");
296
+ expect(select).toEqualText("Test label 1");
297
+ });
298
+ it("should move focus to previous option and set as value when Up Arrow is pressed", async () => {
299
+ const page = await newE2EPage();
300
+ await page.setContent(getTestSelect(options));
301
+ await page.waitForChanges();
302
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
303
+ await select.press("ArrowUp");
304
+ await select.press("ArrowUp");
305
+ await page.waitForChanges();
306
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
307
+ const secondOption = await menu.findAll("li");
308
+ expect(secondOption[1]).toHaveClass("focused-option");
309
+ expect(select).toEqualText("Test label 2");
310
+ });
311
+ it("should move focus to last option and set as value when focus is on first option and Up Arrow is pressed", async () => {
312
+ const page = await newE2EPage();
313
+ await page.setContent(getTestSelect(options));
314
+ await page.waitForChanges();
315
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
316
+ await select.press("ArrowDown");
317
+ await select.press("ArrowUp");
318
+ await page.waitForChanges();
319
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
320
+ const lastOption = await menu.findAll("li");
321
+ expect(lastOption[2]).toHaveClass("focused-option");
322
+ expect(select).toEqualText("Test label 3");
323
+ });
324
+ it("should move focus to first option and set as value when Home is pressed", async () => {
325
+ const page = await newE2EPage();
326
+ await page.setContent(getTestSelect(options));
327
+ await page.waitForChanges();
328
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
329
+ await select.press("ArrowUp");
330
+ await page.keyboard.press("Home");
331
+ await page.waitForChanges();
332
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
333
+ const firstOption = await menu.findAll("li");
334
+ expect(firstOption[0]).toHaveClass("focused-option");
335
+ expect(select).toEqualText("Test label 1");
336
+ });
337
+ it("should move focus to last option and set as value when End is pressed", async () => {
338
+ const page = await newE2EPage();
339
+ await page.setContent(getTestSelect(options));
340
+ await page.waitForChanges();
341
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
342
+ await select.press("ArrowDown");
343
+ await page.keyboard.press("End");
344
+ await page.waitForChanges();
345
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
346
+ const lastOption = await menu.findAll("li");
347
+ expect(lastOption[2]).toHaveClass("focused-option");
348
+ expect(select).toEqualText("Test label 3");
349
+ });
350
+ it("should display a check next to the selected option and set aria-selected", async () => {
351
+ const page = await newE2EPage();
352
+ await page.setContent(getTestSelect(options));
353
+ await page.waitForChanges();
354
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
355
+ await select.press("ArrowDown");
356
+ await page.waitForChanges();
357
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
358
+ const firstOption = await menu.findAll("li");
359
+ expect(firstOption[0].getAttribute("aria-selected")).toBeTruthy;
360
+ expect(await firstOption[0].find(".check-icon")).not.toBeNull;
361
+ expect(firstOption[1].getAttribute("aria-selected")).toBeFalsy;
362
+ expect(await firstOption[1].find(".check-icon")).toBeNull;
363
+ });
364
+ it("should display a check next to the selected option and set aria-selected when a default value is applied", async () => {
365
+ const page = await newE2EPage();
366
+ await page.setContent(getTestSelect(options));
367
+ await page.waitForChanges();
368
+ const icSelect = await page.find("ic-select-with-multi");
369
+ icSelect.setAttribute("value", "Test value 1");
370
+ await page.waitForChanges();
371
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
372
+ const firstOption = await menu.findAll("li");
373
+ expect(firstOption[0]).toHaveAttribute("aria-selected");
374
+ expect(await firstOption[0].find(".check-icon")).not.toBeNull;
375
+ });
376
+ it("should display clear button if the 'show-clear-button' prop is supplied and an option is selected", async () => {
377
+ const page = await newE2EPage();
378
+ await page.setContent(getTestSelect(options));
379
+ let clearButton = await page.find("ic-select-with-multi >>> .clear-button");
380
+ expect(clearButton).toBeNull();
381
+ const icSelect = await page.find("ic-select-with-multi");
382
+ icSelect.setAttribute("show-clear-button", true);
383
+ await page.waitForChanges();
384
+ clearButton = await page.find("ic-select-with-multi >>> .clear-button");
385
+ expect(clearButton).toBeNull();
386
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
387
+ await select.press("ArrowDown");
388
+ await page.keyboard.press("Enter");
389
+ await page.waitForChanges();
390
+ clearButton = await page.find("ic-select-with-multi >>> .clear-button");
391
+ expect(clearButton).not.toBeNull();
392
+ });
393
+ it("should clear the input if the clear button is clicked", async () => {
394
+ const page = await newE2EPage();
395
+ await page.setContent(getTestSelect(options));
396
+ const icSelect = await page.find("ic-select-with-multi");
397
+ icSelect.setAttribute("show-clear-button", true);
398
+ await page.waitForChanges();
399
+ const icChange = await page.spyOnEvent("icChange");
400
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
401
+ await select.press("ArrowDown");
402
+ await page.keyboard.press("Enter");
403
+ await page.waitForChanges();
404
+ let clearButton = await page.find("ic-select-with-multi >>> .clear-button");
405
+ await clearButton.click();
406
+ await page.waitForChanges();
407
+ expect(select).toEqualText("Select an option");
408
+ expect(icChange).toHaveReceivedEventDetail({
409
+ value: null,
410
+ });
411
+ clearButton = await page.find("ic-select-with-multi >>> .clear-button");
412
+ expect(clearButton).toBe(null);
413
+ });
414
+ });
415
+ it("should close menu when input is clicked while open and set focus on it", async () => {
416
+ const page = await newE2EPage();
417
+ await page.setContent(getTestSelect(options));
418
+ await page.waitForChanges();
419
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
420
+ await select.click();
421
+ await page.waitForChanges();
422
+ await select.click();
423
+ await page.waitForChanges();
424
+ await page.waitForTimeout(1000);
425
+ expect(await getMenuVisibility(page)).toBe("hidden");
426
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
427
+ expect(activeElId).toBe("ic-select-input-0");
428
+ });
429
+ it("should close menu when an option is clicked, set as value and move focus onto the input", async () => {
430
+ const page = await newE2EPage();
431
+ await page.setContent(getTestSelect(options));
432
+ await page.waitForChanges();
433
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
434
+ await select.click();
435
+ await page.waitForChanges();
436
+ const icChange = await page.spyOnEvent("icChange");
437
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
438
+ await menu.click();
439
+ await page.waitForChanges();
440
+ await page.waitForTimeout(1000);
441
+ expect(await getMenuVisibility(page)).toBe("hidden");
442
+ expect(icChange).toHaveReceivedEventDetail({
443
+ value: "Test value 2",
444
+ });
445
+ expect(select).toEqualText("Test label 2");
446
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
447
+ expect(activeElId).toBe("ic-select-input-0");
448
+ });
449
+ it("should close menu when Space is pressed and move focus to the input", async () => {
450
+ const page = await newE2EPage();
451
+ await page.setContent(getTestSelect(options));
452
+ await page.waitForChanges();
453
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
454
+ await select.press("ArrowDown");
455
+ await page.waitForChanges();
456
+ await page.keyboard.press(" ");
457
+ await page.waitForChanges();
458
+ await page.waitForTimeout(1000);
459
+ expect(await getMenuVisibility(page)).toBe("hidden");
460
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
461
+ expect(activeElId).toBe("ic-select-input-0");
462
+ });
463
+ it("should close menu when Enter is pressed and set focus to the input", async () => {
464
+ const page = await newE2EPage();
465
+ await page.setContent(getTestSelect(options));
466
+ await page.waitForChanges();
467
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
468
+ await select.press("ArrowDown");
469
+ await page.waitForChanges();
470
+ await page.keyboard.press("Enter");
471
+ await page.waitForChanges();
472
+ await page.waitForTimeout(1000);
473
+ expect(await getMenuVisibility(page)).toBe("hidden");
474
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
475
+ expect(activeElId).toBe("ic-select-input-0");
476
+ });
477
+ it("should close menu when Escape is pressed and set focus to the input", async () => {
478
+ const page = await newE2EPage();
479
+ await page.setContent(getTestSelect(options));
480
+ await page.waitForChanges();
481
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
482
+ await select.press("ArrowDown");
483
+ await page.waitForChanges();
484
+ await page.keyboard.press("Escape");
485
+ await page.waitForChanges();
486
+ await page.waitForTimeout(1000);
487
+ expect(await getMenuVisibility(page)).toBe("hidden");
488
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
489
+ expect(activeElId).toBe("ic-select-input-0");
490
+ });
491
+ it("should close menu when another element on the page is clicked", async () => {
492
+ const page = await newE2EPage();
493
+ await page.setContent(`${getTestSelect(options)}<button>Test button</button>`);
494
+ await page.waitForChanges();
495
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
496
+ await select.press("ArrowDown");
497
+ await page.waitForChanges();
498
+ const button = await page.find("button");
499
+ await button.click();
500
+ await page.waitForChanges();
501
+ await page.waitForTimeout(1000);
502
+ expect(await getMenuVisibility(page)).toBe("hidden");
503
+ });
504
+ it("should close menu when Tab is pressed to move focus onto the next element on the page", async () => {
505
+ const page = await newE2EPage();
506
+ await page.setContent(`${getTestSelect(options)}<button>Test button</button>`);
507
+ await page.waitForChanges();
508
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
509
+ await select.press("ArrowDown");
510
+ await page.waitForChanges();
511
+ await page.keyboard.press("Tab");
512
+ await page.waitForChanges();
513
+ await page.waitForTimeout(1000);
514
+ expect(await getMenuVisibility(page)).toBe("hidden");
515
+ });
516
+ it("should close menu when Shift + Tab is pressed to move focus onto the input", async () => {
517
+ const page = await newE2EPage();
518
+ await page.setContent(`${getTestSelect(options)}`);
519
+ await page.waitForChanges();
520
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
521
+ await select.press("ArrowDown");
522
+ await page.waitForChanges();
523
+ await page.waitForTimeout(1000);
524
+ await page.keyboard.down("Shift");
525
+ await page.keyboard.press("Tab");
526
+ await page.waitForChanges();
527
+ await page.keyboard.up("Shift");
528
+ await page.waitForChanges();
529
+ await page.waitForTimeout(1000);
530
+ expect(await getMenuVisibility(page)).toBe("hidden");
531
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
532
+ expect(activeElId).toBe("ic-select-input-0");
533
+ });
534
+ it("should display the label of the value passed in using the 'value' prop as the selected option", async () => {
535
+ const page = await newE2EPage();
536
+ await page.setContent(getTestSelect(options));
537
+ const icSelect = await page.find("ic-select-with-multi");
538
+ icSelect.setAttribute("value", "Test value 2");
539
+ await page.waitForChanges();
540
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
541
+ expect(select).toEqualText("Test label 2");
542
+ });
543
+ it("should render options with descriptions", async () => {
544
+ const page = await newE2EPage();
545
+ const optionsWithDescription = `[
546
+ { label: 'Test label 1', value: 'Test value 1', description: 'Test description 1' },
547
+ { label: 'Test label 2', value: 'Test value 2' },
548
+ { label: 'Test label 3', value: 'Test value 3' },
549
+ ]`;
550
+ await page.setContent(getTestSelect(optionsWithDescription));
551
+ await page.waitForChanges();
552
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
553
+ await select.press("ArrowDown");
554
+ await page.waitForChanges();
555
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
556
+ const firstOptionDescription = await menu.find("li .option-description");
557
+ expect(firstOptionDescription).toEqualText("Test description 1");
558
+ });
559
+ it("should render the placeholder", async () => {
560
+ const page = await newE2EPage();
561
+ await page.setContent(getTestSelect(options));
562
+ const icSelect = await page.find("ic-select-with-multi");
563
+ icSelect.setAttribute("placeholder", "Test placeholder");
564
+ await page.waitForChanges();
565
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
566
+ expect(select).toEqualText("Test placeholder");
567
+ });
568
+ it("should render as disabled correctly", async () => {
569
+ const page = await newE2EPage();
570
+ await page.setContent(getTestSelect(options));
571
+ const icSelect = await page.find("ic-select-with-multi");
572
+ icSelect.setAttribute("disabled", true);
573
+ await page.waitForChanges();
574
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
575
+ expect(select).toHaveAttribute("disabled");
576
+ await select.click();
577
+ await page.waitForChanges();
578
+ expect(await getMenuVisibility(page)).toBe("hidden");
579
+ });
580
+ it("should prevent click on disabled options", async () => {
581
+ const page = await newE2EPage();
582
+ await page.setContent(getTestSelect(optionsWithDisabled));
583
+ await page.waitForChanges();
584
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
585
+ await select.press("ArrowDown");
586
+ await page.waitForChanges();
587
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
588
+ await menu.click();
589
+ await page.waitForChanges();
590
+ expect(await getMenuVisibility(page)).toBe("visible");
591
+ });
592
+ it("should set aria-disabled and skip focus when option disabled", async () => {
593
+ const page = await newE2EPage();
594
+ const optionsWithFirstDisabled = `[
595
+ { label: 'Test label 1', value: 'Test value 1', disabled: true },
596
+ { label: 'Test label 2', value: 'Test value 2' },
597
+ { label: 'Test label 3', value: 'Test value 3' },
598
+ ]`;
599
+ await page.setContent(getTestSelect(optionsWithFirstDisabled));
600
+ await page.waitForChanges();
601
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
602
+ await select.press("ArrowDown");
603
+ await page.waitForChanges();
604
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
605
+ const menuOptions = await menu.findAll("li");
606
+ expect(menuOptions[0]).toHaveAttribute("aria-disabled");
607
+ expect(menuOptions[1]).toHaveClass("focused-option");
608
+ });
609
+ it("should render as required correctly", async () => {
610
+ const page = await newE2EPage();
611
+ await page.setContent(getTestSelect(options));
612
+ const icSelect = await page.find("ic-select-with-multi");
613
+ icSelect.setAttribute("required", true);
614
+ await page.waitForChanges();
615
+ const label = await page.find("ic-select-with-multi >>> ic-input-label");
616
+ expect(label).toEqualText("IC Select Test *");
617
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
618
+ expect(select.getAttribute("aria-label").includes("required")).toBeTruthy();
619
+ });
620
+ it("should render selected value as text when read-only", async () => {
621
+ const page = await newE2EPage();
622
+ await page.setContent(getTestSelect(options));
623
+ const icSelect = await page.find("ic-select-with-multi");
624
+ icSelect.setAttribute("value", "Test value 1");
625
+ icSelect.setAttribute("readonly", true);
626
+ await page.waitForChanges();
627
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
628
+ const typography = await page.evaluate(() => Array.from(document
629
+ .querySelector("ic-select-with-multi")
630
+ .shadowRoot.querySelectorAll("ic-typography"), (typography) => typography.innerText));
631
+ expect(select).toBe(null);
632
+ expect(typography[1]).toBe("Test label 1");
633
+ });
634
+ it("should render options as groups if they have children", async () => {
635
+ const page = await newE2EPage();
636
+ const groupedOptions = `[
637
+ {
638
+ label: 'Test group',
639
+ children: [
640
+ { label: 'Test label 1', value: 'Test value 1' },
641
+ { label: 'Test label 2', value: 'Test value 2' },
642
+ { label: 'Test label 3', value: 'Test value 3' },
643
+ ],
644
+ },
645
+ ]`;
646
+ await page.setContent(getTestSelect(groupedOptions));
647
+ await page.waitForChanges();
648
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
649
+ await select.press("ArrowDown");
650
+ await page.waitForChanges();
651
+ const optionGroupTitle = await page.find("ic-select-with-multi >>> ic-menu-with-multi >>> .option-group-title");
652
+ expect(optionGroupTitle).not.toBeNull();
653
+ const optionsText = await page.evaluate(() => Array.from(document
654
+ .querySelector("ic-select-with-multi")
655
+ .shadowRoot.querySelectorAll("ic-menu-with-multi ic-typography"), (typography) => typography.innerText));
656
+ expect(optionsText[0]).toBe("Test group");
657
+ });
658
+ it("should render and focus child options correctly", async () => {
659
+ const page = await newE2EPage();
660
+ const groupedOptions = `[
661
+ {
662
+ label: 'Test group',
663
+ children: [
664
+ { label: 'Test label 1', value: 'Test value 1' },
665
+ { label: 'Test label 2', value: 'Test value 2' },
666
+ { label: 'Test label 3', value: 'Test value 3' },
667
+ ],
668
+ },
669
+ ]`;
670
+ await page.setContent(getTestSelect(groupedOptions));
671
+ await page.waitForChanges();
672
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
673
+ await select.press("ArrowDown");
674
+ await page.waitForChanges();
675
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
676
+ const childOptions = await menu.findAll("li");
677
+ expect(childOptions).toHaveLength(3);
678
+ expect(childOptions[0]).toEqualText("Test label 1");
679
+ expect(childOptions[1]).toEqualText("Test label 2");
680
+ expect(childOptions[2]).toEqualText("Test label 3");
681
+ expect(childOptions[0]).toHaveClass("focused-option");
682
+ });
683
+ it("should render options at the top of the menu if they are recommended", async () => {
684
+ const page = await newE2EPage();
685
+ const optionsWithRecommended = `[
686
+ { label: 'Test label 1', value: 'Test value 1' },
687
+ { label: 'Test label 2', value: 'Test value 2', recommended: true },
688
+ { label: 'Test label 3', value: 'Test value 3' },
689
+ ]`;
690
+ await page.setContent(getTestSelect(optionsWithRecommended));
691
+ await page.waitForChanges();
692
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
693
+ await select.press("ArrowDown");
694
+ await page.waitForChanges();
695
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
696
+ const firstOption = await menu.findAll("li");
697
+ expect(firstOption[0]).toEqualText("Test label 2");
698
+ });
699
+ it("should set aria-invalid if validation status is 'error'", async () => {
700
+ const page = await newE2EPage();
701
+ await page.setContent(getTestSelect(options));
702
+ const icSelect = await page.find("ic-select-with-multi");
703
+ icSelect.setAttribute("validation-status", "error");
704
+ await page.waitForChanges();
705
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
706
+ expect(select).toHaveAttribute("aria-invalid");
707
+ });
708
+ it("should set the aria-label correctly if an option has a description", async () => {
709
+ const page = await newE2EPage();
710
+ const optionsWithDescription = `[
711
+ { label: 'Test label 1', value: 'Test value 1', description: 'Test description 1' },
712
+ { label: 'Test label 2', value: 'Test value 2' },
713
+ { label: 'Test label 3', value: 'Test value 3' },
714
+ ]`;
715
+ await page.setContent(getTestSelect(optionsWithDescription));
716
+ await page.waitForChanges();
717
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
718
+ await select.press("ArrowDown");
719
+ await page.waitForChanges();
720
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
721
+ const firstOption = await menu.findAll("li");
722
+ expect(firstOption[0].getAttribute("aria-label")).toBe("Test label 1, Test description 1");
723
+ });
724
+ it("should set the aria-label correctly if an option is within a group", async () => {
725
+ const page = await newE2EPage();
726
+ const optionsWithDescription = `[
727
+ {
728
+ label: 'Test group',
729
+ children: [
730
+ { label: 'Test label 1', value: 'Test value 1' },
731
+ { label: 'Test label 2', value: 'Test value 2' },
732
+ { label: 'Test label 3', value: 'Test value 3' },
733
+ ],
734
+ },
735
+ ]`;
736
+ await page.setContent(getTestSelect(optionsWithDescription));
737
+ await page.waitForChanges();
738
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
739
+ await select.press("ArrowDown");
740
+ await page.waitForChanges();
741
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
742
+ const firstOption = await menu.findAll("li");
743
+ expect(firstOption[0].getAttribute("aria-label")).toBe("Test label 1, Test group group");
744
+ });
745
+ it("should set the aria-label correctly if an option has a description and is within a group", async () => {
746
+ const page = await newE2EPage();
747
+ const optionsWithDescription = `[
748
+ {
749
+ label: 'Test group',
750
+ children: [
751
+ { label: 'Test label 1', value: 'Test value 1', description: 'Test description 1' },
752
+ { label: 'Test label 2', value: 'Test value 2' },
753
+ { label: 'Test label 3', value: 'Test value 3' },
754
+ ],
755
+ },
756
+ ]`;
757
+ await page.setContent(getTestSelect(optionsWithDescription));
758
+ await page.waitForChanges();
759
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
760
+ await select.press("ArrowDown");
761
+ await page.waitForChanges();
762
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
763
+ const firstOption = await menu.findAll("li");
764
+ expect(firstOption[0].getAttribute("aria-label")).toBe("Test label 1, Test description 1, Test group group");
765
+ });
766
+ it("should call icFocus when focused", async () => {
767
+ const page = await newE2EPage();
768
+ await page.setContent(`<button>Test button</button>${getTestSelect(options)}`);
769
+ await page.waitForChanges();
770
+ const button = await page.find("button");
771
+ await button.focus();
772
+ await page.waitForChanges();
773
+ const icFocus = await page.spyOnEvent("icFocus");
774
+ await page.keyboard.down("Tab");
775
+ await page.waitForChanges();
776
+ expect(icFocus).toHaveReceivedEvent();
777
+ });
778
+ it("should call icBlur when it loses focus", async () => {
779
+ const page = await newE2EPage();
780
+ await page.setContent(getTestSelect(options));
781
+ await page.waitForChanges();
782
+ const icBlur = await page.spyOnEvent("icBlur");
783
+ await page.keyboard.down("Tab");
784
+ await page.keyboard.down("Tab");
785
+ await page.waitForChanges();
786
+ expect(icBlur).toHaveReceivedEvent();
787
+ });
788
+ describe("loading", () => {
789
+ it("should display a loading message and then the options when fetching options externally", async () => {
790
+ const page = await newE2EPage();
791
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" loading="true"></ic-select-with-multi>
792
+ <script>
793
+ var select = document.querySelector('ic-select-with-multi');
794
+ select.options = [];
795
+ select.addEventListener('icChange', function (event) {
796
+ option = event.detail.value;
797
+ select.value = option;
798
+ });
799
+ setTimeout(() => {
800
+ select.options = [
801
+ { label: 'Test label 1', value: 'Test value 1' },
802
+ { label: 'Test label 2', value: 'Test value 2' },
803
+ { label: 'Test label 3', value: 'Test value 3' },
804
+ ];
805
+ }, 1000);
806
+ </script>`);
807
+ await page.waitForChanges();
808
+ let firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li");
809
+ expect(firstOption).toEqualText("Loading...");
810
+ await page.waitForTimeout(1500);
811
+ firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li");
812
+ expect(firstOption).toEqualText("Test label 1");
813
+ const icSelect = await page.find("ic-select-with-multi");
814
+ expect(icSelect.getAttribute("loading")).toBeFalsy;
815
+ });
816
+ it("should display a retry button and a custom loading error when it times out and should not update the options", async () => {
817
+ const page = await newE2EPage();
818
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" loading="true" timeout="500" options="[]" loading-error-label="Error"></ic-select-with-multi>`);
819
+ await page.waitForChanges();
820
+ let firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li");
821
+ expect(firstOption).toEqualText("Loading...");
822
+ await page.waitForTimeout(560);
823
+ firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li ic-typography");
824
+ expect(firstOption).toEqualText("Error");
825
+ const retryButton = await page.find("ic-select-with-multi >>> #retry-button");
826
+ expect(retryButton).not.toBeNull;
827
+ await page.waitForTimeout(1500);
828
+ firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li ic-typography");
829
+ expect(firstOption).toEqualText("Error");
830
+ });
831
+ it("should focus the retry button on tab and emit icBlur and close the menu when blurring", async () => {
832
+ const page = await newE2EPage();
833
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" loading="true" timeout="500" options="[]" loading-error-label="Error"></ic-select-with-multi>`);
834
+ await page.waitForChanges();
835
+ await page.waitForTimeout(560);
836
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
837
+ await select.click();
838
+ await page.waitForChanges();
839
+ await page.keyboard.press("Tab");
840
+ await page.waitForChanges();
841
+ const icBlur = await page.spyOnEvent("icBlur");
842
+ expect(icBlur).not.toHaveReceivedEvent();
843
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
844
+ expect(activeElId).toBe("retry-button");
845
+ await page.keyboard.press("Tab");
846
+ await page.waitForChanges();
847
+ expect(icBlur).toHaveReceivedEvent();
848
+ });
849
+ it("should retry loading and keep the menu open when retry button is clicked", async () => {
850
+ const page = await newE2EPage();
851
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" loading="true" timeout="500"></ic-select-with-multi>
852
+ <script>
853
+ var select = document.querySelector('ic-select-with-multi');
854
+ select.options = [];
855
+ select.addEventListener('icChange', function (event) {
856
+ option = event.detail.value;
857
+ select.value = option;
858
+ });
859
+ select.addEventListener('icRetryLoad', function () {
860
+ select.loading = true;
861
+ });
862
+ </script>`);
863
+ await page.waitForChanges();
864
+ const icRetryLoad = await page.spyOnEvent("icRetryLoad");
865
+ await page.waitForTimeout(560);
866
+ let firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li ic-typography");
867
+ expect(firstOption).toEqualText("Loading Error");
868
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
869
+ await select.click();
870
+ await page.waitForChanges();
871
+ const retryButton = await page.find("ic-select-with-multi >>> #retry-button");
872
+ await retryButton.click();
873
+ await page.waitForChanges();
874
+ expect(icRetryLoad).toHaveReceivedEvent;
875
+ firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li");
876
+ expect(firstOption).toEqualText("Loading...");
877
+ expect(await getMenuVisibility(page)).toBe("visible");
878
+ });
879
+ it("should retry loading and keep the menu open when retry button is pressed with Enter", async () => {
880
+ const page = await newE2EPage();
881
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" loading="true" options="[]" timeout="500"></ic-select-with-multi>`);
882
+ await page.waitForChanges();
883
+ const icRetryLoad = await page.spyOnEvent("icRetryLoad");
884
+ await page.waitForTimeout(560);
885
+ const firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li ic-typography");
886
+ expect(firstOption).toEqualText("Loading Error");
887
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
888
+ await select.click();
889
+ await page.waitForChanges();
890
+ const retryButton = await page.find("ic-select-with-multi >>> #retry-button");
891
+ await retryButton.press("Enter");
892
+ await page.waitForChanges();
893
+ expect(icRetryLoad).toHaveReceivedEvent;
894
+ expect(await getMenuVisibility(page)).toBe("visible");
895
+ });
896
+ it("should render a No results message if no options are provided on render", async () => {
897
+ const page = await newE2EPage();
898
+ await page.setContent(getTestSelect(`[]`));
899
+ await page.waitForChanges();
900
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
901
+ await select.click();
902
+ await page.waitForChanges();
903
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
904
+ const menuOptions = await menu.findAll("li");
905
+ expect(menuOptions).toHaveLength(1);
906
+ expect(menuOptions[0]).toEqualText("No results found");
907
+ });
908
+ });
909
+ });
910
+ describe("searchable", () => {
911
+ it("should open menu when character is entered in input field and filter options", async () => {
912
+ const page = await newE2EPage();
913
+ await page.setContent(getTestSearchableSelect(searchableOptions));
914
+ await page.waitForChanges();
915
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
916
+ await select.press("c");
917
+ await page.waitForChanges();
918
+ expect(await getMenuVisibility(page)).toBe("visible");
919
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
920
+ const menuOptions = await menu.findAll("li");
921
+ expect(menuOptions).toHaveLength(4);
922
+ expect(menuOptions[0]).toEqualText("Cappuccino");
923
+ expect(menuOptions[1]).toEqualText("Americano");
924
+ expect(menuOptions[2]).toEqualText("Mocha");
925
+ expect(menuOptions[3]).toEqualText("Macchiato");
926
+ });
927
+ it("should keep the same options when characters are entered and the menu is reopened", async () => {
928
+ const page = await newE2EPage();
929
+ await page.setContent(getTestSearchableSelect(searchableOptions));
930
+ await page.waitForChanges();
931
+ await focusAndTypeIntoInput("foo", page);
932
+ await page.waitForChanges();
933
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
934
+ let menuOptions = await menu.findAll("li");
935
+ expect(menuOptions).toHaveLength(1);
936
+ expect(menuOptions[0]).toEqualText("No results found");
937
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
938
+ select.click();
939
+ await page.waitForChanges();
940
+ expect(await getMenuVisibility(page)).toBe("hidden");
941
+ select.click();
942
+ await page.waitForChanges();
943
+ expect(await getMenuVisibility(page)).toBe("visible");
944
+ menuOptions = await menu.findAll("li");
945
+ expect(menuOptions).toHaveLength(1);
946
+ expect(menuOptions[0]).toEqualText("No results found");
947
+ });
948
+ it("should display no results state when search term matches none of the options", async () => {
949
+ const page = await newE2EPage();
950
+ await page.setContent(getTestSearchableSelect(searchableOptions));
951
+ await page.waitForChanges();
952
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
953
+ await select.press("z");
954
+ await page.waitForChanges();
955
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
956
+ const menuOptions = await menu.findAll("li");
957
+ expect(menuOptions).toHaveLength(1);
958
+ expect(menuOptions[0]).toEqualText("No results found");
959
+ });
960
+ it("should filter options accordingly when Backspace is pressed", async () => {
961
+ const page = await newE2EPage();
962
+ await page.setContent(getTestSearchableSelect(searchableOptions));
963
+ await page.waitForChanges();
964
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
965
+ await select.press("f");
966
+ await page.waitForChanges();
967
+ await select.press("i");
968
+ await page.waitForChanges();
969
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
970
+ let menuOptions = await menu.findAll("li");
971
+ expect(menuOptions).toHaveLength(1);
972
+ await select.press("Backspace");
973
+ await page.waitForChanges();
974
+ menuOptions = await menu.findAll("li");
975
+ expect(menuOptions).toHaveLength(2);
976
+ expect(menuOptions[0]).toEqualText("Filter");
977
+ expect(menuOptions[1]).toEqualText("Flat white");
978
+ });
979
+ it("should filter options when search match position is set to start", async () => {
980
+ const page = await newE2EPage();
981
+ await page.setContent(getTestSearchableSelect(searchableOptions));
982
+ const icSelect = await page.find("ic-select-with-multi");
983
+ icSelect.setAttribute("search-match-position", "start");
984
+ await page.waitForChanges();
985
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
986
+ await select.press("c");
987
+ await page.waitForChanges();
988
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
989
+ const menuOptions = await menu.findAll("li");
990
+ expect(menuOptions).toHaveLength(1);
991
+ expect(menuOptions[0]).toEqualText("Cappuccino");
992
+ });
993
+ it("should include option descriptions in search", async () => {
994
+ const page = await newE2EPage();
995
+ const optionsWithDescription = `[
996
+ { label: "Cappuccino", value: "Cap" },
997
+ { label: "Latte", value: "Lat", description: "A milkier coffee than a cappuccino" },
998
+ { label: "Americano", value: "Ame" },
999
+ { label: "Filter", value: "Fil" },
1000
+ { label: "Flat white", value: "Fla" },
1001
+ { label: "Mocha", value: "Moc" },
1002
+ { label: "Macchiato", value: "Mac" },
1003
+ ]`;
1004
+ await page.setContent(getTestSearchableSelect(optionsWithDescription));
1005
+ const icSelect = await page.find("ic-select-with-multi");
1006
+ icSelect.setAttribute("include-descriptions-in-search", true);
1007
+ await page.waitForChanges();
1008
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1009
+ await select.press("m");
1010
+ await page.waitForChanges();
1011
+ await select.press("i");
1012
+ await page.waitForChanges();
1013
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1014
+ const menuOptions = await menu.findAll("li");
1015
+ expect(menuOptions).toHaveLength(1);
1016
+ expect(menuOptions[0].textContent.substring(0, 5)).toEqualText("Latte");
1017
+ });
1018
+ it("should not include group titles in search", async () => {
1019
+ const page = await newE2EPage();
1020
+ const groupedOptions = `[
1021
+ {
1022
+ label: "Fancy",
1023
+ children: [
1024
+ { label: "Cappuccino", value: "Cap" },
1025
+ { label: "Flat white", value: "Flat" },
1026
+ ],
1027
+ },
1028
+ {
1029
+ label: "Boring",
1030
+ children: [
1031
+ { label: "Filter", value: "Fil" },
1032
+ { label: "Latte", value: "Lat" },
1033
+ ],
1034
+ },
1035
+ ]`;
1036
+ await page.setContent(getTestSearchableSelect(groupedOptions));
1037
+ await page.waitForChanges();
1038
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1039
+ await select.press("b");
1040
+ await page.waitForChanges();
1041
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1042
+ const menuOptions = await menu.findAll("li");
1043
+ expect(menuOptions).toHaveLength(1);
1044
+ expect(menuOptions[0]).toEqualText("No results found");
1045
+ });
1046
+ it("should display whole group when group titles included in search", async () => {
1047
+ const page = await newE2EPage();
1048
+ const groupedOptions = `[
1049
+ {
1050
+ label: "Fancy",
1051
+ children: [
1052
+ { label: "Cappuccino", value: "Cap" },
1053
+ { label: "Flat white", value: "Flat" },
1054
+ ],
1055
+ },
1056
+ {
1057
+ label: "Boring",
1058
+ children: [
1059
+ { label: "Filter", value: "Fil" },
1060
+ { label: "Latte", value: "Lat" },
1061
+ ],
1062
+ },
1063
+ ]`;
1064
+ await page.setContent(getTestSearchableSelect(groupedOptions));
1065
+ const icSelect = await page.find("ic-select-with-multi");
1066
+ icSelect.setAttribute("include-group-titles-in-search", true);
1067
+ await page.waitForChanges();
1068
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1069
+ await select.press("b");
1070
+ await page.waitForChanges();
1071
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1072
+ const menuOptions = await menu.findAll("li");
1073
+ expect(menuOptions).toHaveLength(2);
1074
+ expect(menuOptions[0]).toEqualText("Filter");
1075
+ expect(menuOptions[1]).toEqualText("Latte");
1076
+ });
1077
+ it("should display a clear button which clears the input when clicked", async () => {
1078
+ const page = await newE2EPage();
1079
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1080
+ await page.waitForChanges();
1081
+ const icChange = await page.spyOnEvent("icChange");
1082
+ let clearButton = await page.find("ic-select-with-multi >>> .clear-button");
1083
+ expect(clearButton).toBeNull();
1084
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1085
+ await select.press("a");
1086
+ await page.waitForChanges();
1087
+ clearButton = await page.find("ic-select-with-multi >>> .clear-button");
1088
+ expect(clearButton).not.toBeNull();
1089
+ await clearButton.click();
1090
+ expect(select.textContent).toBe("");
1091
+ expect(icChange).toHaveReceivedEventDetail({
1092
+ value: null,
1093
+ });
1094
+ });
1095
+ it("should emit the value as null when the input is changed after selecting an option", async () => {
1096
+ const page = await newE2EPage();
1097
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1098
+ await page.waitForChanges();
1099
+ const icChange = await page.spyOnEvent("icChange");
1100
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1101
+ await select.press("ArrowDown");
1102
+ await page.waitForChanges();
1103
+ await page.keyboard.press("Enter");
1104
+ await page.waitForChanges();
1105
+ expect(icChange).toHaveReceivedEventDetail({
1106
+ value: "Cap",
1107
+ });
1108
+ const clearButton = await page.find("ic-select-with-multi >>> .clear-button");
1109
+ await clearButton.click();
1110
+ await page.waitForChanges();
1111
+ expect(icChange).toHaveReceivedEventDetail({
1112
+ value: null,
1113
+ });
1114
+ });
1115
+ it("should still filter the options when the input is changed after selecting an option", async () => {
1116
+ const page = await newE2EPage();
1117
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1118
+ await page.waitForChanges();
1119
+ const icChange = await page.spyOnEvent("icChange");
1120
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1121
+ await select.press("ArrowDown");
1122
+ await page.waitForChanges();
1123
+ await select.press("Enter");
1124
+ await page.waitForChanges();
1125
+ expect(icChange).toHaveReceivedEventDetail({
1126
+ value: "Cap",
1127
+ });
1128
+ for (let i = 0; i <= 7; i++) {
1129
+ select.press("Backspace");
1130
+ await page.waitForChanges();
1131
+ }
1132
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1133
+ const menuOptions = await menu.findAll("li");
1134
+ expect(menuOptions).toHaveLength(2);
1135
+ expect(menuOptions[0]).toEqualText("Cappuccino");
1136
+ expect(menuOptions[1]).toEqualText("Americano");
1137
+ });
1138
+ it("should close menu on blur", async () => {
1139
+ const page = await newE2EPage();
1140
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1141
+ await page.waitForChanges();
1142
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1143
+ await select.click();
1144
+ await page.waitForChanges();
1145
+ expect(await getMenuVisibility(page)).toBe("visible");
1146
+ await select.press("Tab");
1147
+ expect(await getMenuVisibility(page)).toBe("hidden");
1148
+ });
1149
+ it("should emit icChange on delay", async () => {
1150
+ const page = await newE2EPage();
1151
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" debounce="500" searchable></ic-select-with-multi>`);
1152
+ await page.waitForChanges();
1153
+ const icChange = await page.spyOnEvent("icChange");
1154
+ await focusAndTypeIntoInput("foo", page);
1155
+ await page.waitForTimeout(600);
1156
+ expect(icChange).toHaveReceivedEventDetail({
1157
+ value: "foo",
1158
+ });
1159
+ await focusAndTypeIntoInput("bar", page);
1160
+ await page.waitForChanges();
1161
+ await page.waitForTimeout(100);
1162
+ expect(icChange).toHaveReceivedEventDetail({
1163
+ value: "foo",
1164
+ });
1165
+ await page.waitForTimeout(500);
1166
+ expect(icChange).toHaveReceivedEventDetail({
1167
+ value: "foobar",
1168
+ });
1169
+ });
1170
+ it("should update hidden input to value typed in select searchable input", async () => {
1171
+ const page = await newE2EPage();
1172
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1173
+ await page.waitForChanges();
1174
+ await focusAndTypeIntoInput("bar", page);
1175
+ await page.waitForChanges();
1176
+ const hiddenInput = await page.find("input[type='hidden']");
1177
+ expect(hiddenInput.getAttribute("value")).toBe("bar");
1178
+ });
1179
+ it("should keep typed in hidden input value when highlighting menu options", async () => {
1180
+ const page = await newE2EPage();
1181
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1182
+ await page.waitForChanges();
1183
+ await focusAndTypeIntoInput("cap", page);
1184
+ await page.waitForChanges();
1185
+ let hiddenInput = await page.find("input[type='hidden']");
1186
+ expect(hiddenInput.getAttribute("value")).toBe("cap");
1187
+ await page.keyboard.press("ArrowDown");
1188
+ await page.waitForChanges();
1189
+ const menuListItems = await page.findAll("ic-select-with-multi >>> ic-menu-with-multi > ul > li");
1190
+ expect(menuListItems[0]).toHaveClass("focused-option");
1191
+ hiddenInput = await page.find("input[type='hidden']");
1192
+ expect(hiddenInput.getAttribute("value")).toBe("cap");
1193
+ });
1194
+ it("should update hidden value from typed to selected", async () => {
1195
+ const page = await newE2EPage();
1196
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1197
+ await page.waitForChanges();
1198
+ await focusAndTypeIntoInput("o", page);
1199
+ await page.waitForChanges();
1200
+ const hiddenInput = await page.find("input[type='hidden']");
1201
+ expect(hiddenInput.getAttribute("value")).toBe("o");
1202
+ await page.keyboard.press("ArrowDown");
1203
+ await page.waitForChanges();
1204
+ const menuListItems = await page.findAll("ic-select-with-multi >>> ic-menu-with-multi > ul > li");
1205
+ expect(menuListItems[0]).toHaveClass("focused-option");
1206
+ await page.keyboard.press("Enter");
1207
+ await page.waitForChanges();
1208
+ expect(hiddenInput.getAttribute("value")).toBe("Cap");
1209
+ });
1210
+ it("should update hidden value from typed to selected to typed", async () => {
1211
+ const page = await newE2EPage();
1212
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1213
+ await page.waitForChanges();
1214
+ await focusAndTypeIntoInput("o", page);
1215
+ await page.waitForChanges();
1216
+ const hiddenInput = await page.find("input[type='hidden']");
1217
+ expect(hiddenInput.getAttribute("value")).toBe("o");
1218
+ await page.keyboard.press("ArrowDown");
1219
+ await page.waitForChanges();
1220
+ const menuListItems = await page.findAll("ic-select-with-multi >>> ic-menu-with-multi > ul > li");
1221
+ expect(menuListItems[0]).toHaveClass("focused-option");
1222
+ await page.keyboard.press("Enter");
1223
+ await page.waitForChanges();
1224
+ expect(hiddenInput.getAttribute("value")).toBe("Cap");
1225
+ await page.keyboard.press("1");
1226
+ await page.waitForChanges();
1227
+ expect(hiddenInput.getAttribute("value")).toBe("Cappuccino1");
1228
+ });
1229
+ it("should update the value of the input and options when passing the value directly", async () => {
1230
+ const page = await newE2EPage();
1231
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1232
+ await page.waitForChanges();
1233
+ const select = await page.find("ic-select-with-multi");
1234
+ select.setAttribute("value", "foo");
1235
+ await page.waitForChanges();
1236
+ const selectInput = await page.find('ic-select-with-multi >>> input[role="combobox"]');
1237
+ expect(await selectInput.getProperty("value")).toBe("foo");
1238
+ });
1239
+ it("should trigger icChange on input for each typed value", async () => {
1240
+ const page = await newE2EPage();
1241
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1242
+ await page.waitForChanges();
1243
+ const select = await page.find("ic-select-with-multi");
1244
+ const icChange = await select.spyOnEvent("icChange");
1245
+ await focusAndTypeIntoInput("f", page);
1246
+ await page.waitForChanges();
1247
+ expect(icChange).toHaveReceivedEventDetail({
1248
+ value: "f",
1249
+ });
1250
+ await focusAndTypeIntoInput("o", page);
1251
+ await page.waitForChanges();
1252
+ expect(icChange).toHaveReceivedEventDetail({
1253
+ value: "fo",
1254
+ });
1255
+ await focusAndTypeIntoInput("o", page);
1256
+ await page.waitForChanges();
1257
+ expect(icChange).toHaveReceivedEventDetail({
1258
+ value: "foo",
1259
+ });
1260
+ });
1261
+ it("should not trigger icChange on highlighting menu items", async () => {
1262
+ const page = await newE2EPage();
1263
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1264
+ await page.waitForChanges();
1265
+ const select = await page.find("ic-select-with-multi");
1266
+ const icChange = await select.spyOnEvent("icChange");
1267
+ await page.$eval("ic-select-with-multi", (el) => {
1268
+ const input = el.shadowRoot.querySelector("input");
1269
+ input.focus();
1270
+ });
1271
+ await page.waitForChanges();
1272
+ await page.keyboard.press("ArrowDown");
1273
+ await page.waitForChanges();
1274
+ expect(icChange).not.toHaveReceivedEvent();
1275
+ await page.keyboard.press("ArrowDown");
1276
+ await page.waitForChanges();
1277
+ expect(icChange).not.toHaveReceivedEvent();
1278
+ });
1279
+ it("should not select a menu option when typing into the searchable input field", async () => {
1280
+ const page = await newE2EPage();
1281
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1282
+ await page.waitForChanges();
1283
+ await focusAndTypeIntoInput("Cap", page);
1284
+ await page.waitForChanges();
1285
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1286
+ expect(await getMenuVisibility(page)).toBe("visible");
1287
+ const firstOption = await menu.findAll("li");
1288
+ expect(firstOption[0]).not.toHaveClass("aria-selected");
1289
+ });
1290
+ it("should not selet a menu option when one has previously been set and backspace is pressed", async () => {
1291
+ const page = await newE2EPage();
1292
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1293
+ await page.waitForChanges();
1294
+ await focusAndTypeIntoInput("Lat", page);
1295
+ await page.waitForChanges();
1296
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1297
+ expect(await getMenuVisibility(page)).toBe("visible");
1298
+ await page.keyboard.press("ArrowDown");
1299
+ await page.waitForChanges();
1300
+ await page.keyboard.press("Enter");
1301
+ await page.waitForChanges();
1302
+ const inputValue = await page.$eval("ic-select-with-multi", (el) => {
1303
+ const input = el.shadowRoot.querySelector("input");
1304
+ return input.value;
1305
+ });
1306
+ expect(inputValue).toBe("Latte");
1307
+ await page.keyboard.press("Backspace");
1308
+ await page.waitForChanges();
1309
+ await page.keyboard.press("Backspace");
1310
+ await page.waitForChanges();
1311
+ const options = await menu.findAll("li");
1312
+ options.forEach((option) => {
1313
+ expect(option).not.toHaveClass("aria-selected");
1314
+ });
1315
+ });
1316
+ it("should display selected option when selecting a menu option and then opening and closing the menu", async () => {
1317
+ const page = await newE2EPage();
1318
+ await page.setContent(getTestSearchableSelect(searchableOptions));
1319
+ await page.waitForChanges();
1320
+ await focusAndTypeIntoInput("Lat", page);
1321
+ await page.waitForChanges();
1322
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1323
+ expect(await getMenuVisibility(page)).toBe("visible");
1324
+ await page.keyboard.press("ArrowDown");
1325
+ await page.waitForChanges();
1326
+ await page.keyboard.press("Enter");
1327
+ await page.waitForChanges();
1328
+ const inputValue = await page.$eval("ic-select-with-multi", (el) => {
1329
+ const input = el.shadowRoot.querySelector("input");
1330
+ return input.value;
1331
+ });
1332
+ expect(inputValue).toBe("Latte");
1333
+ await page.evaluate(() => {
1334
+ const button = document.querySelector("button");
1335
+ button.focus();
1336
+ });
1337
+ await page.waitForChanges();
1338
+ expect(await getMenuVisibility(page)).toBe("hidden");
1339
+ const select = await page.find("ic-select-with-multi");
1340
+ await select.click();
1341
+ await page.keyboard.press("ArrowDown");
1342
+ await page.waitForChanges();
1343
+ const latteOption = await menu.find("li[data-value='Lat']");
1344
+ expect(latteOption).toHaveAttribute("aria-selected");
1345
+ });
1346
+ it("hidden input value when on initial load with default value", async () => {
1347
+ const page = await newE2EPage();
1348
+ await page.setContent(getTestSelectSearchableFormReset(options));
1349
+ await page.waitForChanges();
1350
+ const hiddenInput = await page.find("ic-select-with-multi > [name*='ic-select-input-0']");
1351
+ expect(hiddenInput.getAttribute("value")).toBe("Test value 1");
1352
+ });
1353
+ it("should submit hidden input value when updating value, pressing reset to initial value and then submitting", async () => {
1354
+ const page = await newE2EPage();
1355
+ await page.setContent(getTestSelectSearchableFormReset(options));
1356
+ await page.waitForChanges();
1357
+ const hiddenInput = await page.find("ic-select-with-multi > [name*='ic-select-input-0']");
1358
+ expect(hiddenInput.getAttribute("value")).toBe("Test value 1");
1359
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1360
+ await select.press("Backspace");
1361
+ await page.waitForChanges();
1362
+ expect(await getMenuVisibility(page)).toBe("visible");
1363
+ await page.keyboard.press("ArrowDown");
1364
+ await page.waitForChanges();
1365
+ await page.keyboard.press("ArrowDown");
1366
+ await page.waitForChanges();
1367
+ await page.keyboard.press("Enter");
1368
+ await page.waitForChanges();
1369
+ expect(hiddenInput.getAttribute("value")).toBe("Test value 2");
1370
+ await page.$eval("#resetButton", (el) => {
1371
+ const reset = el;
1372
+ reset.click();
1373
+ });
1374
+ await page.waitForChanges();
1375
+ expect(hiddenInput.getAttribute("value")).toBe("Test value 1");
1376
+ });
1377
+ it("should scroll menu", async () => {
1378
+ const page = await newE2EPage();
1379
+ await page.setContent(getTestSearchableSelect(largeOptions));
1380
+ await page.waitForChanges();
1381
+ await focusAndTypeIntoInput("Test", page);
1382
+ await page.waitForChanges();
1383
+ expect(await getMenuVisibility(page)).toBe("visible");
1384
+ await page.keyboard.press("ArrowDown");
1385
+ await page.waitForChanges();
1386
+ let menuScrollTop = await page.$eval("ic-select-with-multi", (el) => {
1387
+ const menu = el.shadowRoot.querySelector("ic-menu-with-multi ul");
1388
+ return menu.scrollTop;
1389
+ });
1390
+ expect(menuScrollTop).toBe(0);
1391
+ await page.keyboard.press("Enter");
1392
+ await page.waitForChanges();
1393
+ const inputValue = await page.$eval("ic-select-with-multi", (el) => {
1394
+ const input = el.shadowRoot.querySelector("input");
1395
+ return input.value;
1396
+ });
1397
+ expect(inputValue).toBe("Test label 1");
1398
+ await page.$eval("ic-select-with-multi", (el) => {
1399
+ const input = el.shadowRoot.querySelector("input");
1400
+ input.focus();
1401
+ });
1402
+ await page.waitForChanges();
1403
+ await page.keyboard.press("ArrowUp");
1404
+ await page.waitForChanges();
1405
+ menuScrollTop = await page.$eval("ic-select-with-multi", (el) => {
1406
+ const menu = el.shadowRoot.querySelector("ic-menu-with-multi ul");
1407
+ return menu.scrollTop;
1408
+ });
1409
+ expect(menuScrollTop).not.toBe(0);
1410
+ });
1411
+ it("should only highlight and select enabled options in searchable with arrowDown", async () => {
1412
+ const page = await newE2EPage();
1413
+ await page.setContent(getTestSearchableSelect(optionsWithDisabled));
1414
+ await page.waitForChanges();
1415
+ await focusAndTypeIntoInput("Test", page);
1416
+ await page.waitForChanges();
1417
+ expect(await getMenuVisibility(page)).toBe("visible");
1418
+ await page.keyboard.press("ArrowDown");
1419
+ await page.waitForChanges();
1420
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1421
+ const menuItems = await menu.findAll("li");
1422
+ expect(menuItems[0]).not.toHaveClass("focused-option");
1423
+ expect(menuItems[1]).toHaveClass("focused-option");
1424
+ await page.keyboard.press("Enter");
1425
+ await page.waitForChanges();
1426
+ let inputValue = await page.$eval("ic-select-with-multi", (el) => {
1427
+ const input = el.shadowRoot.querySelector("input");
1428
+ return input.value;
1429
+ });
1430
+ expect(inputValue).toBe("Test label 2");
1431
+ await page.keyboard.press("ArrowDown");
1432
+ await page.waitForChanges();
1433
+ await page.keyboard.press("ArrowDown");
1434
+ await page.waitForChanges();
1435
+ await page.keyboard.press("Enter");
1436
+ await page.waitForChanges();
1437
+ inputValue = await page.$eval("ic-select-with-multi", (el) => {
1438
+ const input = el.shadowRoot.querySelector("input");
1439
+ return input.value;
1440
+ });
1441
+ expect(inputValue).toBe("Test label 5");
1442
+ });
1443
+ it("should only highlight and select enabled options in searchable with arrowUp", async () => {
1444
+ const page = await newE2EPage();
1445
+ await page.setContent(getTestSearchableSelect(optionsWithDisabled));
1446
+ await page.waitForChanges();
1447
+ await focusAndTypeIntoInput("Test", page);
1448
+ await page.waitForChanges();
1449
+ expect(await getMenuVisibility(page)).toBe("visible");
1450
+ await page.keyboard.press("ArrowUp");
1451
+ await page.waitForChanges();
1452
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1453
+ const menuItems = await menu.findAll("li");
1454
+ expect(menuItems[menuItems.length - 1]).toHaveClass("focused-option");
1455
+ expect(menuItems[menuItems.length - 2]).not.toHaveClass("focused-option");
1456
+ await page.keyboard.press("Enter");
1457
+ await page.waitForChanges();
1458
+ let inputValue = await page.$eval("ic-select-with-multi", (el) => {
1459
+ const input = el.shadowRoot.querySelector("input");
1460
+ return input.value;
1461
+ });
1462
+ expect(inputValue).toBe("Test label 5");
1463
+ await page.keyboard.press("ArrowUp");
1464
+ await page.waitForChanges();
1465
+ await page.keyboard.press("ArrowUp");
1466
+ await page.waitForChanges();
1467
+ await page.keyboard.press("Enter");
1468
+ await page.waitForChanges();
1469
+ inputValue = await page.$eval("ic-select-with-multi", (el) => {
1470
+ const input = el.shadowRoot.querySelector("input");
1471
+ return input.value;
1472
+ });
1473
+ expect(inputValue).toBe("Test label 2");
1474
+ });
1475
+ describe("loading", () => {
1476
+ it("should retry loading and keep the menu open when retry button is pressed with Spacebar", async () => {
1477
+ const page = await newE2EPage();
1478
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" searchable="true" options="[]" loading="true" timeout="500"></ic-select-with-multi>`);
1479
+ await page.waitForChanges();
1480
+ const icRetryLoad = await page.spyOnEvent("icRetryLoad");
1481
+ await page.waitForTimeout(560);
1482
+ const firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li ic-typography");
1483
+ expect(firstOption).toEqualText("Loading Error");
1484
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1485
+ await select.click();
1486
+ await page.waitForChanges();
1487
+ const retryButton = await page.find("ic-select-with-multi >>> #retry-button");
1488
+ await retryButton.press(" ");
1489
+ await page.waitForChanges();
1490
+ expect(icRetryLoad).toHaveReceivedEvent;
1491
+ expect(await getMenuVisibility(page)).toBe("visible");
1492
+ });
1493
+ it("should cancel loading if the clear button is pressed mid-load", async () => {
1494
+ const page = await newE2EPage();
1495
+ await page.setContent(`<ic-select-with-multi label="IC Select Test" searchable="true" timeout="500"></ic-select-with-multi>
1496
+ <script>
1497
+ var select = document.querySelector("ic-select-with-multi");
1498
+ select.options = [];
1499
+ select.addEventListener("icChange", function() {
1500
+ select.loading = "true";
1501
+ });
1502
+ </script>`);
1503
+ await page.waitForChanges();
1504
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1505
+ await select.press("c");
1506
+ await page.waitForChanges();
1507
+ let firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li");
1508
+ expect(firstOption).toEqualText("Loading...");
1509
+ const clearButton = await page.find("ic-select-with-multi >>> .clear-button");
1510
+ await clearButton.click();
1511
+ await page.waitForChanges();
1512
+ await page.waitForTimeout(560);
1513
+ firstOption = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu li");
1514
+ expect(firstOption).toBeNull;
1515
+ });
1516
+ it("should render a No results message if no options are provided on render", async () => {
1517
+ const page = await newE2EPage();
1518
+ await page.setContent(getTestSearchableSelect(`[]`));
1519
+ await page.waitForChanges();
1520
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1521
+ await select.click();
1522
+ await page.waitForChanges();
1523
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1524
+ const menuOptions = await menu.findAll("li");
1525
+ expect(menuOptions).toHaveLength(1);
1526
+ expect(menuOptions[0]).toEqualText("No results found");
1527
+ });
1528
+ });
1529
+ });
1530
+ it("should reset to initial value on form reset", async () => {
1531
+ const page = await newE2EPage();
1532
+ await page.setContent(getTestSelectFormReset(options));
1533
+ await page.waitForChanges();
1534
+ let value = await page.$eval("ic-select-with-multi", (el) => {
1535
+ const select = el;
1536
+ return select.value;
1537
+ });
1538
+ expect(value).toBe(undefined);
1539
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1540
+ await select.press("Enter");
1541
+ await page.waitForChanges();
1542
+ await select.press("ArrowDown");
1543
+ await page.waitForChanges();
1544
+ value = await page.$eval("ic-select-with-multi", (el) => {
1545
+ const select = el;
1546
+ return select.value;
1547
+ });
1548
+ expect(value).toBe("Test value 1");
1549
+ await page.$eval("#resetButton", (el) => {
1550
+ const reset = el;
1551
+ reset.click();
1552
+ });
1553
+ await page.waitForChanges();
1554
+ value = await page.$eval("ic-select-with-multi", (el) => {
1555
+ const select = el;
1556
+ return select.value;
1557
+ });
1558
+ expect(value).toBe(undefined);
1559
+ });
1560
+ it("menu should not be visible on initial load if setting default value and disable filter is set", async () => {
1561
+ const page = await newE2EPage();
1562
+ await page.setContent(getTestSearchableSelectAsync());
1563
+ await page.waitForChanges();
1564
+ await page.waitForTimeout(900);
1565
+ expect(await getMenuVisibility(page)).toBe("hidden");
1566
+ });
1567
+ it("should reset to initial value on form reset with searchable", async () => {
1568
+ const page = await newE2EPage();
1569
+ await page.setContent(getTestSelectSearchableFormReset(options));
1570
+ await page.waitForChanges();
1571
+ let value = await page.$eval("ic-select-with-multi", (el) => {
1572
+ const select = el;
1573
+ return select.value;
1574
+ });
1575
+ expect(value).toBe("Test value 1");
1576
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1577
+ await select.press("ArrowDown");
1578
+ await page.waitForChanges();
1579
+ await page.keyboard.press("ArrowDown");
1580
+ await page.waitForChanges();
1581
+ await page.keyboard.press("Enter");
1582
+ await page.waitForChanges();
1583
+ value = await page.$eval("ic-select-with-multi", (el) => {
1584
+ const select = el;
1585
+ return select.value;
1586
+ });
1587
+ expect(value).toBe("Test value 2");
1588
+ await page.$eval("#resetButton", (el) => {
1589
+ const reset = el;
1590
+ reset.click();
1591
+ });
1592
+ await page.waitForChanges();
1593
+ value = await page.$eval("ic-select-with-multi", (el) => {
1594
+ const select = el;
1595
+ return select.value;
1596
+ });
1597
+ expect(value).toBe("Test value 1");
1598
+ });
1599
+ let page;
1600
+ describe("native", () => {
1601
+ beforeEach(async () => {
1602
+ page = await newE2EPage();
1603
+ await page.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");
1604
+ await page.setViewport({
1605
+ width: 375,
1606
+ height: 667,
1607
+ isMobile: true,
1608
+ hasTouch: true,
1609
+ });
1610
+ });
1611
+ it("should render", async () => {
1612
+ await page.setContent(getTestSelect(options));
1613
+ await page.waitForChanges();
1614
+ const select = await page.find("ic-select-with-multi >>> select");
1615
+ expect(select).not.toBeNull();
1616
+ });
1617
+ it("should render a native select when searchable is applied on mobile", async () => {
1618
+ await page.setContent(getTestSearchableSelect(options));
1619
+ await page.waitForChanges();
1620
+ const select = await page.find("ic-select-with-multi >>> select");
1621
+ expect(select).not.toBeNull();
1622
+ });
1623
+ it("should render when no options are provided", async () => {
1624
+ await page.setContent(`<ic-select-with-multi label="IC Select Test"></ic-select-with-multi>`);
1625
+ await page.waitForChanges();
1626
+ const select = await page.find("ic-select-with-multi >>> select");
1627
+ expect(select).not.toBeNull();
1628
+ });
1629
+ it("should disable options correctly", async () => {
1630
+ await page.setContent(getTestSelect(optionsWithDisabled));
1631
+ await page.waitForChanges();
1632
+ const optionsDisabled = await page.evaluate(() => Array.from(document
1633
+ .querySelector("ic-select-with-multi")
1634
+ .shadowRoot.querySelectorAll("option"), (option) => option.disabled));
1635
+ expect(optionsDisabled[1]).toBe(true);
1636
+ });
1637
+ it("should render options as <optgroup>s if they have children", async () => {
1638
+ const groupedOptions = `[
1639
+ {
1640
+ label: 'Test group',
1641
+ children: [
1642
+ { label: 'Test label 1', value: 'Test value 1' },
1643
+ { label: 'Test label 2', value: 'Test value 2' },
1644
+ { label: 'Test label 3', value: 'Test value 3' },
1645
+ ],
1646
+ },
1647
+ ]`;
1648
+ await page.setContent(getTestSelect(groupedOptions));
1649
+ await page.waitForChanges();
1650
+ const optGroup = await page.evaluate(() => document
1651
+ .querySelector("ic-select-with-multi")
1652
+ .shadowRoot.querySelector("optgroup"));
1653
+ expect(optGroup).toBeTruthy();
1654
+ });
1655
+ it("should render a required <select> when required", async () => {
1656
+ await page.setContent(getTestSelect(options));
1657
+ const icSelect = await page.find("ic-select-with-multi");
1658
+ icSelect.setAttribute("required", true);
1659
+ await page.waitForChanges();
1660
+ const select = await page.find("ic-select-with-multi >>> select");
1661
+ expect(select).toHaveAttribute("required");
1662
+ });
1663
+ it("should not render a label when the 'hide-label' prop is supplied", async () => {
1664
+ await page.setContent(getTestSelect(options));
1665
+ const icSelect = await page.find("ic-select-with-multi");
1666
+ icSelect.setAttribute("hide-label", true);
1667
+ await page.waitForChanges();
1668
+ const label = await page.find("ic-select-with-multi >>> ic-input-label");
1669
+ expect(label).toBeNull();
1670
+ });
1671
+ it("should render a disabled <select> when the 'disabled' prop is supplied", async () => {
1672
+ await page.setContent(getTestSelect(options));
1673
+ const icSelect = await page.find("ic-select-with-multi");
1674
+ icSelect.setAttribute("disabled", true);
1675
+ await page.waitForChanges();
1676
+ const select = await page.find("ic-select-with-multi >>> select");
1677
+ expect(select).toHaveAttribute("disabled");
1678
+ });
1679
+ it("should render the selected value as text instead of rendering a <select> when read-only", async () => {
1680
+ await page.setContent(getTestSelect(options));
1681
+ const icSelect = await page.find("ic-select-with-multi");
1682
+ icSelect.setAttribute("value", "Test value 1");
1683
+ icSelect.setAttribute("readonly", true);
1684
+ await page.waitForChanges();
1685
+ const select = await page.find("ic-select-with-multi >>> select");
1686
+ const typography = await page.evaluate(() => Array.from(document
1687
+ .querySelector("ic-select-with-multi")
1688
+ .shadowRoot.querySelectorAll("ic-typography"), (typography) => typography.innerText));
1689
+ expect(select).toBe(null);
1690
+ expect(typography[1]).toBe("Test label 1");
1691
+ });
1692
+ it("should render the correct placeholder", async () => {
1693
+ await page.setContent(getTestSelect(options));
1694
+ const icSelect = await page.find("ic-select-with-multi");
1695
+ icSelect.setAttribute("placeholder", "Test placeholder");
1696
+ await page.waitForChanges();
1697
+ const optionLabels = await page.evaluate(() => Array.from(document
1698
+ .querySelector("ic-select-with-multi")
1699
+ .shadowRoot.querySelectorAll("option"), (option) => option.innerText));
1700
+ expect(optionLabels[0]).toEqual("Test placeholder");
1701
+ });
1702
+ it("should set aria-invalid if validation status is 'error'", async () => {
1703
+ await page.setContent(getTestSelect(options));
1704
+ const icSelect = await page.find("ic-select-with-multi");
1705
+ icSelect.setAttribute("validation-status", "error");
1706
+ await page.waitForChanges();
1707
+ const select = await page.find("ic-select-with-multi >>> select");
1708
+ expect(select).toHaveAttribute("aria-invalid");
1709
+ });
1710
+ it("should display the value passed in using the 'value' prop as the selected option", async () => {
1711
+ await page.setContent(getTestSelect(options));
1712
+ const icSelect = await page.find("ic-select-with-multi");
1713
+ icSelect.setAttribute("value", "Test value 1");
1714
+ await page.waitForChanges();
1715
+ const optionsSelected = await page.evaluate(() => Array.from(document
1716
+ .querySelector("ic-select-with-multi")
1717
+ .shadowRoot.querySelectorAll("option"), (option) => option.selected));
1718
+ expect(optionsSelected[1]).toBe(true);
1719
+ });
1720
+ it("should set the correct name on the hidden input", async () => {
1721
+ await page.setContent(getTestSelect(options));
1722
+ const icSelect = await page.find("ic-select-with-multi");
1723
+ icSelect.setAttribute("name", "Test name");
1724
+ await page.waitForChanges();
1725
+ const hiddenInput = await page.find("input");
1726
+ const hiddenInputName = await hiddenInput.getProperty("name");
1727
+ expect(hiddenInputName).toEqual("Test name");
1728
+ });
1729
+ it("should call icChange when the selected option is changed", async () => {
1730
+ await page.setContent(getTestSelect(options));
1731
+ await page.waitForChanges();
1732
+ const icChange = await page.spyOnEvent("icChange");
1733
+ const select = await page.find("ic-select-with-multi >>> select");
1734
+ await select.press("ArrowDown");
1735
+ await select.press("Enter");
1736
+ await page.waitForChanges();
1737
+ expect(icChange).toHaveReceivedEventDetail({
1738
+ value: "Test value 1",
1739
+ });
1740
+ });
1741
+ it("should call icFocus when focused", async () => {
1742
+ await page.setContent(getTestSelect(options));
1743
+ await page.waitForChanges();
1744
+ const icFocus = await page.spyOnEvent("icFocus");
1745
+ await page.keyboard.down("Tab");
1746
+ await page.waitForChanges();
1747
+ expect(icFocus).toHaveReceivedEvent();
1748
+ });
1749
+ it("should call icBlur when it loses focus", async () => {
1750
+ await page.setContent(getTestSelect(options));
1751
+ await page.waitForChanges();
1752
+ const icBlur = await page.spyOnEvent("icBlur");
1753
+ await page.keyboard.down("Tab");
1754
+ await page.keyboard.down("Tab");
1755
+ await page.waitForChanges();
1756
+ expect(icBlur).toHaveReceivedEvent();
1757
+ });
1758
+ it("should set the 'placeholder' class name if no option is selected", async () => {
1759
+ await page.setContent(getTestSelect(options));
1760
+ await page.waitForChanges();
1761
+ const selectClassName = await page.evaluate(() => document
1762
+ .querySelector("ic-select-with-multi")
1763
+ .shadowRoot.querySelector("select").className);
1764
+ expect(selectClassName).toBe("placeholder");
1765
+ });
1766
+ it("should set the text colour to the primary text colour if an option is selected", async () => {
1767
+ await page.setContent(getTestSelect(options));
1768
+ const icSelect = await page.find("ic-select-with-multi");
1769
+ icSelect.setAttribute("value", "Test value 1");
1770
+ await page.waitForChanges();
1771
+ const selectClassName = await page.evaluate(() => document
1772
+ .querySelector("ic-select-with-multi")
1773
+ .shadowRoot.querySelector("select").className);
1774
+ expect(selectClassName).toBe("select-option-selected");
1775
+ });
1776
+ it("should change the text colour to the primary text colour when an option is selected", async () => {
1777
+ await page.setContent(getTestSelect(options));
1778
+ await page.waitForChanges();
1779
+ const select = await page.find("ic-select-with-multi >>> select");
1780
+ await select.press("ArrowDown");
1781
+ await select.press("Enter");
1782
+ await page.waitForChanges();
1783
+ const selectClassName = await page.evaluate(() => document
1784
+ .querySelector("ic-select-with-multi")
1785
+ .shadowRoot.querySelector("select").className);
1786
+ expect(selectClassName).toBe("select-option-selected");
1787
+ });
1788
+ it("should add .menu-scroll to menu components when options height is over 320", async () => {
1789
+ const page = await newE2EPage();
1790
+ await page.setContent(getTestSelect(largeOptions));
1791
+ await page.waitForChanges();
1792
+ const select = await page.find("ic-select-with-multi >>> button.select-input");
1793
+ await select.click();
1794
+ await page.waitForChanges();
1795
+ const menuClasses = await page.evaluate(() => {
1796
+ const menu = document
1797
+ .querySelector("ic-select-with-multi")
1798
+ .shadowRoot.querySelector("ic-menu-with-multi .menu");
1799
+ return menu.classList;
1800
+ });
1801
+ expect(Object.values(menuClasses).includes("menu-scroll")).toBeTruthy();
1802
+ });
1803
+ it("should add .menu-scroll to menu components when options are initially set and then populated with large data set", async () => {
1804
+ const page = await newE2EPage();
1805
+ await page.setContent(getTestSelectAsync(options, largeOptions));
1806
+ await page.waitForChanges();
1807
+ const select = await page.find("ic-select-with-multi >>> button.select-input");
1808
+ await select.click();
1809
+ await page.waitForChanges();
1810
+ let menuClasses = await page.evaluate(() => {
1811
+ const menu = document
1812
+ .querySelector("ic-select-with-multi")
1813
+ .shadowRoot.querySelector("ic-menu-with-multi .menu");
1814
+ return menu.classList;
1815
+ });
1816
+ expect(Object.values(menuClasses).includes("menu-scroll")).toBeFalsy();
1817
+ await page.waitForTimeout(1200);
1818
+ menuClasses = await page.evaluate(() => {
1819
+ const menu = document
1820
+ .querySelector("ic-select-with-multi")
1821
+ .shadowRoot.querySelector("ic-menu-with-multi .menu");
1822
+ return menu.classList;
1823
+ });
1824
+ expect(Object.values(menuClasses).includes("menu-scroll")).toBeTruthy();
1825
+ });
1826
+ });
1827
+ describe("multi", () => {
1828
+ it("should emit icChange and icOptionSelect when an option is selected", async () => {
1829
+ const page = await newE2EPage();
1830
+ await page.setContent(getTestMultiSelect(options));
1831
+ await page.waitForChanges();
1832
+ const icChange = await page.spyOnEvent("icChange");
1833
+ const icOptionSelect = await page.spyOnEvent("icOptionSelect");
1834
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1835
+ await select.press("ArrowDown");
1836
+ await page.waitForChanges();
1837
+ await page.keyboard.press("Enter");
1838
+ await page.waitForChanges();
1839
+ expect(icChange).toHaveReceivedEventDetail({
1840
+ value: ["Test value 1"],
1841
+ });
1842
+ expect(icOptionSelect).toHaveReceivedEventDetail({
1843
+ value: "Test value 1",
1844
+ });
1845
+ });
1846
+ it("should deselect an option correctly - emit icChange and icOptionDeselect, and remove check icon and aria-selected", async () => {
1847
+ const page = await newE2EPage();
1848
+ await page.setContent(getTestMultiSelect(options));
1849
+ await page.waitForChanges();
1850
+ const icChange = await page.spyOnEvent("icChange");
1851
+ const icOptionDeselect = await page.spyOnEvent("icOptionDeselect");
1852
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1853
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
1854
+ const optionEls = await menu.findAll("li");
1855
+ await select.press("ArrowDown");
1856
+ await page.waitForChanges();
1857
+ await page.keyboard.press("Enter");
1858
+ await page.waitForChanges();
1859
+ expect(optionEls[0].getAttribute("aria-selected")).toBeTruthy;
1860
+ expect(await optionEls[0].find(".check-icon")).not.toBeNull;
1861
+ await page.keyboard.press("Enter");
1862
+ await page.waitForChanges();
1863
+ expect(icChange).toHaveReceivedEventDetail({
1864
+ value: null,
1865
+ });
1866
+ expect(icOptionDeselect).toHaveReceivedEventDetail({
1867
+ value: "Test value 1",
1868
+ });
1869
+ expect(optionEls[0].getAttribute("aria-selected")).toBeFalsy;
1870
+ expect(await optionEls[0].find(".check-icon")).toBeNull;
1871
+ });
1872
+ it("should move focus from menu to 'Select all' button and back again", async () => {
1873
+ const page = await newE2EPage();
1874
+ await page.setContent(getTestMultiSelect(options));
1875
+ await page.waitForChanges();
1876
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1877
+ await select.press("Enter");
1878
+ await page.waitForChanges();
1879
+ let activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
1880
+ expect(activeElId).toBe("ic-select-input-0-menu");
1881
+ await page.keyboard.press("Tab");
1882
+ await page.waitForChanges();
1883
+ const activeElClass = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.className);
1884
+ expect(activeElClass).toContain("select-all-button");
1885
+ await page.keyboard.down("Shift");
1886
+ await page.keyboard.press("Tab");
1887
+ await page.waitForChanges();
1888
+ await page.keyboard.up("Shift");
1889
+ await page.waitForChanges();
1890
+ activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
1891
+ expect(activeElId).toBe("ic-select-input-0-menu");
1892
+ });
1893
+ it("should move focus from option (i.e. when option is highlighted) to 'Select all' button", async () => {
1894
+ const page = await newE2EPage();
1895
+ await page.setContent(getTestMultiSelect(options));
1896
+ await page.waitForChanges();
1897
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1898
+ await select.press("ArrowDown");
1899
+ await page.waitForChanges();
1900
+ const activeElId = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.id);
1901
+ expect(activeElId).toBe("ic-select-input-0-menu-Test value 1");
1902
+ await page.keyboard.press("Tab");
1903
+ await page.waitForChanges();
1904
+ const activeElClass = await page.$eval("ic-select-with-multi", (el) => el.shadowRoot.activeElement.className);
1905
+ expect(activeElClass).toContain("select-all-button");
1906
+ });
1907
+ it("should emit icChange when the 'Select all' button is pressed, and emit icOptionSelect only for unselected options", async () => {
1908
+ const page = await newE2EPage();
1909
+ await page.setContent(getTestMultiSelect(options));
1910
+ await page.waitForChanges();
1911
+ const icChange = await page.spyOnEvent("icChange");
1912
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1913
+ await select.press("ArrowDown");
1914
+ await page.waitForChanges();
1915
+ await page.keyboard.press("Enter");
1916
+ await page.waitForChanges();
1917
+ expect(icChange).toHaveReceivedEventDetail({
1918
+ value: ["Test value 1"],
1919
+ });
1920
+ await page.keyboard.press("Tab");
1921
+ await page.waitForChanges();
1922
+ const icOptionSelect = await page.spyOnEvent("icOptionSelect");
1923
+ await page.keyboard.press("Enter");
1924
+ await page.waitForChanges();
1925
+ expect(icChange).toHaveReceivedEventDetail({
1926
+ value: ["Test value 1", "Test value 2", "Test value 3"],
1927
+ });
1928
+ expect(icOptionSelect).toHaveReceivedEventTimes(2);
1929
+ });
1930
+ it("should emit icChange when the 'Clear all' button is pressed, and emit icOptionDeselect for all options", async () => {
1931
+ const page = await newE2EPage();
1932
+ await page.setContent(getTestMultiSelect(options));
1933
+ await page.waitForChanges();
1934
+ const icChange = await page.spyOnEvent("icChange");
1935
+ const icOptionDeselect = await page.spyOnEvent("icOptionDeselect");
1936
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1937
+ await select.press("ArrowDown");
1938
+ await page.waitForChanges();
1939
+ await page.keyboard.press("Enter");
1940
+ await page.keyboard.press("ArrowDown");
1941
+ await page.keyboard.press("Enter");
1942
+ await page.keyboard.press("ArrowDown");
1943
+ await page.keyboard.press("Enter");
1944
+ await page.waitForChanges();
1945
+ await page.keyboard.press("Tab");
1946
+ await page.keyboard.press("Enter");
1947
+ await page.waitForChanges();
1948
+ expect(icChange).toHaveReceivedEventDetail({
1949
+ value: null,
1950
+ });
1951
+ expect(icOptionDeselect).toHaveReceivedEventTimes(3);
1952
+ });
1953
+ it("should close menu when user tabs off 'Select all' button", async () => {
1954
+ const page = await newE2EPage();
1955
+ await page.setContent(getTestMultiSelect(options));
1956
+ await page.waitForChanges();
1957
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1958
+ await select.press("Enter");
1959
+ await page.waitForChanges();
1960
+ await page.keyboard.press("Tab");
1961
+ await page.waitForChanges();
1962
+ expect(await getMenuVisibility(page)).toBe("visible");
1963
+ await page.keyboard.press("Tab");
1964
+ await page.waitForChanges();
1965
+ expect(await getMenuVisibility(page)).toBe("hidden");
1966
+ });
1967
+ it("should select and clear all options on Ctrl+A", async () => {
1968
+ const page = await newE2EPage();
1969
+ await page.setContent(getTestMultiSelect(options));
1970
+ await page.waitForChanges();
1971
+ const icChange = await page.spyOnEvent("icChange");
1972
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1973
+ await select.press("Enter");
1974
+ await page.waitForChanges();
1975
+ await page.keyboard.down("Control");
1976
+ await page.keyboard.press("KeyA");
1977
+ await page.waitForChanges();
1978
+ await page.keyboard.up("Control");
1979
+ await page.waitForChanges();
1980
+ expect(icChange).toHaveReceivedEventDetail({
1981
+ value: ["Test value 1", "Test value 2", "Test value 3"],
1982
+ });
1983
+ await page.keyboard.down("Control");
1984
+ await page.keyboard.press("KeyA");
1985
+ await page.waitForChanges();
1986
+ await page.keyboard.up("Control");
1987
+ await page.waitForChanges();
1988
+ expect(icChange).toHaveReceivedEventDetail({
1989
+ value: null,
1990
+ });
1991
+ });
1992
+ it("should not select disabled options when the 'Select all' button is pressed", async () => {
1993
+ const page = await newE2EPage();
1994
+ await page.setContent(getTestMultiSelect(optionsWithDisabled));
1995
+ await page.waitForChanges();
1996
+ const icChange = await page.spyOnEvent("icChange");
1997
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
1998
+ await select.press("Enter");
1999
+ await page.waitForChanges();
2000
+ await page.keyboard.press("Tab");
2001
+ await page.keyboard.press("Enter");
2002
+ await page.waitForChanges();
2003
+ expect(icChange).toHaveReceivedEventDetail({
2004
+ value: ["Test value 2", "Test value 5"],
2005
+ });
2006
+ });
2007
+ it("should select all grouped options correctly", async () => {
2008
+ const page = await newE2EPage();
2009
+ await page.setContent(getTestMultiSelect(optionsWithGroups));
2010
+ await page.waitForChanges();
2011
+ const icChange = await page.spyOnEvent("icChange");
2012
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
2013
+ await select.press("Enter");
2014
+ await page.waitForChanges();
2015
+ await page.keyboard.press("Tab");
2016
+ await page.keyboard.press("Enter");
2017
+ await page.waitForChanges();
2018
+ expect(icChange).toHaveReceivedEventDetail({
2019
+ value: ["Test value 1", "Test value 2", "Test value 3"],
2020
+ });
2021
+ });
2022
+ it("should not reset focus back to the top of the menu when changing from clicking to using the keyboard", async () => {
2023
+ const page = await newE2EPage();
2024
+ await page.setContent(getTestMultiSelect(options));
2025
+ await page.waitForChanges();
2026
+ const select = await page.find("ic-select-with-multi >>> #ic-select-input-0");
2027
+ await select.press("ArrowDown");
2028
+ await page.waitForChanges();
2029
+ const menu = await page.find("ic-select-with-multi >>> #ic-select-input-0-menu");
2030
+ await menu.click();
2031
+ await page.waitForChanges();
2032
+ await page.keyboard.press("ArrowDown");
2033
+ await page.waitForChanges();
2034
+ const optionEls = await menu.findAll("li");
2035
+ expect(optionEls[0]).not.toHaveClass("focused-option");
2036
+ expect(optionEls[1]).toHaveClass("focused-option");
2037
+ });
2038
+ });
2039
+ });
2040
+ //# sourceMappingURL=ic-select.e2e.js.map