@mgdis/mg-components 5.15.0 → 5.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-fede8ee2.js → index-c042e24b.js} +321 -68
- package/dist/cjs/index-c042e24b.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +5 -12
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/{mg-action-more_32.cjs.entry.js → mg-action-more_34.cjs.entry.js} +341 -112
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -0
- package/dist/cjs/mg-components.cjs.js +5 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -0
- package/dist/cjs/mg-item-more.cjs.entry.js +8 -4
- package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -0
- package/dist/cjs/{mg-menu.conf-f9d0ddec.js → mg-menu.conf-43aacf30.js} +2 -0
- package/dist/cjs/mg-menu.conf-43aacf30.js.map +1 -0
- package/dist/collection/assets/icons/index.js +184 -0
- package/dist/collection/collection-manifest.json +37 -35
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +6 -4
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js +33 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js +70 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +10 -6
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js +91 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js +142 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js +1 -0
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +8 -5
- package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js +36 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js +43 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +3 -2
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js +15 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js +42 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +2 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js +11 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js +14 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js +55 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js +84 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +2 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js +18 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js +27 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +1 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +6 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js +37 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js +71 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.css +43 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +50 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +0 -43
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +64 -17
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js +132 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js +264 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +3 -2
- package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +12 -7
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +18 -12
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js +243 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +581 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +10 -8
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js +123 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js +324 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +46 -23
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js +212 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js +234 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js +154 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js +295 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +14 -9
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js +194 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js +344 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +12 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +280 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js +129 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js +255 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +6 -4
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js +125 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js +203 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +9 -5
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js +268 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js +175 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +12 -9
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js +119 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js +295 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +27 -14
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js +128 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js +187 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +3 -2
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js +30 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js +42 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +17 -7
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js +169 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js +277 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +3 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js +39 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js +36 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +15 -9
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js +85 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js +106 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +7 -5
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js +64 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js +109 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.conf.js +5 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +42 -8
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js +62 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js +40 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js +26 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js +122 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +5 -4
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js +57 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js +121 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +10 -7
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js +106 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js +223 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.css +135 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +101 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +0 -111
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +47 -46
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js +148 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js +130 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +5 -3
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js +55 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js +55 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +8 -5
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js +76 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js +332 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js.map +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/locales/index.js +4 -3
- package/dist/collection/locales/index.js.map +1 -0
- package/dist/collection/locales/index.spec.js +27 -0
- package/dist/collection/locales/index.spec.js.map +1 -0
- package/dist/collection/stories/icon-gallery.js +4 -3
- package/dist/collection/stories/icon-gallery.js.map +1 -0
- package/dist/collection/test/typography.e2e.playwright.js +12 -0
- package/dist/collection/test/typography.e2e.playwright.js.map +1 -0
- package/dist/collection/utils/behaviors.utils.js +1 -0
- package/dist/collection/utils/behaviors.utils.js.map +1 -0
- package/dist/collection/utils/behaviors.utils.spec.js +57 -0
- package/dist/collection/utils/behaviors.utils.spec.js.map +1 -0
- package/dist/collection/utils/components.utils.js +9 -7
- package/dist/collection/utils/components.utils.js.map +1 -0
- package/dist/collection/utils/components.utils.spec.js +120 -0
- package/dist/collection/utils/components.utils.spec.js.map +1 -0
- package/dist/collection/utils/e2e.test.utils.js +46 -0
- package/dist/collection/utils/e2e.test.utils.js.map +1 -0
- package/dist/collection/utils/locale.utils.js +1 -0
- package/dist/collection/utils/locale.utils.js.map +1 -0
- package/dist/collection/utils/locale.utils.spec.js +52 -0
- package/dist/collection/utils/locale.utils.spec.js.map +1 -0
- package/dist/collection/utils/playwright.e2e.test.utils.js +100 -0
- package/dist/collection/utils/playwright.e2e.test.utils.js.map +1 -0
- package/dist/collection/utils/stencil.e2e.test.utils.js +33 -0
- package/dist/collection/utils/stencil.e2e.test.utils.js.map +1 -0
- package/dist/collection/utils/unit.test.utils.js +8 -6
- package/dist/collection/utils/unit.test.utils.js.map +1 -0
- package/dist/components/MgInput.js +2 -0
- package/dist/components/MgInput.js.map +1 -0
- package/dist/components/components.utils.js +10 -7
- package/dist/components/components.utils.js.map +1 -0
- package/dist/components/index.d.ts +5 -35
- package/dist/components/index.js +3 -34
- package/dist/components/index.js.map +1 -0
- package/dist/components/index2.js +2 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/mg-action-more.js +42 -19
- package/dist/components/mg-action-more.js.map +1 -0
- package/dist/components/mg-badge.js +2 -0
- package/dist/components/mg-badge.js.map +1 -0
- package/dist/components/mg-badge2.js +8 -1
- package/dist/components/mg-badge2.js.map +1 -0
- package/dist/components/mg-button.js +2 -0
- package/dist/components/mg-button.js.map +1 -0
- package/dist/components/mg-button2.js +8 -1
- package/dist/components/mg-button2.js.map +1 -0
- package/dist/components/mg-card.js +2 -0
- package/dist/components/mg-card.js.map +1 -0
- package/dist/components/mg-card2.js +6 -1
- package/dist/components/mg-card2.js.map +1 -0
- package/dist/components/mg-character-left.js +2 -0
- package/dist/components/mg-character-left.js.map +1 -0
- package/dist/components/mg-character-left2.js +5 -1
- package/dist/components/mg-character-left2.js.map +1 -0
- package/dist/components/mg-details.js +8 -2
- package/dist/components/mg-details.js.map +1 -0
- package/dist/components/mg-divider.js +3 -1
- package/dist/components/mg-divider.js.map +1 -0
- package/dist/components/mg-form.js +17 -4
- package/dist/components/mg-form.js.map +1 -0
- package/dist/components/mg-icon.js +2 -0
- package/dist/components/mg-icon.js.map +1 -0
- package/dist/components/mg-icon2.js +87 -17
- package/dist/components/mg-icon2.js.map +1 -0
- package/dist/components/mg-illustrated-message.js +3 -1
- package/dist/components/mg-illustrated-message.js.map +1 -0
- package/dist/components/mg-input-checkbox-paginated.js +2 -0
- package/dist/components/mg-input-checkbox-paginated.js.map +1 -0
- package/dist/components/mg-input-checkbox-paginated2.js +24 -13
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -0
- package/dist/components/mg-input-checkbox.js +48 -25
- package/dist/components/mg-input-checkbox.js.map +1 -0
- package/dist/components/mg-input-date.js +23 -8
- package/dist/components/mg-input-date.js.map +1 -0
- package/dist/components/mg-input-numeric.js +58 -22
- package/dist/components/mg-input-numeric.js.map +1 -0
- package/dist/components/mg-input-password.js +21 -8
- package/dist/components/mg-input-password.js.map +1 -0
- package/dist/components/mg-input-radio.js +22 -8
- package/dist/components/mg-input-radio.js.map +1 -0
- package/dist/components/mg-input-select.js +2 -0
- package/dist/components/mg-input-select.js.map +1 -0
- package/dist/components/mg-input-select2.js +22 -8
- package/dist/components/mg-input-select2.js.map +1 -0
- package/dist/components/mg-input-text.js +2 -0
- package/dist/components/mg-input-text.js.map +1 -0
- package/dist/components/mg-input-text2.js +24 -10
- package/dist/components/mg-input-text2.js.map +1 -0
- package/dist/components/mg-input-textarea.js +24 -10
- package/dist/components/mg-input-textarea.js.map +1 -0
- package/dist/components/mg-input-title.js +2 -0
- package/dist/components/mg-input-title.js.map +1 -0
- package/dist/components/mg-input-title2.js +6 -1
- package/dist/components/mg-input-title2.js.map +1 -0
- package/dist/components/mg-input-toggle.js +23 -7
- package/dist/components/mg-input-toggle.js.map +1 -0
- package/dist/components/mg-item-more.js +31 -17
- package/dist/components/mg-item-more.js.map +1 -0
- package/dist/components/mg-menu-item.js +2 -0
- package/dist/components/mg-menu-item.js.map +1 -0
- package/dist/components/mg-menu-item2.js +27 -13
- package/dist/components/mg-menu-item2.js.map +1 -0
- package/dist/components/mg-menu.conf.js +2 -0
- package/dist/components/mg-menu.conf.js.map +1 -0
- package/dist/components/mg-menu.js +2 -0
- package/dist/components/mg-menu.js.map +1 -0
- package/dist/components/mg-menu2.js +8 -1
- package/dist/components/mg-menu2.js.map +1 -0
- package/dist/components/mg-message.js +8 -1
- package/dist/components/mg-message.js.map +1 -0
- package/dist/components/mg-modal.js +24 -5
- package/dist/components/mg-modal.js.map +1 -0
- package/dist/components/mg-pagination.js +2 -0
- package/dist/components/mg-pagination.js.map +1 -0
- package/dist/components/mg-pagination2.js +22 -11
- package/dist/components/mg-pagination2.js.map +1 -0
- package/dist/components/mg-panel.js +30 -16
- package/dist/components/mg-panel.js.map +1 -0
- package/dist/components/mg-popover-content.d.ts +11 -0
- package/dist/components/mg-popover-content.js +8 -0
- package/dist/components/mg-popover-content.js.map +1 -0
- package/dist/components/mg-popover-content2.js +90 -0
- package/dist/components/mg-popover-content2.js.map +1 -0
- package/dist/components/mg-popover.js +2 -0
- package/dist/components/mg-popover.js.map +1 -0
- package/dist/components/mg-popover2.js +61 -48
- package/dist/components/mg-popover2.js.map +1 -0
- package/dist/components/mg-skip-links.js +5 -1
- package/dist/components/mg-skip-links.js.map +1 -0
- package/dist/components/mg-tabs.js +8 -1
- package/dist/components/mg-tabs.js.map +1 -0
- package/dist/components/mg-tag.js +7 -1
- package/dist/components/mg-tag.js.map +1 -0
- package/dist/components/mg-tooltip-content.d.ts +11 -0
- package/dist/components/mg-tooltip-content.js +8 -0
- package/dist/components/mg-tooltip-content.js.map +1 -0
- package/dist/components/mg-tooltip-content2.js +43 -0
- package/dist/components/mg-tooltip-content2.js.map +1 -0
- package/dist/components/mg-tooltip.js +2 -0
- package/dist/components/mg-tooltip.js.map +1 -0
- package/dist/components/mg-tooltip2.js +71 -16
- package/dist/components/mg-tooltip2.js.map +1 -0
- package/dist/components/popper.js +2 -0
- package/dist/components/popper.js.map +1 -0
- package/dist/esm/{index-1d40b052.js → index-ce01e63b.js} +321 -68
- package/dist/esm/index-ce01e63b.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +6 -13
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/{mg-action-more_32.entry.js → mg-action-more_34.entry.js} +340 -113
- package/dist/esm/mg-action-more_34.entry.js.map +1 -0
- package/dist/esm/mg-components.js +6 -4
- package/dist/esm/mg-components.js.map +1 -0
- package/dist/esm/mg-item-more.entry.js +8 -4
- package/dist/esm/mg-item-more.entry.js.map +1 -0
- package/dist/esm/{mg-menu.conf-2cc079ae.js → mg-menu.conf-012fc9b4.js} +2 -0
- package/dist/esm/mg-menu.conf-012fc9b4.js.map +1 -0
- package/dist/mg-components/index.esm.js +2 -0
- package/dist/mg-components/index.esm.js.map +1 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +2 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -0
- package/dist/mg-components/p-1aa89acf.js +3 -0
- package/dist/mg-components/p-1aa89acf.js.map +1 -0
- package/dist/mg-components/p-1d7d6fa0.js +2 -0
- package/dist/mg-components/p-1d7d6fa0.js.map +1 -0
- package/dist/mg-components/p-9257e8f1.entry.js +2 -0
- package/dist/mg-components/p-9257e8f1.entry.js.map +1 -0
- package/dist/mg-components/p-caafc9cf.entry.js +2 -0
- package/dist/mg-components/p-caafc9cf.entry.js.map +1 -0
- package/dist/types/components/atoms/mg-badge/test/mg-badge.e2e.playwright.d.ts +1 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +19 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +6 -1
- package/dist/types/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.d.ts +2 -0
- package/dist/types/components/molecules/mg-details/test/mg-details.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +8 -0
- package/dist/types/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +8 -2
- package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.template.d.ts +12 -0
- package/dist/types/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-panel/test/mg-panel.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +47 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +8 -11
- package/dist/types/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.d.ts +1 -0
- package/dist/types/components.d.ts +79 -0
- package/dist/types/stencil-public-runtime.d.ts +43 -17
- package/dist/types/test/typography.e2e.playwright.d.ts +1 -0
- package/dist/types/utils/e2e.test.utils.d.ts +22 -0
- package/dist/types/utils/stencil.e2e.test.utils.d.ts +14 -0
- package/loader/index.d.ts +2 -2
- package/package.json +7 -7
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/mg-components/p-067080e4.js +0 -1
- package/dist/mg-components/p-3bf1e2f0.js +0 -2
- package/dist/mg-components/p-4ae1130f.entry.js +0 -1
- package/dist/mg-components/p-6672f590.entry.js +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
3
|
+
import { MgMessage } from "../mg-message";
|
|
4
|
+
import { variants } from "../mg-message.conf";
|
|
5
|
+
const getDefaultContent = () => (h("p", null, h("strong", null, "Strong"), " content!"));
|
|
6
|
+
const getPage = (args, content) => newSpecPage({
|
|
7
|
+
components: [MgMessage],
|
|
8
|
+
template: () => h("mg-message", Object.assign({}, args), content),
|
|
9
|
+
});
|
|
10
|
+
describe('mg-message', () => {
|
|
11
|
+
describe.each(variants)('Should render a %s message', variant => {
|
|
12
|
+
test.each([
|
|
13
|
+
{ identifier: 'identifier' },
|
|
14
|
+
{ identifier: 'identifier', closeButton: true },
|
|
15
|
+
{ identifier: 'identifier', closeButton: true, lang: 'fr' },
|
|
16
|
+
{ identifier: 'identifier', closeButton: true, lang: 'xx' },
|
|
17
|
+
])('with args %s', async (args) => {
|
|
18
|
+
const { root } = await getPage(Object.assign(Object.assign({}, args), { variant }), getDefaultContent());
|
|
19
|
+
expect(root).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
test('Should replace classes on variant changes', async () => {
|
|
23
|
+
const page = await getPage({ identifier: 'identifier' }, getDefaultContent());
|
|
24
|
+
const element = page.doc.querySelector('mg-message');
|
|
25
|
+
let classInfo = element.shadowRoot.querySelector('.mg-message--info');
|
|
26
|
+
expect(classInfo).not.toBeNull();
|
|
27
|
+
element.variant = 'danger';
|
|
28
|
+
await page.waitForChanges();
|
|
29
|
+
classInfo = element.shadowRoot.querySelector('.mg-message--info');
|
|
30
|
+
const classDanger = element.shadowRoot.querySelector('.mg-message--danger');
|
|
31
|
+
expect(classInfo).toBeNull();
|
|
32
|
+
expect(classDanger).not.toBeNull();
|
|
33
|
+
});
|
|
34
|
+
test.each(['', 'blu'])('Should throw error with invalid variant property: %s', async (variant) => {
|
|
35
|
+
expect.assertions(1);
|
|
36
|
+
try {
|
|
37
|
+
await getPage({ identifier: 'identifier', variant }, getDefaultContent());
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
expect(err.message).toMatch('<mg-message> prop "variant" must be one of:');
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
test('Should throw error with invalid delay property: 50ms', async () => {
|
|
44
|
+
expect.assertions(1);
|
|
45
|
+
try {
|
|
46
|
+
await getPage({ identifier: 'identifier', delay: 1 }, getDefaultContent());
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
expect(err.message).toMatch('<mg-message> prop "delay" must be greater than 2 seconds.');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
test('Should throw error when using prop "close-button" with an action slot', async () => {
|
|
53
|
+
expect.assertions(1);
|
|
54
|
+
try {
|
|
55
|
+
await getPage({ identifier: 'identifier', closeButton: true }, [
|
|
56
|
+
getDefaultContent(),
|
|
57
|
+
h("div", { slot: "actions", class: "mg-group-elements mg-group-elements--align-right" }, h("mg-button", null, "Primary"), h("mg-button", { variant: "secondary" }, "Secondary")),
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
expect(err.message).toMatch('<mg-message> prop "close-button" can\'t be used with the actions slot.');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
test('Should hide message on close button', async () => {
|
|
65
|
+
const args = { identifier: 'identifier', closeButton: true };
|
|
66
|
+
const page = await getPage(args, getDefaultContent());
|
|
67
|
+
const element = page.doc.querySelector('mg-message');
|
|
68
|
+
const button = element.shadowRoot.querySelector('mg-button');
|
|
69
|
+
jest.spyOn(page.rootInstance.componentHide, 'emit');
|
|
70
|
+
button.dispatchEvent(new CustomEvent('click', { bubbles: true }));
|
|
71
|
+
await page.waitForChanges();
|
|
72
|
+
expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(1);
|
|
73
|
+
expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');
|
|
74
|
+
});
|
|
75
|
+
test('Should hide message on delay', async () => {
|
|
76
|
+
const args = { identifier: 'identifier', delay: 2 };
|
|
77
|
+
const page = await getPage(args, getDefaultContent());
|
|
78
|
+
jest.spyOn(page.rootInstance.componentHide, 'emit');
|
|
79
|
+
jest.spyOn(page.rootInstance.componentShow, 'emit');
|
|
80
|
+
expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');
|
|
81
|
+
jest.advanceTimersByTime(args.delay * 1000);
|
|
82
|
+
expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');
|
|
83
|
+
expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(1);
|
|
84
|
+
page.rootInstance.hide = false;
|
|
85
|
+
await page.waitForChanges();
|
|
86
|
+
expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');
|
|
87
|
+
expect(page.rootInstance.componentShow.emit).toHaveBeenCalledTimes(1);
|
|
88
|
+
jest.advanceTimersByTime(args.delay * 1000);
|
|
89
|
+
expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');
|
|
90
|
+
expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(2);
|
|
91
|
+
});
|
|
92
|
+
test.each(['focus', 'mouse'])('Should manage event %s with delay', async (eventType) => {
|
|
93
|
+
const args = { identifier: 'identifier', delay: 2 };
|
|
94
|
+
const page = await getPage(args, getDefaultContent());
|
|
95
|
+
jest.spyOn(page.rootInstance.componentHide, 'emit');
|
|
96
|
+
jest.spyOn(page.rootInstance.componentShow, 'emit');
|
|
97
|
+
const element = page.doc.querySelector('mg-message');
|
|
98
|
+
expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');
|
|
99
|
+
jest.advanceTimersByTime((args.delay / 2) * 1000);
|
|
100
|
+
element.dispatchEvent(eventType === 'focus' ? new FocusEvent('focusin') : new MouseEvent('mouseenter'));
|
|
101
|
+
jest.advanceTimersByTime(args.delay * 1000);
|
|
102
|
+
expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');
|
|
103
|
+
element.dispatchEvent(eventType === 'focus' ? new FocusEvent('focusout') : new MouseEvent('mouseleave'));
|
|
104
|
+
jest.advanceTimersByTime(args.delay * 1000);
|
|
105
|
+
expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');
|
|
106
|
+
expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(1);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=mg-message.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-message.spec.js","sourceRoot":"","sources":["../../../../../src/components/molecules/mg-message/test/mg-message.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,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,CAAC,GAAG,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,aAAa,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;IAExG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAE5C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAEnF,OAAO,CAAC,aAAa,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAE5C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC/E,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;EACxE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { h } from '@stencil/core';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { MgMessage } from '../mg-message';\nimport { variants } from '../mg-message.conf';\n\nconst getDefaultContent = () => (\n <p>\n <strong>Strong</strong> content!\n </p>\n);\n\nconst getPage = (args, content) =>\n newSpecPage({\n components: [MgMessage],\n template: () => <mg-message {...args}>{content}</mg-message>,\n });\n\ndescribe('mg-message', () => {\n describe.each(variants)('Should render a %s message', variant => {\n test.each([\n { identifier: 'identifier' },\n { identifier: 'identifier', closeButton: true },\n { identifier: 'identifier', closeButton: true, lang: 'fr' },\n { identifier: 'identifier', closeButton: true, lang: 'xx' },\n ])('with args %s', async args => {\n const { root } = await getPage({ ...args, variant }, getDefaultContent());\n expect(root).toMatchSnapshot();\n });\n });\n\n test('Should replace classes on variant changes', async () => {\n const page = await getPage({ identifier: 'identifier' }, getDefaultContent());\n const element = page.doc.querySelector('mg-message');\n let classInfo = element.shadowRoot.querySelector('.mg-message--info');\n\n expect(classInfo).not.toBeNull();\n\n element.variant = 'danger';\n await page.waitForChanges();\n\n classInfo = element.shadowRoot.querySelector('.mg-message--info');\n const classDanger = element.shadowRoot.querySelector('.mg-message--danger');\n\n expect(classInfo).toBeNull();\n expect(classDanger).not.toBeNull();\n });\n\n test.each(['', 'blu'])('Should throw error with invalid variant property: %s', async variant => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', variant }, getDefaultContent());\n } catch (err) {\n expect(err.message).toMatch('<mg-message> prop \"variant\" must be one of:');\n }\n });\n\n test('Should throw error with invalid delay property: 50ms', async () => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', delay: 1 }, getDefaultContent());\n } catch (err) {\n expect(err.message).toMatch('<mg-message> prop \"delay\" must be greater than 2 seconds.');\n }\n });\n\n test('Should throw error when using prop \"close-button\" with an action slot', async () => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', closeButton: true }, [\n getDefaultContent(),\n <div slot=\"actions\" class=\"mg-group-elements mg-group-elements--align-right\">\n <mg-button>Primary</mg-button>\n <mg-button variant=\"secondary\">Secondary</mg-button>\n </div>,\n ]);\n } catch (err) {\n expect(err.message).toMatch('<mg-message> prop \"close-button\" can\\'t be used with the actions slot.');\n }\n });\n\n test('Should hide message on close button', async () => {\n const args = { identifier: 'identifier', closeButton: true };\n const page = await getPage(args, getDefaultContent());\n\n const element = page.doc.querySelector('mg-message');\n const button = element.shadowRoot.querySelector('mg-button');\n\n jest.spyOn(page.rootInstance.componentHide, 'emit');\n\n button.dispatchEvent(new CustomEvent('click', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(1);\n expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');\n });\n\n test('Should hide message on delay', async () => {\n const args = { identifier: 'identifier', delay: 2 };\n const page = await getPage(args, getDefaultContent());\n\n jest.spyOn(page.rootInstance.componentHide, 'emit');\n jest.spyOn(page.rootInstance.componentShow, 'emit');\n\n expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');\n\n jest.advanceTimersByTime(args.delay * 1000);\n\n expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');\n expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(1);\n\n page.rootInstance.hide = false;\n await page.waitForChanges();\n\n expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');\n expect(page.rootInstance.componentShow.emit).toHaveBeenCalledTimes(1);\n\n jest.advanceTimersByTime(args.delay * 1000);\n\n expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');\n expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(2);\n });\n\n test.each(['focus', 'mouse'])('Should manage event %s with delay', async eventType => {\n const args = { identifier: 'identifier', delay: 2 };\n const page = await getPage(args, getDefaultContent());\n\n jest.spyOn(page.rootInstance.componentHide, 'emit');\n jest.spyOn(page.rootInstance.componentShow, 'emit');\n\n const element = page.doc.querySelector('mg-message');\n\n expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');\n\n jest.advanceTimersByTime((args.delay / 2) * 1000);\n\n element.dispatchEvent(eventType === 'focus' ? new FocusEvent('focusin') : new MouseEvent('mouseenter'));\n\n jest.advanceTimersByTime(args.delay * 1000);\n\n expect(page.rootInstance.classCollection.join()).not.toContain('mg-message--hide');\n\n element.dispatchEvent(eventType === 'focus' ? new FocusEvent('focusout') : new MouseEvent('mouseleave'));\n\n jest.advanceTimersByTime(args.delay * 1000);\n\n expect(page.rootInstance.classCollection.join()).toContain('mg-message--hide');\n expect(page.rootInstance.componentHide.emit).toHaveBeenCalledTimes(1);\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-modal.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-modal/mg-modal.conf.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAU,CAAC","sourcesContent":["/**\n * List of all possibles dialog roles\n */\nexport const dialogRoles = ['dialog', 'alertdialog'] as const;\n\n/**\n * DialogRole type from dialog roles\n */\nexport type DialogRoleType = (typeof dialogRoles)[number];\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { h } from
|
|
2
|
-
import { createID, ClassList, focusableElements } from
|
|
3
|
-
import { initLocales } from
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { createID, ClassList, focusableElements } from "../../../utils/components.utils";
|
|
3
|
+
import { initLocales } from "../../../locales";
|
|
4
|
+
import { dialogRoles } from "./mg-modal.conf";
|
|
4
5
|
export class MgModal {
|
|
5
6
|
constructor() {
|
|
6
7
|
/************
|
|
@@ -69,13 +70,18 @@ export class MgModal {
|
|
|
69
70
|
this.hide = true;
|
|
70
71
|
};
|
|
71
72
|
this.identifier = createID('mg-modal');
|
|
73
|
+
this.dialogRole = dialogRoles[0];
|
|
72
74
|
this.modalTitle = undefined;
|
|
73
75
|
this.closeButton = false;
|
|
74
|
-
this.hide =
|
|
76
|
+
this.hide = undefined;
|
|
75
77
|
this.hasActions = false;
|
|
76
78
|
this.hasContent = false;
|
|
77
79
|
this.classCollection = new ClassList(['mg-modal']);
|
|
78
80
|
}
|
|
81
|
+
validateDialogRole(newValue) {
|
|
82
|
+
if (!dialogRoles.includes(newValue))
|
|
83
|
+
throw new Error(`<mg-modal> prop "dialogRole" must be one of: ${dialogRoles.join(', ')}.`);
|
|
84
|
+
}
|
|
79
85
|
validateModalTitle(newValue) {
|
|
80
86
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
81
87
|
throw new Error('<mg-modal> prop "modalTitle" is required.');
|
|
@@ -92,7 +98,7 @@ export class MgModal {
|
|
|
92
98
|
if (this.modalFocusableElements.length > 0)
|
|
93
99
|
this.modalFocusableElements[0].removeEventListener('keydown', this.handleFirstFocusableElement);
|
|
94
100
|
}
|
|
95
|
-
else {
|
|
101
|
+
else if (newValue === false) {
|
|
96
102
|
this.componentShow.emit();
|
|
97
103
|
this.classCollection.delete(this.classHide);
|
|
98
104
|
document.body.style.overflow = 'hidden';
|
|
@@ -126,6 +132,7 @@ export class MgModal {
|
|
|
126
132
|
this.titleId = `${this.identifier}-title`;
|
|
127
133
|
this.validateModalTitle(this.modalTitle);
|
|
128
134
|
this.validateHide(this.hide);
|
|
135
|
+
this.validateDialogRole(this.dialogRole);
|
|
129
136
|
}
|
|
130
137
|
/**
|
|
131
138
|
* Add observer on component to set focus when displayed
|
|
@@ -144,7 +151,7 @@ export class MgModal {
|
|
|
144
151
|
* @returns HTML Element
|
|
145
152
|
*/
|
|
146
153
|
render() {
|
|
147
|
-
return (h("div", { role:
|
|
154
|
+
return (h("div", { role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: `${this.identifier}-close-button`, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose, ref: (el) => {
|
|
148
155
|
if (el !== null) {
|
|
149
156
|
// store closeButton Element
|
|
150
157
|
this.closeButtonElement = el;
|
|
@@ -185,6 +192,30 @@ export class MgModal {
|
|
|
185
192
|
"reflect": false,
|
|
186
193
|
"defaultValue": "createID('mg-modal')"
|
|
187
194
|
},
|
|
195
|
+
"dialogRole": {
|
|
196
|
+
"type": "string",
|
|
197
|
+
"mutable": false,
|
|
198
|
+
"complexType": {
|
|
199
|
+
"original": "DialogRoleType",
|
|
200
|
+
"resolved": "\"alertdialog\" | \"dialog\"",
|
|
201
|
+
"references": {
|
|
202
|
+
"DialogRoleType": {
|
|
203
|
+
"location": "import",
|
|
204
|
+
"path": "./mg-modal.conf",
|
|
205
|
+
"id": "src/components/molecules/mg-modal/mg-modal.conf.ts::DialogRoleType"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
"required": false,
|
|
210
|
+
"optional": false,
|
|
211
|
+
"docs": {
|
|
212
|
+
"tags": [],
|
|
213
|
+
"text": "Modal dialog role."
|
|
214
|
+
},
|
|
215
|
+
"attribute": "dialog-role",
|
|
216
|
+
"reflect": false,
|
|
217
|
+
"defaultValue": "dialogRoles[0]"
|
|
218
|
+
},
|
|
188
219
|
"modalTitle": {
|
|
189
220
|
"type": "string",
|
|
190
221
|
"mutable": false,
|
|
@@ -235,8 +266,7 @@ export class MgModal {
|
|
|
235
266
|
"text": "Define if modal is hidden"
|
|
236
267
|
},
|
|
237
268
|
"attribute": "hide",
|
|
238
|
-
"reflect": false
|
|
239
|
-
"defaultValue": "false"
|
|
269
|
+
"reflect": false
|
|
240
270
|
}
|
|
241
271
|
};
|
|
242
272
|
}
|
|
@@ -283,6 +313,9 @@ export class MgModal {
|
|
|
283
313
|
static get elementRef() { return "element"; }
|
|
284
314
|
static get watchers() {
|
|
285
315
|
return [{
|
|
316
|
+
"propName": "dialogRole",
|
|
317
|
+
"methodName": "validateDialogRole"
|
|
318
|
+
}, {
|
|
286
319
|
"propName": "modalTitle",
|
|
287
320
|
"methodName": "validateModalTitle"
|
|
288
321
|
}, {
|
|
@@ -300,3 +333,4 @@ export class MgModal {
|
|
|
300
333
|
}];
|
|
301
334
|
}
|
|
302
335
|
}
|
|
336
|
+
//# sourceMappingURL=mg-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-modal.js","sourceRoot":"","sources":["../../../../src/components/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EAAC,EAAE,EAAE,IAAI,CAAC,OAAO,IACzC,IAAI,CAAC,UAAU,CACb,CACE;UAER,IAAI,CAAC,UAAU,IAAI,CAClB,eAAS,KAAK,EAAC,mBAAmB;YAChC,YAAM,IAAI,EAAC,SAAS,GAAQ,CACpB,CACX;UAEA,IAAI,CAAC,UAAU,IAAI,CAClB,cAAQ,KAAK,EAAC,kBAAkB;YAC9B,YAAM,IAAI,EAAC,SAAS,GAAQ,CACrB,CACV,CACG,CACE,CACN,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch, Element, Event, EventEmitter, Listen } from '@stencil/core';\nimport { createID, ClassList, focusableElements } from '../../../utils/components.utils';\nimport { initLocales } from '../../../locales';\nimport { DialogRoleType, dialogRoles } from './mg-modal.conf';\n\n@Component({\n tag: 'mg-modal',\n styleUrl: 'mg-modal.scss',\n shadow: true,\n})\nexport class MgModal {\n /************\n * Internal *\n ************/\n\n // Modal focusable elements\n private modalFocusableElements: HTMLElement[] = [];\n private closeButtonElement: HTMLMgButtonElement;\n\n // Classes\n private readonly classHide = 'mg-modal--hide';\n\n // IDs\n private titleId = '';\n\n // Locales\n private messages;\n\n // body overflow default\n private bodyOverflow: string;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgModalElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-modal');\n\n /**\n * Modal dialog role.\n */\n @Prop() dialogRole: DialogRoleType = dialogRoles[0];\n @Watch('dialogRole')\n validateDialogRole(newValue: MgModal['dialogRole']): void {\n if (!dialogRoles.includes(newValue)) throw new Error(`<mg-modal> prop \"dialogRole\" must be one of: ${dialogRoles.join(', ')}.`);\n }\n\n /**\n * Displayed modal title\n */\n @Prop() modalTitle!: string;\n @Watch('modalTitle')\n validateModalTitle(newValue: MgModal['modalTitle']): void {\n if (typeof newValue !== 'string' || newValue.trim() === '') {\n throw new Error('<mg-modal> prop \"modalTitle\" is required.');\n }\n }\n\n /**\n * Define if modal has a cross button\n */\n @Prop() closeButton = false;\n\n /**\n * Define if modal is hidden\n */\n @Prop({ mutable: true }) hide: boolean;\n @Watch('hide')\n validateHide(newValue: MgModal['hide']): void {\n if (newValue) {\n this.componentHide.emit();\n this.classCollection.add(this.classHide);\n document.body.style.overflow = this.bodyOverflow;\n // reset focus handlers\n this.getLastFocusableElement()?.removeEventListener('keydown', this.handleLastFocusableElement);\n if (this.modalFocusableElements.length > 0) this.modalFocusableElements[0].removeEventListener('keydown', this.handleFirstFocusableElement);\n } else if (newValue === false) {\n this.componentShow.emit();\n this.classCollection.delete(this.classHide);\n document.body.style.overflow = 'hidden';\n this.setFocus();\n }\n }\n\n /**\n * Define if component is using actions slot\n */\n @State() hasActions = false;\n\n /**\n * Define if component is using content slot\n */\n @State() hasContent = false;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-modal']);\n\n /**\n * Emmited event when modal is diplayed\n */\n @Event({ eventName: 'component-show' }) componentShow: EventEmitter<string>;\n\n /**\n * Emmited event when modal is hidden\n */\n @Event({ eventName: 'component-hide' }) componentHide: EventEmitter<string>;\n\n /**\n * Handle 'escape' key down\n * @param event - keydown event\n */\n @Listen('keydown', {\n target: 'window',\n })\n handleKeyDown(event: KeyboardEvent): void {\n // we can use 'Escape button\" when this not a blocking modal, induced by closeButton value.\n if (this.closeButton && event.key === 'Escape') {\n this.hide = true;\n }\n }\n\n /**\n * Handle last focusable element\n * @param event - keyboard event\n */\n private handleLastFocusableElement = (event): void => {\n if (event.key === 'Tab' && !event.shiftKey) {\n event.preventDefault();\n this.modalFocusableElements[0].focus();\n }\n };\n\n /**\n * Handle first focusable element\n * @param event - keyboard event\n */\n private handleFirstFocusableElement = (event): void => {\n if (event.key === 'Tab' && event.shiftKey) {\n event.preventDefault();\n this.getLastFocusableElement().focus();\n }\n };\n\n /**\n * Get last focusablmeElement\n * @returns last modal focusable element\n */\n private getLastFocusableElement = (): HTMLElement | null => (this.modalFocusableElements.length > 0 ? this.modalFocusableElements[this.modalFocusableElements.length - 1] : null);\n\n /**\n * Method to manage focus on modal focusable elements\n */\n private setFocus = (): void => {\n // Get all focusable elements\n const allFocusableElements = Array.from(this.element.querySelectorAll(focusableElements));\n // If at least one\n if (allFocusableElements.length > 0) {\n this.modalFocusableElements = allFocusableElements.reduce((acc, focusableElement) => {\n acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);\n return acc;\n }, []);\n // When close button is enabled it's the first focusable element.\n if (this.closeButton && this.closeButtonElement !== undefined) {\n this.modalFocusableElements.unshift(this.closeButtonElement);\n }\n // Add event listener on last element\n this.getLastFocusableElement().addEventListener('keydown', this.handleLastFocusableElement);\n // Add event listener on first element (case shift + tab)\n this.modalFocusableElements[0].addEventListener('keydown', this.handleFirstFocusableElement);\n }\n };\n\n /*************\n * Handlers *\n *************/\n\n /**\n * Handle close button\n */\n private handleClose = (): void => {\n this.hide = true;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Store body overflow\n this.bodyOverflow = document.body.style.overflow;\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Validate\n this.hasActions = this.element.querySelector('[slot=\"actions\"]') !== null;\n this.hasContent = this.element.querySelector('[slot=\"content\"]') !== null;\n this.titleId = `${this.identifier}-title`;\n this.validateModalTitle(this.modalTitle);\n this.validateHide(this.hide);\n this.validateDialogRole(this.dialogRole);\n }\n\n /**\n * Add observer on component to set focus when displayed\n */\n componentDidLoad(): void {\n new MutationObserver(mutationList => {\n // as mutation.target is null on chrome and '' or undefined on firefox we test both with the 'aria-hidden' attribute mutation\n if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && ['', null, undefined].includes((mutation.target as HTMLElement).ariaHidden))) {\n // Set focus on first element\n this.modalFocusableElements[0].focus();\n }\n }).observe(this.element.shadowRoot.getElementById(this.identifier), { attributes: true });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div role={this.dialogRole} id={this.identifier} class={this.classCollection.join()} tabindex=\"-1\" aria-labelledby={this.titleId} aria-modal=\"true\" aria-hidden={this.hide}>\n <mg-card>\n <div class=\"mg-modal__dialog\">\n <header class=\"mg-modal__header\">\n {this.closeButton && (\n <span class=\"mg-modal__close-button\">\n <mg-button\n identifier={`${this.identifier}-close-button`}\n is-icon\n variant=\"flat\"\n label={this.messages.modal.closeButton}\n onClick={this.handleClose}\n ref={(el: HTMLMgButtonElement) => {\n if (el !== null) {\n // store closeButton Element\n this.closeButtonElement = el;\n // add close button element to modalFocusableElements when it is render\n this.modalFocusableElements.unshift(this.closeButtonElement);\n }\n }}\n >\n <mg-icon icon=\"cross\"></mg-icon>\n </mg-button>\n </span>\n )}\n <h1 class=\"mg-modal__title\" id={this.titleId}>\n {this.modalTitle}\n </h1>\n </header>\n\n {this.hasContent && (\n <article class=\"mg-modal__content\">\n <slot name=\"content\"></slot>\n </article>\n )}\n\n {this.hasActions && (\n <footer class=\"mg-modal__footer\">\n <slot name=\"actions\"></slot>\n </footer>\n )}\n </div>\n </mg-card>\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { setPageContent, expect, describe, describeEach, testEach, test } from "../../../../utils/playwright.e2e.test.utils";
|
|
2
|
+
import { actions, contents, createHTML } from "./mg-modal.e2e.template";
|
|
3
|
+
describe('mg-modal', () => {
|
|
4
|
+
const slotsToTests = actions.flatMap(action => contents.map(content => ({ action, content })));
|
|
5
|
+
describeEach(slotsToTests)('render whith slots %s', slots => {
|
|
6
|
+
testEach([
|
|
7
|
+
{ closeButton: false, hide: false },
|
|
8
|
+
{ closeButton: true, hide: false },
|
|
9
|
+
{
|
|
10
|
+
closeButton: true,
|
|
11
|
+
modalTitle: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat',
|
|
12
|
+
},
|
|
13
|
+
])('Should render %s', async (page, args) => {
|
|
14
|
+
await setPageContent(page, createHTML(args, slots));
|
|
15
|
+
await expect(page.locator(args.hide ? 'body' : '.mg-modal')).toHaveScreenshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
test('Should render hidden modal', async ({ page }) => {
|
|
19
|
+
await setPageContent(page, createHTML({ hide: true }));
|
|
20
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
21
|
+
});
|
|
22
|
+
describe('style', () => {
|
|
23
|
+
test('Should render with child mg-card', async ({ page }) => {
|
|
24
|
+
await setPageContent(page, `<mg-modal modal-title="child mg-card" class="custom-modal-card">
|
|
25
|
+
<mg-card slot="content">child card</mg-card>
|
|
26
|
+
</mg-modal>
|
|
27
|
+
<style>.custom-modal-card {--mg-card-background: hsl(var(--color-danger));}</style>
|
|
28
|
+
`);
|
|
29
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('navigation', () => {
|
|
33
|
+
test('Should trigger modal and close modal.', async ({ page }) => {
|
|
34
|
+
await setPageContent(page, createHTML({ closeButton: true, hide: true }, { action: true, content: 'short' }));
|
|
35
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
36
|
+
// open modal
|
|
37
|
+
await page.locator('#modal-button').click();
|
|
38
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
39
|
+
// close modal
|
|
40
|
+
await page.locator('.mg-modal mg-button').click();
|
|
41
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
42
|
+
});
|
|
43
|
+
test('should navigate with keyboard', async ({ page }) => {
|
|
44
|
+
await setPageContent(page, createHTML({ closeButton: true, hide: true }, { action: true, content: 'short' }));
|
|
45
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
46
|
+
// open modal
|
|
47
|
+
await page.keyboard.press('Tab');
|
|
48
|
+
await page.keyboard.press('Enter');
|
|
49
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
50
|
+
// loop in modal
|
|
51
|
+
await page.keyboard.press('Tab');
|
|
52
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
53
|
+
await page.keyboard.press('Tab');
|
|
54
|
+
await page.keyboard.press('Tab');
|
|
55
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
56
|
+
// close modal
|
|
57
|
+
await page.keyboard.press('Enter');
|
|
58
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=mg-modal.e2e.playwright.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-modal.e2e.playwright.js","sourceRoot":"","sources":["../../../../../src/components/molecules/mg-modal/test/mg-modal.e2e.playwright.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAY,IAAI,EAAE,MAAM,6CAA6C,CAAC;AACvI,OAAO,EAAe,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErF,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;EACxB,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,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AAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;MACjC,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;MACnC,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;MAE3D,gBAAgB;MAChB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;MACjC,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;MAC3D,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;MACjC,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;MACjC,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;MAE3D,cAAc;MACd,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;MACnC,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { setPageContent, expect, describe, describeEach, testEach, PageType, test } from '../../../../utils/playwright.e2e.test.utils';\nimport { MgModalType, actions, contents, createHTML } from './mg-modal.e2e.template';\n\ndescribe('mg-modal', () => {\n const slotsToTests = actions.flatMap(action => contents.map(content => ({ action, content })));\n describeEach(slotsToTests)('render whith slots %s', slots => {\n testEach([\n { closeButton: false, hide: false },\n { closeButton: true, hide: false },\n {\n closeButton: true,\n modalTitle:\n 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat',\n },\n ])('Should render %s', async (page: PageType, args: MgModalType) => {\n await setPageContent(page, createHTML(args, slots));\n\n await expect(page.locator(args.hide ? 'body' : '.mg-modal')).toHaveScreenshot();\n });\n });\n\n test('Should render hidden modal', async ({ page }) => {\n await setPageContent(page, createHTML({ hide: true }));\n\n await expect(page.locator('body')).toHaveScreenshot();\n });\n\n describe('style', () => {\n test('Should render with child mg-card', async ({ page }) => {\n await setPageContent(\n page,\n `<mg-modal modal-title=\"child mg-card\" class=\"custom-modal-card\">\n <mg-card slot=\"content\">child card</mg-card>\n </mg-modal>\n <style>.custom-modal-card {--mg-card-background: hsl(var(--color-danger));}</style>\n `,\n );\n\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n });\n });\n\n describe('navigation', () => {\n test('Should trigger modal and close modal.', async ({ page }) => {\n await setPageContent(page, createHTML({ closeButton: true, hide: true }, { action: true, content: 'short' }));\n\n await expect(page.locator('body')).toHaveScreenshot();\n\n // open modal\n await page.locator('#modal-button').click();\n\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n\n // close modal\n await page.locator('.mg-modal mg-button').click();\n\n await expect(page.locator('body')).toHaveScreenshot();\n });\n\n test('should navigate with keyboard', async ({ page }) => {\n await setPageContent(page, createHTML({ closeButton: true, hide: true }, { action: true, content: 'short' }));\n await expect(page.locator('body')).toHaveScreenshot();\n\n // open modal\n await page.keyboard.press('Tab');\n await page.keyboard.press('Enter');\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n\n // loop in modal\n await page.keyboard.press('Tab');\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n await page.keyboard.press('Tab');\n await page.keyboard.press('Tab');\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n\n // close modal\n await page.keyboard.press('Enter');\n await expect(page.locator('body')).toHaveScreenshot();\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { renderAttributes } from "../../../../utils/e2e.test.utils";
|
|
2
|
+
export const contents = [null, 'short', 'long'];
|
|
3
|
+
export const actions = [true, false];
|
|
4
|
+
export const createSlots = ({ content, action }) => {
|
|
5
|
+
let slots = '';
|
|
6
|
+
if (content === 'short') {
|
|
7
|
+
slots += `
|
|
8
|
+
<p slot="content">
|
|
9
|
+
<strong>Strong</strong> content!
|
|
10
|
+
</p>`;
|
|
11
|
+
}
|
|
12
|
+
if (content === 'long') {
|
|
13
|
+
slots += `
|
|
14
|
+
<p slot="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia d</p>
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
17
|
+
if (action) {
|
|
18
|
+
slots += `
|
|
19
|
+
<div slot="actions" class="mg-group-elements mg-group-elements--align-right">
|
|
20
|
+
<mg-button identifier="identifier">Primary</mg-button>
|
|
21
|
+
<mg-button variant="secondary" identifier="identifier">
|
|
22
|
+
Secondary
|
|
23
|
+
</mg-button>
|
|
24
|
+
</div>`;
|
|
25
|
+
}
|
|
26
|
+
return slots;
|
|
27
|
+
};
|
|
28
|
+
export const createHTML = (args, slots = {}) => {
|
|
29
|
+
const triggerModalId = 'modal-button';
|
|
30
|
+
return `<mg-button id="${triggerModalId}">Open modal</mg-button>
|
|
31
|
+
<mg-modal ${renderAttributes(Object.assign({ modalTitle: 'Modal title' }, args))}>${createSlots(slots)}</mg-modal>
|
|
32
|
+
<script>
|
|
33
|
+
document.getElementById('${triggerModalId}').addEventListener('click', () => {
|
|
34
|
+
const mgModal = document.querySelector('mg-modal');
|
|
35
|
+
mgModal.hide = !mgModal.hide;
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
`;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=mg-modal.e2e.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-modal.e2e.template.js","sourceRoot":"","sources":["../../../../../src/components/molecules/mg-modal/test/mg-modal.e2e.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AACzD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAM9C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAY,EAAU,EAAE;EACnE,IAAI,KAAK,GAAG,EAAE,CAAC;EACf,IAAI,OAAO,KAAK,OAAO,EAAE;IACvB,KAAK,IAAI;;;SAGJ,CAAC;GACP;EACD,IAAI,OAAO,KAAK,MAAM,EAAE;IACtB,KAAK,IAAI;;KAER,CAAC;GACH;EACD,IAAI,MAAM,EAAE;IACV,KAAK,IAAI;;;;;;UAMH,CAAC;GACR;EAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAiB,EAAE,QAAkB,EAAE,EAAU,EAAE;EAC5E,MAAM,cAAc,GAAG,cAAc,CAAC;EACtC,OAAO,kBAAkB,cAAc;cAC3B,gBAAgB,iBAAG,UAAU,EAAE,aAAa,IAAK,IAAI,EAAG,IAAI,WAAW,CAAC,KAAK,CAAC;;+BAE7D,cAAc;;;;;GAK1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { renderAttributes } from '../../../../utils/e2e.test.utils';\nimport { MgModal } from '../mg-modal';\n\nexport const contents = [null, 'short', 'long'] as const;\nexport const actions = [true, false] as const;\nexport type ContentsType = (typeof contents)[number];\nexport type ActionsType = (typeof actions)[number];\nexport type SlotType = { content?: ContentsType; action?: ActionsType };\nexport type MgModalType = Partial<MgModal>;\n\nexport const createSlots = ({ content, action }: SlotType): string => {\n let slots = '';\n if (content === 'short') {\n slots += `\n <p slot=\"content\">\n <strong>Strong</strong> content!\n </p>`;\n }\n if (content === 'long') {\n slots += `\n <p slot=\"content\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia dLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia d</p>\n `;\n }\n if (action) {\n slots += `\n <div slot=\"actions\" class=\"mg-group-elements mg-group-elements--align-right\">\n <mg-button identifier=\"identifier\">Primary</mg-button>\n <mg-button variant=\"secondary\" identifier=\"identifier\">\n Secondary\n </mg-button>\n </div>`;\n }\n\n return slots;\n};\n\nexport const createHTML = (args: MgModalType, slots: SlotType = {}): string => {\n const triggerModalId = 'modal-button';\n return `<mg-button id=\"${triggerModalId}\">Open modal</mg-button>\n <mg-modal ${renderAttributes({ modalTitle: 'Modal title', ...args })}>${createSlots(slots)}</mg-modal>\n <script>\n document.getElementById('${triggerModalId}').addEventListener('click', () => {\n const mgModal = document.querySelector('mg-modal');\n mgModal.hide = !mgModal.hide;\n });\n </script>\n `;\n};\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { setPageContent, expect, describe, test, devices } from "../../../../utils/playwright.e2e.test.utils";
|
|
2
|
+
import { createHTML } from "./mg-modal.e2e.template";
|
|
3
|
+
test.use(Object.assign({}, devices['Desktop Firefox']));
|
|
4
|
+
describe('mg-modal, firefox', () => {
|
|
5
|
+
describe('navigation', () => {
|
|
6
|
+
test('should navigate with keyboard', async ({ page }) => {
|
|
7
|
+
await setPageContent(page, createHTML({ closeButton: true, hide: true }, { action: true, content: 'short' }));
|
|
8
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
9
|
+
// open modal
|
|
10
|
+
await page.keyboard.press('Tab');
|
|
11
|
+
await page.keyboard.press('Enter');
|
|
12
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
13
|
+
// loop in modal
|
|
14
|
+
await page.keyboard.press('Tab');
|
|
15
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
16
|
+
await page.keyboard.press('Tab');
|
|
17
|
+
await page.keyboard.press('Tab');
|
|
18
|
+
await expect(page.locator('.mg-modal')).toHaveScreenshot();
|
|
19
|
+
// close modal
|
|
20
|
+
await page.keyboard.press('Enter');
|
|
21
|
+
await page.waitForTimeout(100);
|
|
22
|
+
await expect(page.locator('body')).toHaveScreenshot();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=mg-modal.firefox.e2e.playwright.js.map
|
package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-modal.firefox.e2e.playwright.js","sourceRoot":"","sources":["../../../../../src/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,6CAA6C,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,IAAI,CAAC,GAAG,mBAAM,OAAO,CAAC,iBAAiB,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AC;MAC/B,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { setPageContent, expect, describe, test, devices } from '../../../../utils/playwright.e2e.test.utils';\nimport { createHTML } from './mg-modal.e2e.template';\n\ntest.use({ ...devices['Desktop Firefox'] });\n\ndescribe('mg-modal, firefox', () => {\n describe('navigation', () => {\n test('should navigate with keyboard', async ({ page }) => {\n await setPageContent(page, createHTML({ closeButton: true, hide: true }, { action: true, content: 'short' }));\n await expect(page.locator('body')).toHaveScreenshot();\n\n // open modal\n await page.keyboard.press('Tab');\n await page.keyboard.press('Enter');\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n\n // loop in modal\n await page.keyboard.press('Tab');\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n await page.keyboard.press('Tab');\n await page.keyboard.press('Tab');\n await expect(page.locator('.mg-modal')).toHaveScreenshot();\n\n // close modal\n await page.keyboard.press('Enter');\n await page.waitForTimeout(100);\n await expect(page.locator('body')).toHaveScreenshot();\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
3
|
+
import { h } from "@stencil/core";
|
|
4
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
5
|
+
import { MgButton } from "../../../atoms/mg-button/mg-button";
|
|
6
|
+
import { MgModal } from "../mg-modal";
|
|
7
|
+
import { focusableElements } from "../../../../utils/components.utils";
|
|
8
|
+
import { setupMutationObserverMock } from "../../../../utils/unit.test.utils";
|
|
9
|
+
import { dialogRoles } from "../mg-modal.conf";
|
|
10
|
+
const getPage = (args, slots) => newSpecPage({
|
|
11
|
+
components: [MgModal, MgButton],
|
|
12
|
+
template: () => (h("mg-modal", Object.assign({}, args), (slots === null || slots === void 0 ? void 0 : slots.content) && (h("p", { slot: "content" }, h("strong", null, "Strong"), " content with ", h("a", { href: "./" }, "a link"), "!")), (slots === null || slots === void 0 ? void 0 : slots.actions) && (h("div", { slot: "actions", class: "mg-group-elements mg-group-elements--align-right" }, h("mg-button", null, "Primary"), h("mg-button", { variant: "secondary" }, "Secondary"))))),
|
|
13
|
+
});
|
|
14
|
+
describe('mg-modal', () => {
|
|
15
|
+
let fireMo;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
setupMutationObserverMock({
|
|
18
|
+
observe: function () {
|
|
19
|
+
fireMo = this.cb;
|
|
20
|
+
},
|
|
21
|
+
disconnect: function () {
|
|
22
|
+
return null;
|
|
23
|
+
},
|
|
24
|
+
takeRecords: () => [],
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe.each([undefined, { content: true }, { actions: true }, { content: true, actions: true }])('Should render a modal', slots => {
|
|
28
|
+
test.each([
|
|
29
|
+
{ modalTitle: 'Modal Title', identifier: 'identifier' },
|
|
30
|
+
{ modalTitle: 'Modal Title', identifier: 'identifier', dialogRole: 'alertdialog' },
|
|
31
|
+
{ modalTitle: 'Modal Title', identifier: 'identifier', closeButton: true },
|
|
32
|
+
{ modalTitle: 'Modal Title', identifier: 'identifier', closeButton: true, hide: true },
|
|
33
|
+
{ modalTitle: 'Modal Title', identifier: 'identifier', closeButton: true, lang: 'fr' },
|
|
34
|
+
{ modalTitle: 'Modal Title', identifier: 'identifier', closeButton: true, lang: 'xx' },
|
|
35
|
+
])('with args %s', async (args) => {
|
|
36
|
+
const { root } = await getPage(Object.assign({}, args), slots);
|
|
37
|
+
expect(root).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
test.each(['', ' ', undefined])('Should not render with invalid modalTitle property: %s', async (modalTitle) => {
|
|
41
|
+
expect.assertions(1);
|
|
42
|
+
try {
|
|
43
|
+
await getPage({ modalTitle });
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
expect(err.message).toMatch('<mg-modal> prop "modalTitle" is required.');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
test.each([' ', 'batman'])('Should throw error with invalid dialogRole property: %s', async (dialogRole) => {
|
|
50
|
+
expect.assertions(1);
|
|
51
|
+
try {
|
|
52
|
+
await getPage({ modalTitle: 'Modal title', dialogRole });
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
expect(err.message).toMatch(`<mg-modal> prop "dialogRole" must be one of: ${dialogRoles.join(', ')}.`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
describe('navigation', () => {
|
|
59
|
+
test('should hide panel with button', async () => {
|
|
60
|
+
const page = await getPage({ modalTitle: 'Modal Title', identifier: 'identifier', closeButton: true });
|
|
61
|
+
const closeButton = page.root.shadowRoot.querySelector('mg-button');
|
|
62
|
+
expect(page.root).toMatchSnapshot();
|
|
63
|
+
const spy = jest.spyOn(page.rootInstance.componentHide, 'emit');
|
|
64
|
+
closeButton.dispatchEvent(new CustomEvent('click', { bubbles: true }));
|
|
65
|
+
await page.waitForChanges();
|
|
66
|
+
expect(page.root).toMatchSnapshot();
|
|
67
|
+
expect(spy).toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
test.each([true, false])('should hide panel with escape keyboard', async (closeButton) => {
|
|
70
|
+
const page = await getPage({ modalTitle: 'Modal Title', identifier: 'identifier', closeButton });
|
|
71
|
+
expect(page.root).toMatchSnapshot();
|
|
72
|
+
const spy = jest.spyOn(page.rootInstance.componentHide, 'emit');
|
|
73
|
+
page.win.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
|
74
|
+
await page.waitForChanges();
|
|
75
|
+
expect(page.root).toMatchSnapshot();
|
|
76
|
+
if (closeButton) {
|
|
77
|
+
expect(spy).toHaveBeenCalled();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
expect(spy).not.toHaveBeenCalled();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
describe.each([
|
|
84
|
+
{ attributeName: 'aria-hidden', target: { ariaHidden: null } },
|
|
85
|
+
{ attributeName: 'aria-hidden', target: { ariaHidden: '' } },
|
|
86
|
+
{ attributeName: 'aria-hidden', target: { ariaHidden: undefined } },
|
|
87
|
+
])('mutationObserver', mutation => {
|
|
88
|
+
test.each([true, false])('should keep focus inside modal, closeButton %s', async (closeButton) => {
|
|
89
|
+
const page = await getPage({ modalTitle: 'Modal Title', identifier: 'identifier', closeButton, hide: true }, { content: true, actions: true });
|
|
90
|
+
const element = page.doc.querySelector('mg-modal');
|
|
91
|
+
// Get all focusable elements
|
|
92
|
+
const modalFocusableElements = Array.from(element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
93
|
+
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);
|
|
94
|
+
return acc;
|
|
95
|
+
}, []);
|
|
96
|
+
// When close button is enabled it's the first focusable element.
|
|
97
|
+
if (closeButton) {
|
|
98
|
+
modalFocusableElements.unshift(element.shadowRoot.querySelector(`.mg-modal__close-button mg-button`));
|
|
99
|
+
}
|
|
100
|
+
const lastFocusableElement = modalFocusableElements[modalFocusableElements.length - 1];
|
|
101
|
+
const spyFirst = jest.spyOn(modalFocusableElements[0], 'focus');
|
|
102
|
+
const spyLast = jest.spyOn(lastFocusableElement, 'focus');
|
|
103
|
+
// Display modal
|
|
104
|
+
element.hide = false;
|
|
105
|
+
await page.waitForChanges();
|
|
106
|
+
expect(spyFirst).toHaveBeenCalledTimes(0);
|
|
107
|
+
fireMo([mutation]);
|
|
108
|
+
await page.waitForChanges();
|
|
109
|
+
expect(spyFirst).toHaveBeenCalledTimes(1);
|
|
110
|
+
// Tab from last focusable element
|
|
111
|
+
lastFocusableElement.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Tab', shiftKey: false }));
|
|
112
|
+
await page.waitForChanges();
|
|
113
|
+
expect(spyFirst).toHaveBeenCalledTimes(2);
|
|
114
|
+
// Tab first focusable element with shift key
|
|
115
|
+
modalFocusableElements[0].dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Tab', shiftKey: true }));
|
|
116
|
+
await page.waitForChanges();
|
|
117
|
+
expect(spyLast).toHaveBeenCalledTimes(1);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=mg-modal.spec.js.map
|