diff --git a/vizro-core/changelog.d/20251218_123929_alexey_snigir_enable_alerts_tests.md b/vizro-core/changelog.d/20251218_123929_alexey_snigir_enable_alerts_tests.md new file mode 100644 index 0000000000..7c0d58d4f8 --- /dev/null +++ b/vizro-core/changelog.d/20251218_123929_alexey_snigir_enable_alerts_tests.md @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/vizro-core/examples/scratch_dev/app.py b/vizro-core/examples/scratch_dev/app.py index 2de642bea5..40c2be634b 100644 --- a/vizro-core/examples/scratch_dev/app.py +++ b/vizro-core/examples/scratch_dev/app.py @@ -164,7 +164,7 @@ ], ) -dashboard = vm.Dashboard(pages=[page_1, page_two]) +dashboard = vm.Dashboard(pages=[page_1, page_two], title="Test Dashboard") if __name__ == "__main__": Vizro().build(dashboard).run() diff --git a/vizro-core/src/vizro/actions/_notifications.py b/vizro-core/src/vizro/actions/_notifications.py index c28cdcb33c..2d87558033 100755 --- a/vizro-core/src/vizro/actions/_notifications.py +++ b/vizro-core/src/vizro/actions/_notifications.py @@ -103,7 +103,7 @@ def set_variant_defaults(self): @property def outputs(self) -> _IdOrIdProperty: # type: ignore[override] - return "vizro_notifications.sendNotifications" + return "vizro-notifications.sendNotifications" @_log_call def function(self): diff --git a/vizro-core/src/vizro/models/_page.py b/vizro-core/src/vizro/models/_page.py index 33f34e36fc..ec10f03169 100644 --- a/vizro-core/src/vizro/models/_page.py +++ b/vizro-core/src/vizro/models/_page.py @@ -237,7 +237,7 @@ def build(self) -> _PageBuildType: dcc.Location(id="vizro_url", refresh="callback-nav"), dmc.NotificationContainer( position="top-right", - id="vizro_notifications", + id="vizro-notifications", ), ] ) diff --git a/vizro-core/src/vizro/static/css/layout.css b/vizro-core/src/vizro/static/css/layout.css index 94afb05c5d..d03017dbde 100644 --- a/vizro-core/src/vizro/static/css/layout.css +++ b/vizro-core/src/vizro/static/css/layout.css @@ -249,7 +249,7 @@ Current logic: #header, #right-side, - #notification-container { + #vizro-notifications { zoom: 80%; } } diff --git a/vizro-core/src/vizro/static/css/notifications.css b/vizro-core/src/vizro/static/css/notifications.css index 182951c013..20d068718b 100644 --- a/vizro-core/src/vizro/static/css/notifications.css +++ b/vizro-core/src/vizro/static/css/notifications.css @@ -1,9 +1,14 @@ +#vizro-notifications > div:first-child { + display: flex; + flex-direction: column; + gap: 12px; +} + .alert-info, .alert-success, .alert-warning, .alert-error { align-items: flex-start; background: var(--surfaces-bg-card-inverted); box-shadow: var(--bs-box-shadow); display: flex; - margin-top: 12px; padding: 12px 8px; } diff --git a/vizro-core/tests/e2e/screenshots/chrome/main_notifications_page.png b/vizro-core/tests/e2e/screenshots/chrome/main_notifications_page.png new file mode 100644 index 0000000000..dd08bfa711 Binary files /dev/null and b/vizro-core/tests/e2e/screenshots/chrome/main_notifications_page.png differ diff --git a/vizro-core/tests/e2e/screenshots/chrome/main_notifications_page_dark_theme.png b/vizro-core/tests/e2e/screenshots/chrome/main_notifications_page_dark_theme.png new file mode 100644 index 0000000000..f4e11eb55b Binary files /dev/null and b/vizro-core/tests/e2e/screenshots/chrome/main_notifications_page_dark_theme.png differ diff --git a/vizro-core/tests/e2e/screenshots/chrome_mobile/main_notifications_page_mobile[mobile].png b/vizro-core/tests/e2e/screenshots/chrome_mobile/main_notifications_page_mobile[mobile].png new file mode 100644 index 0000000000..dc1a1409aa Binary files /dev/null and b/vizro-core/tests/e2e/screenshots/chrome_mobile/main_notifications_page_mobile[mobile].png differ diff --git a/vizro-core/tests/e2e/screenshots/firefox/main_notifications_page.png b/vizro-core/tests/e2e/screenshots/firefox/main_notifications_page.png new file mode 100644 index 0000000000..9c5923a768 Binary files /dev/null and b/vizro-core/tests/e2e/screenshots/firefox/main_notifications_page.png differ diff --git a/vizro-core/tests/e2e/screenshots/firefox/main_notifications_page_dark_theme.png b/vizro-core/tests/e2e/screenshots/firefox/main_notifications_page_dark_theme.png new file mode 100644 index 0000000000..1238e808ca Binary files /dev/null and b/vizro-core/tests/e2e/screenshots/firefox/main_notifications_page_dark_theme.png differ diff --git a/vizro-core/tests/e2e/vizro/dashboards/default/dashboard.py b/vizro-core/tests/e2e/vizro/dashboards/default/dashboard.py index 0ae976d8ff..2a9b54cdec 100644 --- a/vizro-core/tests/e2e/vizro/dashboards/default/dashboard.py +++ b/vizro-core/tests/e2e/vizro/dashboards/default/dashboard.py @@ -33,6 +33,7 @@ layout_flex_with_wrap_param_and_ag_grid, layout_flex_without_params, ) +from pages.notifications_page import static_notifications_page from pages.parameters_multi_page import parameters_multi_page from pages.parameters_page import parameters_page from pages.set_control_cross_filter_page import ( @@ -106,6 +107,7 @@ action_model_field_shortcut_page, action_ag_grid_underlying_id_shortcut_page, action_control_shortcut_page, + static_notifications_page, ], navigation=vm.Navigation( pages={ @@ -166,6 +168,7 @@ cnst.ACTION_MODEL_FIELD_SHORTCUT_PAGE, cnst.ACTION_AG_GRID_UNDERLYING_ID_SHORTCUT_PAGE, cnst.ACTION_CONTROL_SHORTCUT_PAGE, + cnst.STATIC_NOTIFICATIONS_PAGE, ], } ), diff --git a/vizro-core/tests/e2e/vizro/dashboards/default/pages/notifications_page.py b/vizro-core/tests/e2e/vizro/dashboards/default/pages/notifications_page.py new file mode 100644 index 0000000000..f7234ba30e --- /dev/null +++ b/vizro-core/tests/e2e/vizro/dashboards/default/pages/notifications_page.py @@ -0,0 +1,134 @@ +import e2e.vizro.constants as cnst + +import vizro.actions as va +import vizro.models as vm +import vizro.plotly.express as px + +df = px.data.iris() + +static_notifications_page = vm.Page( + title=cnst.STATIC_NOTIFICATIONS_PAGE, + layout=vm.Flex(), + components=[ + vm.Button( + id=cnst.SUCCESS_NOTIFICATION_BUTTON, + icon=cnst.SUCCESS_NOTIFICATION_ICON, + text="Success Notification", + actions=[ + va.show_notification( + id=cnst.SUCCESS_NOTIFICATION_ID, + text=cnst.SUCCESS_NOTIFICATION_MESSAGE, + variant="success", + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.WARNING_NOTIFICATION_BUTTON, + icon=cnst.WARNING_NOTIFICATION_ICON, + text="Warning Notification", + actions=[ + va.show_notification( + id=cnst.WARNING_NOTIFICATION_ID, + text=cnst.WARNING_NOTIFICATION_MESSAGE, + variant="warning", + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.ERROR_NOTIFICATION_BUTTON, + icon=cnst.ERROR_NOTIFICATION_ICON, + text="Error Notification", + actions=[ + va.show_notification( + id=cnst.ERROR_NOTIFICATION_ID, + text=cnst.ERROR_NOTIFICATION_MESSAGE, + variant="error", + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.INFO_NOTIFICATION_BUTTON, + icon=cnst.INFO_NOTIFICATION_ICON, + text="Info Notification", + actions=[ + va.show_notification( + id=cnst.INFO_NOTIFICATION_ID, + text=cnst.INFO_NOTIFICATION_MESSAGE, + variant="info", + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.CUSTOM_NOTIFICATION_BUTTON, + icon=cnst.CUSTOM_NOTIFICATION_ICON, + text="Custom Notification", + actions=[ + va.show_notification( + id=cnst.CUSTOM_NOTIFICATION_ID, + text=cnst.CUSTOM_NOTIFICATION_MESSAGE, + title=cnst.CUSTOM_NOTIFICATION_TITLE, + variant="success", + icon=cnst.CUSTOM_NOTIFICATION_ICON, + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.PROGRESS_NOTIFICATION_BUTTON, + text="1. Show Loading", + icon="hourglass_empty", + actions=[ + va.show_notification( + id=cnst.UPDATE_NOTIFICATION_ID, + text=cnst.PROGRESS_NOTIFICATION_MESSAGE, + title=cnst.PROGRESS_NOTIFICATION_TITLE, + variant="progress", + ) + ], + ), + vm.Button( + id=cnst.UPDATE_NOTIFICATION_BUTTON, + text="2. Update to Complete", + icon="check_circle", + actions=[ + va.update_notification( + notification=cnst.UPDATE_NOTIFICATION_ID, + text=cnst.UPDATE_NOTIFICATION_MESSAGE, + title=cnst.UPDATE_NOTIFICATION_TITLE, + variant="success", + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.LINK_NOTIFICATION_BUTTON, + text="Markdown with Link", + icon="link", + actions=[ + va.show_notification( + id=cnst.LINK_NOTIFICATION_ID, + text=cnst.LINK_NOTIFICATION_MESSAGE, + title=cnst.LINK_NOTIFICATION_TITLE, + auto_close=False, + ) + ], + ), + vm.Button( + id=cnst.AUTO_CLOSE_NOTIFICATION_BUTTON, + text="Auto-Close", + icon="close", + actions=[ + va.show_notification( + id=cnst.AUTO_CLOSE_NOTIFICATION_ID, + text=cnst.AUTO_CLOSE_NOTIFICATION_MESSAGE, + title=cnst.AUTO_CLOSE_NOTIFICATION_TITLE, + variant="info", + ) + ], + ), + ], +) diff --git a/vizro-core/tests/e2e/vizro/test_dom_elements/test_notifications.py b/vizro-core/tests/e2e/vizro/test_dom_elements/test_notifications.py new file mode 100644 index 0000000000..580b09696d --- /dev/null +++ b/vizro-core/tests/e2e/vizro/test_dom_elements/test_notifications.py @@ -0,0 +1,174 @@ +import time + +import e2e.vizro.constants as cnst +import pytest +from e2e.vizro.navigation import accordion_select, page_select +from e2e.vizro.paths import button_id_path + + +@pytest.mark.parametrize( + "button_id, notification_id, expected_icon, expected_title, expected_message", + [ + ( + cnst.SUCCESS_NOTIFICATION_BUTTON, + cnst.SUCCESS_NOTIFICATION_ID, + cnst.SUCCESS_NOTIFICATION_ICON, + cnst.SUCCESS_NOTIFICATION_TITLE, + cnst.SUCCESS_NOTIFICATION_MESSAGE, + ), + ( + cnst.WARNING_NOTIFICATION_BUTTON, + cnst.WARNING_NOTIFICATION_ID, + cnst.WARNING_NOTIFICATION_ICON, + cnst.WARNING_NOTIFICATION_TITLE, + cnst.WARNING_NOTIFICATION_MESSAGE, + ), + ( + cnst.ERROR_NOTIFICATION_BUTTON, + cnst.ERROR_NOTIFICATION_ID, + cnst.ERROR_NOTIFICATION_ICON, + cnst.ERROR_NOTIFICATION_TITLE, + cnst.ERROR_NOTIFICATION_MESSAGE, + ), + ( + cnst.INFO_NOTIFICATION_BUTTON, + cnst.INFO_NOTIFICATION_ID, + cnst.INFO_NOTIFICATION_ICON, + cnst.INFO_NOTIFICATION_TITLE, + cnst.INFO_NOTIFICATION_MESSAGE, + ), + ( + cnst.CUSTOM_NOTIFICATION_BUTTON, + cnst.CUSTOM_NOTIFICATION_ID, + cnst.CUSTOM_NOTIFICATION_ICON, + cnst.CUSTOM_NOTIFICATION_TITLE, + cnst.CUSTOM_NOTIFICATION_MESSAGE, + ), + ], + ids=[ + "Success Notification", + "Warning Notification", + "Error Notification", + "Info Notification", + "Custom Notification", + ], +) +def test_notifications(dash_br, button_id, notification_id, expected_icon, expected_title, expected_message): + """Testing static notifications appearance and content.""" + accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION) + page_select( + dash_br, + page_name=cnst.STATIC_NOTIFICATIONS_PAGE, + ) + + # Trigger notification and check its content + dash_br.multiple_click(button_id_path(btn_id=button_id), 1) + dash_br.wait_for_text_to_equal(f'#{notification_id} div[class$="Notification-icon"] span', expected_icon) + dash_br.wait_for_text_to_equal(f'#{notification_id} div[class$="Notification-title"]', expected_title) + dash_br.wait_for_text_to_equal(f'#{notification_id} div[class$="Notification-description"] p', expected_message) + + # Close notification + dash_br.multiple_click(f'#{notification_id} button[class*="Notification-closeButton"]', 1) + dash_br.wait_for_no_elements(f"#{notification_id}") + + +def test_progress_update_notification(dash_br): + """Testing progress notification followed by update notification.""" + accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION) + page_select( + dash_br, + page_name=cnst.STATIC_NOTIFICATIONS_PAGE, + ) + + # Trigger progress notification and check its content + dash_br.multiple_click(button_id_path(btn_id=cnst.PROGRESS_NOTIFICATION_BUTTON), 1) + dash_br.wait_for_element(f'#{cnst.UPDATE_NOTIFICATION_ID} span[class*="Notification-loader"]') + dash_br.wait_for_text_to_equal( + f'#{cnst.UPDATE_NOTIFICATION_ID} div[class$="Notification-title"]', cnst.PROGRESS_NOTIFICATION_TITLE + ) + dash_br.wait_for_text_to_equal( + f'#{cnst.UPDATE_NOTIFICATION_ID} div[class$="Notification-description"] p', cnst.PROGRESS_NOTIFICATION_MESSAGE + ) + + # Simulate progress completion and check update notification content + dash_br.multiple_click(button_id_path(btn_id=cnst.UPDATE_NOTIFICATION_BUTTON), 1) + dash_br.wait_for_text_to_equal( + f'#{cnst.UPDATE_NOTIFICATION_ID} div[class$="Notification-icon"] span', cnst.SUCCESS_NOTIFICATION_ICON + ) + dash_br.wait_for_text_to_equal( + f'#{cnst.UPDATE_NOTIFICATION_ID} div[class$="Notification-title"]', cnst.UPDATE_NOTIFICATION_TITLE + ) + dash_br.wait_for_text_to_equal( + f'#{cnst.UPDATE_NOTIFICATION_ID} div[class$="Notification-description"] p', cnst.UPDATE_NOTIFICATION_MESSAGE + ) + + # Close update notification + time.sleep(5) # timeout for checking if notification does not auto close + dash_br.multiple_click(f'#{cnst.UPDATE_NOTIFICATION_ID} button[class*="Notification-closeButton"]', 1) + dash_br.wait_for_no_elements(f"#{cnst.UPDATE_NOTIFICATION_ID}") + + +def test_auto_close_notification(dash_br): + """Testing auto-close notification.""" + accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION) + page_select( + dash_br, + page_name=cnst.STATIC_NOTIFICATIONS_PAGE, + ) + + # Trigger auto-close notification and check its content + dash_br.multiple_click(button_id_path(btn_id=cnst.AUTO_CLOSE_NOTIFICATION_BUTTON), 1) + dash_br.wait_for_text_to_equal( + f'#{cnst.AUTO_CLOSE_NOTIFICATION_ID} div[class$="Notification-icon"] span', cnst.INFO_NOTIFICATION_ICON + ) + dash_br.wait_for_text_to_equal( + f'#{cnst.AUTO_CLOSE_NOTIFICATION_ID} div[class$="Notification-title"]', cnst.AUTO_CLOSE_NOTIFICATION_TITLE + ) + dash_br.wait_for_text_to_equal( + f'#{cnst.AUTO_CLOSE_NOTIFICATION_ID} div[class$="Notification-description"] p', + cnst.AUTO_CLOSE_NOTIFICATION_MESSAGE, + ) + + # Wait for auto-close + dash_br.wait_for_no_elements(f"#{cnst.AUTO_CLOSE_NOTIFICATION_ID}", timeout=10) + + +def test_notifications_limit(dash_br): + """Testing that only a limited number of notifications (5) are shown at once.""" + accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION) + page_select( + dash_br, + page_name=cnst.STATIC_NOTIFICATIONS_PAGE, + ) + + # Trigger multiple notifications + dash_br.multiple_click(button_id_path(btn_id=cnst.SUCCESS_NOTIFICATION_BUTTON), 1) + dash_br.multiple_click(button_id_path(btn_id=cnst.WARNING_NOTIFICATION_BUTTON), 1) + dash_br.multiple_click(button_id_path(btn_id=cnst.ERROR_NOTIFICATION_BUTTON), 1) + dash_br.multiple_click(button_id_path(btn_id=cnst.INFO_NOTIFICATION_BUTTON), 1) + dash_br.multiple_click(button_id_path(btn_id=cnst.CUSTOM_NOTIFICATION_BUTTON), 1) + dash_br.multiple_click(button_id_path(btn_id=cnst.PROGRESS_NOTIFICATION_BUTTON), 1) + + # timeout for checking if notification does not auto close + time.sleep(5) + + # Check that only 5 notifications are shown + dash_br.wait_for_no_elements(f"#{cnst.PROGRESS_NOTIFICATION_ID}") + + # Close one notification and check that the next one appears + dash_br.multiple_click(f'#{cnst.SUCCESS_NOTIFICATION_ID} button[class*="Notification-closeButton"]', 1) + dash_br.wait_for_element(f"#{cnst.PROGRESS_NOTIFICATION_ID}") + + # Trigger another notification and open a different page + dash_br.multiple_click(button_id_path(btn_id=cnst.SUCCESS_NOTIFICATION_BUTTON), 1) + page_select(dash_br, page_name=cnst.ACTION_CONTROL_SHORTCUT_PAGE) + + # timeout for checking if notification does not auto close + time.sleep(5) + + # Check that no new notifications are shown on the new page + dash_br.wait_for_no_elements(f"#{cnst.SUCCESS_NOTIFICATION_ID}") + + # Close one notification and check that the next one appears + dash_br.multiple_click(f'#{cnst.WARNING_NOTIFICATION_ID} button[class*="Notification-closeButton"]', 1) + dash_br.wait_for_element(f"#{cnst.SUCCESS_NOTIFICATION_ID}") diff --git a/vizro-core/tests/e2e/vizro/test_screenshots/test_screenshots.py b/vizro-core/tests/e2e/vizro/test_screenshots/test_screenshots.py index c1e25e97cc..9a4f66dbed 100644 --- a/vizro-core/tests/e2e/vizro/test_screenshots/test_screenshots.py +++ b/vizro-core/tests/e2e/vizro/test_screenshots/test_screenshots.py @@ -12,6 +12,7 @@ page_select, ) from e2e.vizro.paths import ( + button_id_path, dropdown_arrow_path, kpi_card_path, nav_card_link_path, @@ -387,6 +388,45 @@ def test_reset_controls_page(dash_br): dash_br.multiple_click(dropdown_arrow_path(dropdown_id=cnst.DROPDOWN_AG_GRID_INTERACTIONS_ID), 1) +@image_assertion +def test_notifications_page(dash_br): + """Testing static notifications page.""" + accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION) + page_select( + dash_br, + page_name=cnst.STATIC_NOTIFICATIONS_PAGE, + ) + + # Trigger link notification + dash_br.multiple_click(button_id_path(btn_id=cnst.LINK_NOTIFICATION_BUTTON), 1, delay=1) + + # Check that the last notification is displayed + dash_br.wait_for_text_to_equal( + f'#{cnst.LINK_NOTIFICATION_ID} div[class$="Notification-title"]', cnst.LINK_NOTIFICATION_TITLE + ) + + +@image_assertion +def test_notifications_page_dark_theme(dash_br): + """Testing static notifications page with dark theme.""" + accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION) + page_select( + dash_br, + page_name=cnst.STATIC_NOTIFICATIONS_PAGE, + ) + + # Switch theme to dark + dash_br.multiple_click(theme_toggle_path(), 1) + + # Trigger success notification + dash_br.multiple_click(button_id_path(btn_id=cnst.SUCCESS_NOTIFICATION_BUTTON), 1, delay=1) + + # Check that the last notification is displayed + dash_br.wait_for_text_to_equal( + f'#{cnst.SUCCESS_NOTIFICATION_ID} div[class$="Notification-title"]', cnst.SUCCESS_NOTIFICATION_TITLE + ) + + @pytest.mark.mobile_screenshots @image_assertion def test_homepage_mobile(dash_br): @@ -412,3 +452,25 @@ def test_filter_interactions_dark_theme_page(dash_br_driver): dash_br_driver.multiple_click(theme_toggle_path(), 1) check_graph_color(dash_br_driver, style_background=cnst.STYLE_TRANSPARENT, color=cnst.RGBA_TRANSPARENT) check_theme_color(dash_br_driver, color=cnst.THEME_DARK) + + +@pytest.mark.mobile_screenshots +@pytest.mark.parametrize( + "dash_br_driver", [({"path": f"/{cnst.STATIC_NOTIFICATIONS_PAGE}"})], ids=["mobile"], indirect=["dash_br_driver"] +) +@image_assertion +def test_notifications_page_mobile(dash_br_driver): + """Testing static notifications page on mobile.""" + graph_load_waiter(dash_br_driver) + + # Trigger multiple notifications + dash_br_driver.multiple_click(button_id_path(btn_id=cnst.SUCCESS_NOTIFICATION_BUTTON), 1) + dash_br_driver.multiple_click(button_id_path(btn_id=cnst.WARNING_NOTIFICATION_BUTTON), 1) + dash_br_driver.multiple_click(button_id_path(btn_id=cnst.ERROR_NOTIFICATION_BUTTON), 1) + dash_br_driver.multiple_click(button_id_path(btn_id=cnst.INFO_NOTIFICATION_BUTTON), 1) + dash_br_driver.multiple_click(button_id_path(btn_id=cnst.LINK_NOTIFICATION_BUTTON), 1) + + # Check that the last notification is displayed + dash_br_driver.wait_for_text_to_equal( + f'#{cnst.LINK_NOTIFICATION_ID} div[class$="Notification-title"]', cnst.LINK_NOTIFICATION_TITLE + ) diff --git a/vizro-core/tests/tests_utils/e2e/vizro/constants.py b/vizro-core/tests/tests_utils/e2e/vizro/constants.py index ae3dab20f4..4060d6ad52 100644 --- a/vizro-core/tests/tests_utils/e2e/vizro/constants.py +++ b/vizro-core/tests/tests_utils/e2e/vizro/constants.py @@ -295,6 +295,48 @@ ACTION_CONTROL_SHORTCUT_FILTER_ID = "filter-default-properties" ACTION_CONTROL_SHORTCUT_PARAMETER_ID = "parameter-default-properties" +STATIC_NOTIFICATIONS_PAGE = "static-notifications-page" +SUCCESS_NOTIFICATION_BUTTON = "success-notification-button" +SUCCESS_NOTIFICATION_ICON = "check_circle" +SUCCESS_NOTIFICATION_ID = "success-notification" +SUCCESS_NOTIFICATION_TITLE = "Success" +SUCCESS_NOTIFICATION_MESSAGE = "Operation completed successfully!" +WARNING_NOTIFICATION_BUTTON = "warning-notification-button" +WARNING_NOTIFICATION_ICON = "warning" +WARNING_NOTIFICATION_ID = "warning-notification" +WARNING_NOTIFICATION_TITLE = "Warning" +WARNING_NOTIFICATION_MESSAGE = "Please review this warning message." +ERROR_NOTIFICATION_BUTTON = "error-notification-button" +ERROR_NOTIFICATION_ICON = "error" +ERROR_NOTIFICATION_ID = "error-notification" +ERROR_NOTIFICATION_TITLE = "Error" +ERROR_NOTIFICATION_MESSAGE = "An error occurred during the operation." +INFO_NOTIFICATION_BUTTON = "info-notification-button" +INFO_NOTIFICATION_ICON = "info" +INFO_NOTIFICATION_ID = "info-notification" +INFO_NOTIFICATION_TITLE = "Info" +INFO_NOTIFICATION_MESSAGE = "Here's some useful information for you." +CUSTOM_NOTIFICATION_BUTTON = "custom-notification-button" +CUSTOM_NOTIFICATION_ICON = "celebration" +CUSTOM_NOTIFICATION_ID = "custom-notification" +CUSTOM_NOTIFICATION_TITLE = "New Feature" +CUSTOM_NOTIFICATION_MESSAGE = "Check out this new feature we've added!" +PROGRESS_NOTIFICATION_BUTTON = "progress-notification-button" +PROGRESS_NOTIFICATION_ID = "update-notification" +PROGRESS_NOTIFICATION_TITLE = "Processing" +PROGRESS_NOTIFICATION_MESSAGE = "Processing..." +UPDATE_NOTIFICATION_BUTTON = "update-notification-button" +UPDATE_NOTIFICATION_ID = "update-notification" +UPDATE_NOTIFICATION_TITLE = "Complete" +UPDATE_NOTIFICATION_MESSAGE = "Your operation has been updated successfully." +LINK_NOTIFICATION_BUTTON = "link-notification-button" +LINK_NOTIFICATION_ID = "link-notification" +LINK_NOTIFICATION_TITLE = "Learn More" +LINK_NOTIFICATION_MESSAGE = f"This is a notification with a link to [Filters page]({FILTERS_PAGE_PATH})." +AUTO_CLOSE_NOTIFICATION_BUTTON = "auto-close-notification-button" +AUTO_CLOSE_NOTIFICATION_ID = "auto-close-notification" +AUTO_CLOSE_NOTIFICATION_TITLE = "Auto-Close" +AUTO_CLOSE_NOTIFICATION_MESSAGE = "This notification will close automatically." PAGE_404_PATH = "/404-page" diff --git a/vizro-core/tests/unit/vizro/actions/test_notifications.py b/vizro-core/tests/unit/vizro/actions/test_notifications.py index 38d888a22e..cadc8a1993 100644 --- a/vizro-core/tests/unit/vizro/actions/test_notifications.py +++ b/vizro-core/tests/unit/vizro/actions/test_notifications.py @@ -29,7 +29,7 @@ def test_create_show_notification_mandatory_only(self): assert notification.title == "Info" assert notification.icon == "info" assert notification.auto_close == 4000 - assert notification.outputs == "vizro_notifications.sendNotifications" + assert notification.outputs == "vizro-notifications.sendNotifications" @pytest.mark.parametrize("field", ["title", "icon", "auto_close"]) def test_none_value_raises_validation_error(self, field):