diff options
Diffstat (limited to 'app/assets/javascripts/flash.js')
-rw-r--r-- | app/assets/javascripts/flash.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/assets/javascripts/flash.js b/app/assets/javascripts/flash.js index d9c2e55cffe..fa605f8c056 100644 --- a/app/assets/javascripts/flash.js +++ b/app/assets/javascripts/flash.js @@ -18,6 +18,13 @@ const VARIANT_DANGER = 'danger'; const VARIANT_INFO = 'info'; const VARIANT_TIP = 'tip'; +const TYPE_TO_VARIANT = { + [FLASH_TYPES.ALERT]: VARIANT_DANGER, + [FLASH_TYPES.NOTICE]: VARIANT_INFO, + [FLASH_TYPES.SUCCESS]: VARIANT_SUCCESS, + [FLASH_TYPES.WARNING]: VARIANT_WARNING, +}; + const FLASH_CLOSED_EVENT = 'flashClosed'; const getCloseEl = (flashEl) => { @@ -61,7 +68,7 @@ const createAction = (config) => ` `; const createFlashEl = (message, type) => ` - <div class="flash-${type}"> + <div class="flash-${type}" data-testid="alert-${TYPE_TO_VARIANT[type]}"> <div class="flash-text"> ${escape(message)} <div class="close-icon-wrapper js-close-icon"> @@ -189,6 +196,9 @@ const createAlert = function createAlert({ secondaryButtonLink: secondaryButton?.link, secondaryButtonText: secondaryButton?.text, }, + attrs: { + 'data-testid': `alert-${variant}`, + }, on, }, message, |