diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb
index 4cb83c8878e6..4f74da65c59a 100644
--- a/app/helpers/flash_messages_helper.rb
+++ b/app/helpers/flash_messages_helper.rb
@@ -63,7 +63,7 @@ def render_flash_modal
def mapped_flash_type(type)
case type
- when :error
+ when :error, :danger
:danger
when :warning
:warning
diff --git a/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb b/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb
index e981effb14af..525a724aab1e 100644
--- a/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb
+++ b/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb
@@ -185,8 +185,7 @@
click_button "Save"
- backlogs_page
- .expect_and_dismiss_toaster(message: "Successful update.")
+ expect_and_dismiss_primerized_flash(message: "Successful update.")
backlogs_page
.expect_backlog(sprint)
diff --git a/modules/bim/spec/features/bcf/api_authorization_spec.rb b/modules/bim/spec/features/bcf/api_authorization_spec.rb
index 5ae2fc055fea..620127b53262 100644
--- a/modules/bim/spec/features/bcf/api_authorization_spec.rb
+++ b/modules/bim/spec/features/bcf/api_authorization_spec.rb
@@ -57,11 +57,11 @@ def oauth_path(client_id)
fill_in "application_redirect_uri", with: "not a url!"
click_on "Create"
- expect(page).to have_css(".errorExplanation", text: "Redirect URI must be an absolute URI.")
+ expect(page).to have_text("Redirect URI must be an absolute URI.")
fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttps://localhost/my/callback"
click_on "Create"
- expect(page).to have_css(".op-toast.-success", text: "Successful creation.")
+ expect_primerized_flash(message: "Successful creation.")
expect(page).to have_css(".attributes-key-value--key",
text: "Client ID")
diff --git a/modules/bim/spec/features/model_management_spec.rb b/modules/bim/spec/features/model_management_spec.rb
index 914d0dd5a529..7d8686a3ca54 100644
--- a/modules/bim/spec/features/model_management_spec.rb
+++ b/modules/bim/spec/features/model_management_spec.rb
@@ -130,7 +130,7 @@
it "I can't see any models and perform no actions" do
expected = "[Error 403] You are not authorized to access this page."
- expect(page).to have_css(".op-toast.-error", text: expected)
+ expect_primerized_error(expected)
index_page.add_model_allowed false
end
diff --git a/modules/bim/spec/features/model_viewer_spec.rb b/modules/bim/spec/features/model_viewer_spec.rb
index 432570b68d59..58badac51229 100644
--- a/modules/bim/spec/features/model_viewer_spec.rb
+++ b/modules/bim/spec/features/model_viewer_spec.rb
@@ -93,7 +93,7 @@
it "shows a warning that no IFC models exist yet" do
login_as user
visit defaults_bcf_project_ifc_models_path(project)
- expect(page).to have_css(".op-toast.-info", text: I18n.t("js.ifc_models.empty_warning"))
+ expect_primerized_flash(type: :info, message: I18n.t("js.ifc_models.empty_warning"))
end
end
end
@@ -134,7 +134,7 @@
it "shows no viewer" do
expected = "[Error 403] You are not authorized to access this page."
- expect(page).to have_css(".op-toast.-error", text: expected)
+ expect_primerized_error(expected)
show_model_page.model_viewer_visible false
show_model_page.model_viewer_shows_a_toolbar false
diff --git a/modules/boards/spec/features/board_management_spec.rb b/modules/boards/spec/features/board_management_spec.rb
index 7b135a8dd8b1..cbc2ad6ca2f2 100644
--- a/modules/boards/spec/features/board_management_spec.rb
+++ b/modules/boards/spec/features/board_management_spec.rb
@@ -300,7 +300,7 @@
it "does not allow viewing of boards" do
visit project_work_package_board_path(project, board_view)
- expect(page).to have_css("#errorExplanation", text: I18n.t(:notice_not_authorized))
+ expect_primerized_error(I18n.t(:notice_not_authorized))
board_index.expect_editable false
end
@@ -311,7 +311,7 @@
it "does not allow viewing of boards" do
board_index.visit!
- expect(page).to have_css("#errorExplanation", text: I18n.t(:notice_not_authorized))
+ expect_primerized_error(I18n.t(:notice_not_authorized))
end
end
end
diff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rb
index cb9535c146cb..7d35d989ca6d 100644
--- a/modules/boards/spec/features/support/board_index_page.rb
+++ b/modules/boards/spec/features/support/board_index_page.rb
@@ -72,7 +72,7 @@ def create_board(action: "Basic", title: "#{action} Board", expect_empty: false,
new_board_page.set_board_type action
new_board_page.click_on_submit
- new_board_page.expect_and_dismiss_toaster
+ expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_create))
if expect_empty
expect(page).to have_css(".boards-list--add-item-text", wait: 10)
diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb
index 6594631e11d6..41dc462def96 100644
--- a/modules/boards/spec/features/support/board_page.rb
+++ b/modules/boards/spec/features/support/board_page.rb
@@ -284,7 +284,7 @@ def delete_board
click_dropdown_entry "Delete"
accept_alert_dialog!
- expect_and_dismiss_toaster message: I18n.t("js.notice_successful_delete")
+ expect_and_dismiss_primerized_flash message: I18n.t("js.notice_successful_delete")
end
def back_to_index
diff --git a/modules/budgets/spec/features/budgets/add_budget_spec.rb b/modules/budgets/spec/features/budgets/add_budget_spec.rb
index 7468c4f6cecd..31cb1db2ffea 100644
--- a/modules/budgets/spec/features/budgets/add_budget_spec.rb
+++ b/modules/budgets/spec/features/budgets/add_budget_spec.rb
@@ -122,7 +122,7 @@
new_budget_page.add_labor_costs! "0,5", user_name: user.name, comment: "attendance", expected_costs: "12,50 EUR"
page.find('[data-test-selector="budgets-create-button"]').click
- expect(page).to have_content(I18n.t(:notice_successful_create, locale: :de))
+ expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_create, locale: :de))
expect(new_budget_page.unit_costs_at(1)).to have_content "175,00 EUR"
expect(new_budget_page.unit_costs_at(2)).to have_content "50.025,00 EUR"
diff --git a/modules/budgets/spec/features/budgets/copy_budget_spec.rb b/modules/budgets/spec/features/budgets/copy_budget_spec.rb
index ddd4cead7b8e..6d327d4aef54 100644
--- a/modules/budgets/spec/features/budgets/copy_budget_spec.rb
+++ b/modules/budgets/spec/features/budgets/copy_budget_spec.rb
@@ -88,7 +88,7 @@
click_button "Create"
- budget_page.expect_toast message: "Successful creation."
+ expect_primerized_flash message: "Successful creation."
expect(page)
.to have_css(".author", text: current_user.name)
diff --git a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb
index 45bb72287dc6..de2b07cffda5 100644
--- a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb
+++ b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb
@@ -99,7 +99,7 @@
click_on "Save"
# Expect correct costs
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_cost_logged_successfully))
+ expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully))
entry = CostEntry.last
expect(entry.cost_type_id).to eq(cost_type2.id)
expect(entry.units).to eq(2.0)
@@ -136,7 +136,7 @@
click_on I18n.t(:button_save)
# Expect correct costs
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_cost_logged_successfully))
+ expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully))
entry = CostEntry.last
expect(entry.cost_type_id).to eq(cost_type2.id)
expect(entry.units).to eq(1.42)
diff --git a/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb b/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb
index 9251a61176d7..ce5e0bc12dfa 100644
--- a/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb
+++ b/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb
@@ -77,7 +77,7 @@
click_on "Save"
# Expect correct costs
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_cost_logged_successfully))
+ expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully))
entry = CostEntry.last
expect(entry.cost_type_id).to eq(cost_type.id)
expect(entry.units).to eq(1.0)
diff --git a/modules/ldap_groups/spec/features/administration_spec.rb b/modules/ldap_groups/spec/features/administration_spec.rb
index 98570a21c8da..fa2110dbe21c 100644
--- a/modules/ldap_groups/spec/features/administration_spec.rb
+++ b/modules/ldap_groups/spec/features/administration_spec.rb
@@ -35,7 +35,7 @@
check "synchronized_group_sync_users"
click_on "Create"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_create))
+ expect_primerized_flash(message: I18n.t(:notice_successful_create))
expect(page).to have_css("td.dn", text: "cn=foo,ou=groups,dc=example,dc=com")
expect(page).to have_css("td.ldap_auth_source", text: "ldap")
expect(page).to have_css("td.group", text: "foo")
@@ -69,7 +69,7 @@
SeleniumHubWaiter.wait
click_on "Delete"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_delete))
+ expect_primerized_flash(message: I18n.t(:notice_successful_delete))
expect(page).to have_css ".generic-table--empty-row"
expect(LdapGroups::Membership.where(id: memberships)).to be_empty
diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb
index 3f121a2cd395..3987e81a9f88 100644
--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb
+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb
@@ -167,8 +167,7 @@
expect(response).to have_http_status :ok
expect(response).to render_template :new
expect(response.body)
- .to have_css "#errorExplanation li",
- text: "Date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}"
+ .to have_text("Date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}")
end
end
@@ -181,8 +180,7 @@
expect(response).to have_http_status :ok
expect(response).to render_template :new
expect(response.body)
- .to have_css "#errorExplanation li",
- text: "Start time #{I18n.t('activerecord.errors.messages.invalid_time_format')}"
+ .to have_text("Start time #{I18n.t('activerecord.errors.messages.invalid_time_format')}")
end
end
end
@@ -194,8 +192,7 @@
expect(response).to have_http_status :ok
expect(response).to render_template :new
expect(response.body)
- .to have_css "#errorExplanation li",
- text: "Project #{I18n.t('activerecord.errors.messages.blank')}"
+ .to have_text("Project #{I18n.t('activerecord.errors.messages.blank')}")
end
end
@@ -207,8 +204,7 @@
expect(response).to have_http_status :ok
expect(response).to render_template :new
expect(response.body)
- .to have_css "#errorExplanation li",
- text: "Project #{I18n.t('activerecord.errors.messages.blank')}"
+ .to have_text("Project #{I18n.t('activerecord.errors.messages.blank')}")
end
end
end
diff --git a/modules/meeting/spec/features/meetings_participants_spec.rb b/modules/meeting/spec/features/meetings_participants_spec.rb
index 79de4ab783b6..fb368810e166 100644
--- a/modules/meeting/spec/features/meetings_participants_spec.rb
+++ b/modules/meeting/spec/features/meetings_participants_spec.rb
@@ -64,7 +64,7 @@
edit_page.invite(viewer_user)
show_page = edit_page.click_save
- show_page.expect_toast(message: "Successful update")
+ expect_primerized_flash(message: "Successful update")
show_page.expect_invited(viewer_user)
diff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rb
index 64c7e1047f99..ffafbdaea5e3 100644
--- a/modules/meeting/spec/features/structured_meetings/history_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb
@@ -355,6 +355,6 @@
visit history_meeting_path(meeting)
expected = "[Error 403] You are not authorized to access this page."
- expect(page).to have_css(".op-toast.-error", text: expected)
+ expect_primerized_error(expected)
end
end
diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
index cc8c3a5c3ba8..729b86325edb 100644
--- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
+++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
@@ -78,7 +78,7 @@ def edit_cost_entry(new_value, row, cost_entry_id)
SeleniumHubWaiter.wait
fill_in("cost_entry_units", with: new_value)
click_button "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
end
def delete_entry(row)
diff --git a/modules/storages/spec/features/storages/admin/create_storage_spec.rb b/modules/storages/spec/features/storages/admin/create_storage_spec.rb
index bf5c1781c22b..a59d19c73606 100644
--- a/modules/storages/spec/features/storages/admin/create_storage_spec.rb
+++ b/modules/storages/spec/features/storages/admin/create_storage_spec.rb
@@ -181,7 +181,7 @@
expect(page).to have_current_path(edit_admin_settings_storage_path(Storages::Storage.last))
expect(page).to have_test_selector(
- "primer-banner-message-component",
+ "op-primer-flash-message",
text: "Storage connected successfully! Remember to activate the module and the specific " \
"storage in the project settings of each desired project to use it."
)
@@ -318,7 +318,7 @@
expect(page).to have_current_path(edit_admin_settings_storage_path(Storages::Storage.last))
wait_for { page }.to have_test_selector(
- "primer-banner-message-component",
+ "op-primer-flash-message",
text: "Storage connected successfully! Remember to activate the module and the specific " \
"storage in the project settings of each desired project to use it."
)
diff --git a/modules/two_factor_authentication/spec/features/account_activation_spec.rb b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
index 7d1f3118bd5e..111c2bf10e2d 100644
--- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb
+++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
@@ -50,7 +50,7 @@ def activate!
activate!
- expect(page).to have_css(".op-toast.-success", text: "Developer strategy generated the following one-time password:")
+ expect_primerized_flash(message: "Developer strategy generated the following one-time password:")
SeleniumHubWaiter.wait
fill_in I18n.t(:field_otp), with: sms_token
@@ -63,7 +63,7 @@ def activate!
it "handles faulty user input on two factor authentication" do
activate!
- expect(page).to have_css(".op-toast.-success", text: "Developer strategy generated the following one-time password:")
+ expect_primerized_flash(message: "Developer strategy generated the following one-time password:")
fill_in I18n.t(:field_otp), with: "asdf" # faulty token
click_button I18n.t(:button_login)
diff --git a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb
index 86c5d6230c37..6d868259c624 100644
--- a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb
@@ -44,7 +44,7 @@
click_button I18n.t(:button_continue)
# Enter valid phone number
- expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX")
+ expect_primerized_error("Phone number must be of format +XX XXXXXXXXX")
SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "+49 123456789"
diff --git a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
index 628c10f9e54a..b2bfe0e63102 100644
--- a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
+++ b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
@@ -50,7 +50,7 @@
click_on "Submit"
# Expect failure
- expect(page).to have_css(".op-toast.-error", text: I18n.t("two_factor_authentication.error_invalid_backup_code"))
+ expect_primerized_error(I18n.t("two_factor_authentication.error_invalid_backup_code"))
expect(page).to have_current_path signin_path
# Try again!
diff --git a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb
index 18f840fdacdb..7af11b31c1f7 100644
--- a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb
+++ b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb
@@ -36,7 +36,7 @@
first_login_step
two_factor_step("whatever")
- expect(page).to have_css(".op-toast.-error", text: I18n.t(:notice_account_otp_invalid))
+ expect_primerized_error(I18n.t(:notice_account_otp_invalid))
expect(page).to have_current_path signin_path
end
end
diff --git a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb
index 52a93882d145..75df63bbf05e 100644
--- a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb
+++ b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb
@@ -35,7 +35,7 @@
first_login_step
two_factor_step("whatever")
- expect(page).to have_css(".op-toast.-error", text: I18n.t(:notice_account_otp_invalid))
+ expect_primerized_error(I18n.t(:notice_account_otp_invalid))
expect(page).to have_current_path signin_path
end
end
diff --git a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb
index 454362cc5a9a..0271c7f9ec45 100644
--- a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb
@@ -35,7 +35,7 @@
click_button I18n.t(:button_continue)
# Enter valid phone number
- expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX")
+ expect_primerized_error("Phone number must be of format +XX XXXXXXXXX")
fill_in "device_phone_number", with: "+49 123456789"
click_button I18n.t(:button_continue)
@@ -55,8 +55,8 @@
expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device"))
expect(page).to have_css("input#otp")
- expect(page).to have_css(".op-toast.-error",
- text: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid"))
+
+ expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid"))
# Fill in correct token
fill_in "otp", with: sms_token
diff --git a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb
index dc11cfc15754..a697444107d0 100644
--- a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb
+++ b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb
@@ -60,7 +60,7 @@ def expect_no_autologin
visit my_2fa_devices_path
find(".two-factor-authentication--remove-remember-cookie-link").click
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
expect(page).to have_no_css(".two-factor-authentication--remove-remember-cookie-link")
# Log out and in again
diff --git a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
index 461a35b159bc..73ff99151e03 100644
--- a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
+++ b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
@@ -35,8 +35,8 @@ def expect_not_logged_in
RSpec.shared_examples "create enforced sms device" do
it do
- expect(page).to have_css(".op-toast.-info",
- text: I18n.t("two_factor_authentication.forced_registration.required_to_add_device"))
+ expect_primerized_flash(type: :info,
+ message: I18n.t("two_factor_authentication.forced_registration.required_to_add_device"))
SeleniumHubWaiter.wait
# Create SMS device
@@ -46,7 +46,7 @@ def expect_not_logged_in
click_on "Continue"
# Expect error on invalid phone
- expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX")
+ expect_primerized_error("Phone number must be of format +XX XXXXXXXXX")
SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "+49 123456789"
diff --git a/modules/webhooks/spec/features/manage_webhooks_spec.rb b/modules/webhooks/spec/features/manage_webhooks_spec.rb
index dad6fbf95bfc..021974c191da 100644
--- a/modules/webhooks/spec/features/manage_webhooks_spec.rb
+++ b/modules/webhooks/spec/features/manage_webhooks_spec.rb
@@ -40,7 +40,7 @@
# 1st webhook created
#
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_create))
+ expect_primerized_flash(message: I18n.t(:notice_successful_create))
expect(page).to have_css(".webhooks--outgoing-webhook-row .name", text: "My webhook")
webhook = Webhooks::Webhook.last
expect(webhook.event_names).to eq %w(work_package:created)
@@ -65,7 +65,7 @@
find(".webhooks--selected-project-ids[value='#{project.id}']").set true
click_on "Save"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
expect(page).to have_css(".webhooks--outgoing-webhook-row .name", text: "My webhook")
webhook = Webhooks::Webhook.last
expect(webhook.event_names).to eq %w(work_package:updated)
@@ -77,7 +77,7 @@
find(".webhooks--outgoing-webhook-row-#{webhook.id} .icon-delete").click
page.driver.browser.switch_to.alert.accept
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_delete))
+ expect_primerized_flash(message: I18n.t(:notice_successful_delete))
expect(page).to have_css(".generic-table--empty-row")
end
diff --git a/spec/controllers/news_controller_spec.rb b/spec/controllers/news_controller_spec.rb
index 1152e0395494..d4cc219016a4 100644
--- a/spec/controllers/news_controller_spec.rb
+++ b/spec/controllers/news_controller_spec.rb
@@ -133,7 +133,7 @@
expect(assigns(:news)).not_to be_nil
expect(assigns(:news)).to be_new_record
- expect(response.body).to have_css("div.op-toast.-error", text: /1 error/)
+ expect(response.body).to have_text /1 error/
end
end
diff --git a/spec/features/activities/wiki_activity_spec.rb b/spec/features/activities/wiki_activity_spec.rb
index 05db9c7e71e5..5fa22673c09c 100644
--- a/spec/features/activities/wiki_activity_spec.rb
+++ b/spec/features/activities/wiki_activity_spec.rb
@@ -52,7 +52,8 @@
editor.set_markdown("First content")
click_button "Save"
- expect(page).to have_text("Successful creation")
+
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
# We mock letting some time pass by altering the timestamps
Journal.last.update_columns(created_at: Time.now - 5.days, updated_at: Time.now - 5.days)
diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rb
index f9b0e0b08aaf..ad855dc80aff 100644
--- a/spec/features/admin/attribute_help_texts_spec.rb
+++ b/spec/features/admin/attribute_help_texts_spec.rb
@@ -113,7 +113,7 @@
click_button "Save"
# Handle errors
- expect(page).to have_css("#errorExplanation", text: "Help text can't be blank.")
+ expect_primerized_error("Help text can't be blank.")
SeleniumHubWaiter.wait
editor.set_markdown("New**help**text")
click_button "Save"
diff --git a/spec/features/admin/enterprise/enterprise_spec.rb b/spec/features/admin/enterprise/enterprise_spec.rb
index 671c6db311f4..78e92e56d345 100644
--- a/spec/features/admin/enterprise/enterprise_spec.rb
+++ b/spec/features/admin/enterprise/enterprise_spec.rb
@@ -60,9 +60,7 @@
submit_button.click
# Error output
- expect(page).to have_css(".errorExplanation",
- text: "Enterprise support token can't be read. " \
- "Are you sure it is a support token?")
+ expect_primerized_error("Enterprise support token can't be read. Are you sure it is a support token?")
within "span.errorSpan" do
expect(page).to have_css("#enterprise_token_encoded_token")
@@ -78,7 +76,7 @@
textarea.set "foobar"
submit_button.click
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
expect(page).to have_test_selector("op-enterprise--active-token")
expect(page.all(".attributes-key-value--key").map(&:text))
@@ -101,7 +99,7 @@
wait_for_reload
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
# Assume next request
RequestStore.clear!
@@ -115,7 +113,7 @@
wait_for_reload
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_delete))
+ expect_primerized_flash(message: I18n.t(:notice_successful_delete))
# Assume next request
RequestStore.clear!
diff --git a/spec/features/admin/enterprise/enterprise_trial_spec.rb b/spec/features/admin/enterprise/enterprise_trial_spec.rb
index 8d5034e4caca..b7cc52fd549e 100644
--- a/spec/features/admin/enterprise/enterprise_trial_spec.rb
+++ b/spec/features/admin/enterprise/enterprise_trial_spec.rb
@@ -257,7 +257,7 @@ def fill_out_modal(mail: "foo@foocorp.example")
it "can confirm that trial regularly" do
find_test_selector("op-ee-trial-waiting-resend-link", text: "Resend").click
- expect(page).to have_css(".op-toast.-success", text: "Email has been resent.", wait: 20)
+ expect_primerized_flash(message: "Email has been resent.", wait: 20)
expect(page).to have_text "foo@foocorp.example"
expect(page).to have_text "email sent - waiting for confirmation"
@@ -276,7 +276,7 @@ def fill_out_modal(mail: "foo@foocorp.example")
# advance to close
click_on "Continue"
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
expect(page).to have_css(".attributes-key-value--value-container", text: "OpenProject Test")
expect(page).to have_css(".attributes-key-value--value-container", text: "01/01/2020")
expect(page).to have_css(".attributes-key-value--value-container", text: "01/02/2020")
diff --git a/spec/features/admin/oauth/oauth_applications_management_spec.rb b/spec/features/admin/oauth/oauth_applications_management_spec.rb
index fd7c4bbbb1c6..146061496891 100644
--- a/spec/features/admin/oauth/oauth_applications_management_spec.rb
+++ b/spec/features/admin/oauth/oauth_applications_management_spec.rb
@@ -49,20 +49,20 @@
fill_in "application_redirect_uri", with: "not a url!"
click_on "Create"
- expect(page).to have_css(".errorExplanation", text: "Redirect URI must be an absolute URI.")
+ expect_primerized_error("Redirect URI must be an absolute URI.")
fill_in("application_redirect_uri", with: "")
# Fill redirect_uri which does not provide a Secure Context
fill_in "application_redirect_uri", with: "http://example.org"
click_on "Create"
- expect(page).to have_css(".errorExplanation", text: 'Redirect URI is not providing a "Secure Context"')
+ expect_primerized_error('Redirect URI is not providing a "Secure Context"')
# Can create localhost without https (https://community.openproject.com/wp/34025)
fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback"
click_on "Create"
- expect(page).to have_css(".op-toast.-success", text: "Successful creation.")
+ expect_primerized_flash(message: "Successful creation.")
expect(page).to have_css(".attributes-key-value--key", text: "Client ID")
expect(page).to have_css(".attributes-key-value--value", text: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback")
diff --git a/spec/features/admin/progress_tracking_spec.rb b/spec/features/admin/progress_tracking_spec.rb
index c103592437f8..c5236736de4e 100644
--- a/spec/features/admin/progress_tracking_spec.rb
+++ b/spec/features/admin/progress_tracking_spec.rb
@@ -52,7 +52,7 @@
expect(page).to have_text(expected_warning_text)
click_on "Save"
- expect_and_dismiss_toaster(message: "Successful update.")
+ expect_and_dismiss_primerized_flash(message: "Successful update.")
expect(Setting.find_by(name: "work_package_done_ratio").value).to eq("status")
# now change from status-based to work-based
@@ -66,7 +66,7 @@
expect(page).to have_text(expected_warning_text)
click_on "Save"
- expect_and_dismiss_toaster(message: "Successful update.")
+ expect_and_dismiss_primerized_flash(message: "Successful update.")
expect(Setting.find_by(name: "work_package_done_ratio").value).to eq("field")
end
diff --git a/spec/features/admin/test_mail_notification_spec.rb b/spec/features/admin/test_mail_notification_spec.rb
index a233bef9d23c..97b2d3579ecc 100644
--- a/spec/features/admin/test_mail_notification_spec.rb
+++ b/spec/features/admin/test_mail_notification_spec.rb
@@ -44,7 +44,7 @@
click_link "Send a test email"
expected = "An error occurred while sending mail (#{error_message})"
- expect(page).to have_css(".op-toast.-error", text: expected)
+ expect_primerized_error(expected)
expect(page).to have_no_css(".op-toast.-error strong")
end
end
diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb
index dc49660bf8b9..a924c89f56c9 100644
--- a/spec/features/admin/working_days_spec.rb
+++ b/spec/features/admin/working_days_spec.rb
@@ -101,7 +101,7 @@ def working_days_setting
dialog.confirm
end
- expect(page).to have_css(".op-toast.-success", text: "Successful update.")
+ expect_primerized_flash(message: "Successful update.")
expect(page).to have_unchecked_field "Monday"
expect(page).to have_unchecked_field "Friday"
expect(page).to have_unchecked_field "Saturday"
@@ -230,7 +230,7 @@ def working_days_setting
click_on "Apply changes"
click_on "Save and reschedule"
- expect(page).to have_css(".op-toast.-success", text: "Successful update.")
+ expect_primerized_flash(message: "Successful update.")
nwd1 = NonWorkingDay.find_by(name: "My holiday")
expect(nwd1.date).to eq date1
@@ -310,6 +310,6 @@ def working_days_setting
click_on "Apply changes"
# No dialog and saved successfully
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
end
end
diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb
index e58cd7e7f5e0..e7819da395af 100644
--- a/spec/features/auth/consent_auth_stage_spec.rb
+++ b/spec/features/auth/consent_auth_stage_spec.rb
@@ -168,7 +168,7 @@ def expect_not_logged_in
find_by_id("toggle_consent_time").set(true)
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
Setting.clear_cache
expect(Setting.consent_time).to be_present
@@ -215,7 +215,7 @@ def expect_not_logged_in
check "consent_check"
click_on I18n.t(:button_create)
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
expect_logged_in("/?first_time_user=true")
end
@@ -256,7 +256,7 @@ def expect_not_logged_in
# Decline the consent
click_on I18n.t(:button_decline)
- expect(page).to have_css(".op-toast.-error", text: "foo@example.org")
+ expect_primerized_error("foo@example.org")
end
end
end
diff --git a/spec/features/auth/lost_password_spec.rb b/spec/features/auth/lost_password_spec.rb
index dcfb91ce1b99..7bfd9be964d2 100644
--- a/spec/features/auth/lost_password_spec.rb
+++ b/spec/features/auth/lost_password_spec.rb
@@ -39,14 +39,14 @@
fill_in "mail", with: "invalid mail"
click_on "Submit"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent))
+ expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent))
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to be 0
fill_in "mail", with: user.mail
click_on "Submit"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent))
+ expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent))
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to be 1
@@ -60,7 +60,7 @@
click_button "Save"
- expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_account_password_updated))
+ expect_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated))
login_with user.login, new_password
@@ -79,7 +79,7 @@
fill_in "mail", with: user.mail
click_on "Submit"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent))
+ expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent))
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to be 1
@@ -99,7 +99,7 @@
fill_in "mail", with: user.mail
click_on "Submit"
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent))
+ expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent))
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to be 1
diff --git a/spec/features/custom_fields/reorder_options_spec.rb b/spec/features/custom_fields/reorder_options_spec.rb
index cd2274c5c3a6..dc396d030470 100644
--- a/spec/features/custom_fields/reorder_options_spec.rb
+++ b/spec/features/custom_fields/reorder_options_spec.rb
@@ -38,7 +38,7 @@ def get_possible_values_reordered(amount)
click_link "Reorder values alphabetically"
cf_page.accept_alert_dialog!
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
expect(custom_field.custom_options.order(:position).pluck(:value))
.to eq get_possible_values_reordered(200)
end
diff --git a/spec/features/custom_styles/tabs_navigation_spec.rb b/spec/features/custom_styles/tabs_navigation_spec.rb
index 2017ef6c6063..98b0e1bcdd1b 100644
--- a/spec/features/custom_styles/tabs_navigation_spec.rb
+++ b/spec/features/custom_styles/tabs_navigation_spec.rb
@@ -60,7 +60,7 @@
it "selects a color theme and redirect to the interface tab" do
select("OpenProject Gray", from: "theme")
find("[data-test-selector='color-theme-button']").click
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
expect(page).to have_current_path custom_style_path(tab: "interface")
end
@@ -78,7 +78,7 @@
# select a color theme and redirect to the branding tab
select("OpenProject Navy Blue", from: "theme")
find("[data-test-selector='color-theme-button']").click
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
expect(page).to have_current_path custom_style_path(tab: "branding")
# remove the logo and redirect to the branding tab
@@ -94,7 +94,7 @@
# select a color theme and redirect to the PDF export styles tab
select("OpenProject (default)", from: "theme")
find("[data-test-selector='color-theme-button']").click
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
expect(page).to have_current_path custom_style_path(tab: "pdf_export_styles")
# change export cover text color and redirect to the PDF export styles tab
diff --git a/spec/features/groups/groups_spec.rb b/spec/features/groups/groups_spec.rb
index b939d9bdc4cb..a7a74cb93d9c 100644
--- a/spec/features/groups/groups_spec.rb
+++ b/spec/features/groups/groups_spec.rb
@@ -45,7 +45,7 @@
groups_page.delete_group! "Bob's Team"
- expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_deletion_scheduled))
+ expect_primerized_flash(type: :info, message: I18n.t(:notice_deletion_scheduled))
expect(groups_page).to have_group "Bob's Team"
perform_enqueued_jobs
diff --git a/spec/features/ldap_auth_sources/crud_spec.rb b/spec/features/ldap_auth_sources/crud_spec.rb
index b44c7a6b7650..96e3f49f75c9 100644
--- a/spec/features/ldap_auth_sources/crud_spec.rb
+++ b/spec/features/ldap_auth_sources/crud_spec.rb
@@ -52,7 +52,7 @@
click_on "Create"
- ldap_page.expect_and_dismiss_toaster message: "Successful creation."
+ expect_and_dismiss_primerized_flash message: "Successful creation."
expect(page).to have_css("td.name", text: "My LDAP connection")
expect(page).to have_css("td.host", text: "localhost")
@@ -71,7 +71,7 @@
accept_prompt { click_on "Delete" }
end
- ldap_page.expect_and_dismiss_toaster message: "Successful deletion."
+ expect_and_dismiss_primerized_flash message: "Successful deletion."
expect(page).to have_no_text "My LDAP connection"
expect(page).to have_text "Admin connection"
diff --git a/spec/features/members/pagination_spec.rb b/spec/features/members/pagination_spec.rb
index 22af2711d586..9001110667ae 100644
--- a/spec/features/members/pagination_spec.rb
+++ b/spec/features/members/pagination_spec.rb
@@ -84,7 +84,7 @@
members_page.visit!
SeleniumHubWaiter.wait
members_page.remove_user! "Alice Alison"
- members_page.expect_and_dismiss_toaster
+ expect_and_dismiss_primerized_flash message: "Removed Alice Alison from project"
expect(members_page).to have_user "Bob Bobbit"
SeleniumHubWaiter.wait
diff --git a/spec/features/oauth/authorization_code_flow_spec.rb b/spec/features/oauth/authorization_code_flow_spec.rb
index 5b1c95963f6c..fe27bf3b22cb 100644
--- a/spec/features/oauth/authorization_code_flow_spec.rb
+++ b/spec/features/oauth/authorization_code_flow_spec.rb
@@ -101,7 +101,7 @@ def get_and_test_token(code)
page.driver.browser.switch_to.alert.accept
# Should be back on access_token path
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
expect(page).to have_no_css("[id^=oauth-application-grant]")
expect(page).to have_current_path /\/my\/access_token/
diff --git a/spec/features/placeholder_users/delete_spec.rb b/spec/features/placeholder_users/delete_spec.rb
index fc5cd182d0c7..59bc17626334 100644
--- a/spec/features/placeholder_users/delete_spec.rb
+++ b/spec/features/placeholder_users/delete_spec.rb
@@ -49,7 +49,7 @@
expect(page).to have_css(".danger-zone--verification button:not([disabled])")
click_on "Delete"
- expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_deletion_scheduled))
+ expect_primerized_flash(type: :info, message: I18n.t(:notice_deletion_scheduled))
# The user is still there
placeholder_user.reload
diff --git a/spec/features/placeholder_users/edit_placeholder_users_spec.rb b/spec/features/placeholder_users/edit_placeholder_users_spec.rb
index aabffc353394..4d2fa380a893 100644
--- a/spec/features/placeholder_users/edit_placeholder_users_spec.rb
+++ b/spec/features/placeholder_users/edit_placeholder_users_spec.rb
@@ -41,7 +41,7 @@
click_on "Save"
- expect(page).to have_css(".op-toast.-success", text: "Successful update.")
+ expect_primerized_flash(message: "Successful update.")
placeholder_user.reload
diff --git a/spec/features/principals/shared_memberships_examples.rb b/spec/features/principals/shared_memberships_examples.rb
index b326337add17..2dc6130e3747 100644
--- a/spec/features/principals/shared_memberships_examples.rb
+++ b/spec/features/principals/shared_memberships_examples.rb
@@ -30,7 +30,7 @@
principal_page.expect_project(project.name)
principal_page.edit_roles!(member, %w())
- expect(page).to have_css(".op-toast.-error", text: "Roles need to be assigned.")
+ expect_primerized_flash(type: :error, message: "Roles need to be assigned.")
# Remove the user from the project
principal_page.remove_from_project!(project.name)
diff --git a/spec/features/projects/destroy_spec.rb b/spec/features/projects/destroy_spec.rb
index 9b2481f75c02..c666f4afe177 100644
--- a/spec/features/projects/destroy_spec.rb
+++ b/spec/features/projects/destroy_spec.rb
@@ -53,7 +53,7 @@
expect(danger_zone).not_to be_disabled
danger_zone.danger_button.click
- expect(page).to have_css ".op-toast.-success", text: I18n.t("projects.delete.scheduled")
+ expect_primerized_flash message: I18n.t("projects.delete.scheduled")
expect(project.reload).to eq(project)
perform_enqueued_jobs
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb
index 9953fa86e5bd..14c9eb685287 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb
@@ -117,7 +117,7 @@
member_with_project_attributes_edit_permissions.reload
dialog.submit
- expect(page).to have_css("#errorExplanation", text: I18n.t(:notice_not_authorized))
+ expect_primerized_error(I18n.t(:notice_not_authorized))
end
end
end
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb
index 9ddb9d5fecbc..20e862d4ab14 100644
--- a/spec/features/projects/projects_index_spec.rb
+++ b/spec/features/projects/projects_index_spec.rb
@@ -274,9 +274,9 @@ def load_and_open_filters(user)
error_text = "Orders > is not set to one of the allowed values. and does not exist."
error_html = "Orders ><script src='/foobar js'></script> is not set to one of the allowed values. and does not exist."
- expect(page).to have_css(".op-toast.-error", text: error_text)
+ expect_primerized_error(error_text)
- error_container = page.find(".op-toast.-error")
+ error_container = find_primerized_flash(type: :error)
expect(error_container["innerHTML"]).to include error_html
end
end
diff --git a/spec/features/projects/projects_portfolio_spec.rb b/spec/features/projects/projects_portfolio_spec.rb
index d5f805c233a6..886c9fd62b5e 100644
--- a/spec/features/projects/projects_portfolio_spec.rb
+++ b/spec/features/projects/projects_portfolio_spec.rb
@@ -115,7 +115,7 @@
# Save the page
scroll_to_and_click(find(".button", text: "Save"))
- expect(page).to have_css(".op-toast.-success", text: "Successful update.")
+ expect_primerized_flash(message: "Successful update.")
RequestStore.clear!
query = JSON.parse Setting.project_gantt_query
diff --git a/spec/features/projects/template_spec.rb b/spec/features/projects/template_spec.rb
index 2f07f26befec..7b7d800f262a 100644
--- a/spec/features/projects/template_spec.rb
+++ b/spec/features/projects/template_spec.rb
@@ -44,6 +44,7 @@
# Make a template
find(".button", text: "Set as template").click
+ expect_and_dismiss_primerized_flash(message: "Succesful update.")
expect(page).to have_css(".button", text: "Remove from templates")
project.reload
diff --git a/spec/features/roles/create_spec.rb b/spec/features/roles/create_spec.rb
index 8aa9185a917e..9ef403e7401b 100644
--- a/spec/features/roles/create_spec.rb
+++ b/spec/features/roles/create_spec.rb
@@ -55,8 +55,7 @@
click_button "Create"
- expect(page)
- .to have_css(".errorExplanation", text: "Name has already been taken")
+ expect_primerized_error("Name has already been taken")
fill_in "Name", with: "New role name"
@@ -65,17 +64,14 @@
click_button "Create"
- expect(page)
- .to have_css(".errorExplanation",
- text: "Permissions need to also include 'View members' as 'Manage members' is selected.")
+ expect_primerized_error("Permissions need to also include 'View members' as 'Manage members' is selected.")
check "View members"
select existing_role.name, from: "Copy workflow from"
click_button "Create"
- expect(page)
- .to have_css(".-success", text: "Successful creation.")
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
expect(page)
.to have_current_path(roles_path)
diff --git a/spec/features/types/crud_spec.rb b/spec/features/types/crud_spec.rb
index 427fbb4e99a0..37434bf36063 100644
--- a/spec/features/types/crud_spec.rb
+++ b/spec/features/types/crud_spec.rb
@@ -52,8 +52,7 @@
click_button "Create"
- expect(page)
- .to have_css(".errorExplanation", text: "Name has already been taken.")
+ expect_primerized_error("Name has already been taken.")
# Values are retained
expect(page)
@@ -123,9 +122,7 @@
end
it "renders an error message with links to the archived project in the projects list" do
- within ".op-toast.-error" do
- expect(page).to have_link(project.name)
- end
+ expect_primerized_error project.name
end
end
end
diff --git a/spec/features/types/form_configuration_query_spec.rb b/spec/features/types/form_configuration_query_spec.rb
index c777fbd811b9..4c178f1bb720 100644
--- a/spec/features/types/form_configuration_query_spec.rb
+++ b/spec/features/types/form_configuration_query_spec.rb
@@ -93,7 +93,7 @@
it "can save an empty query group" do
form.add_query_group("Empty test", :children)
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
type_bug.reload
query_group = type_bug.attribute_groups.detect { |x| x.is_a?(Type::QueryGroup) }
@@ -105,7 +105,7 @@
form.add_query_group("Subtasks", :children)
# Save changed query
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
# Visit wp_table
wp_table.visit!
@@ -131,7 +131,7 @@
form.add_query_group("Subtasks", :children)
# Save changed query
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
# Visit new wp page
visit new_project_work_packages_path(project)
@@ -156,7 +156,7 @@
filters.save
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash message: "Successful update."
archived.update_attribute(:active, false)
@@ -184,7 +184,7 @@
# Save changed query
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
type_bug.reload
query = type_bug.attribute_groups.detect { |x| x.key == "Columns Test" }
@@ -206,7 +206,7 @@
# Save changed query
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
type_bug.reload
query = type_bug.attribute_groups.detect { |x| x.key == "Columns Test" }
@@ -253,7 +253,7 @@
filters.save
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
# Visit work package with that type
wp_page.visit!
diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb
index 837ab3b88d60..75b6c930b7df 100644
--- a/spec/features/types/form_configuration_spec.rb
+++ b/spec/features/types/form_configuration_spec.rb
@@ -91,7 +91,7 @@
# Save configuration
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
form.expect_empty
@@ -171,7 +171,7 @@
# Save configuration
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
# Expect configuration to be correct now
form.expect_no_attribute("assignee", "Cool Stuff")
@@ -269,7 +269,7 @@
form.expect_attribute(key: cf_identifier)
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
end
end
@@ -299,7 +299,7 @@ def add_cf_to_group
form.expect_attribute(key: cf_identifier)
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
end
context "if inactive in project" do
diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb
index f5bab6ebb1af..43ac566757eb 100644
--- a/spec/features/types/reset_form_configuration_spec.rb
+++ b/spec/features/types/reset_form_configuration_spec.rb
@@ -60,7 +60,7 @@
form.expect_attribute(key: cf_identifier)
form.save_changes
- expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10)
+ expect_primerized_flash(message: "Successful update.")
SeleniumHubWaiter.wait
form.reset_button.click
diff --git a/spec/features/users/edit_users_spec.rb b/spec/features/users/edit_users_spec.rb
index 3bf3e54961b8..650701e321fc 100644
--- a/spec/features/users/edit_users_spec.rb
+++ b/spec/features/users/edit_users_spec.rb
@@ -127,7 +127,7 @@ def have_visible_tab(label)
click_button "Save"
- expect(page).to have_css(".op-toast.-success", text: "Successful update.")
+ expect_primerized_flash(message: "Successful update.")
user.reload
@@ -140,7 +140,7 @@ def have_visible_tab(label)
click_on "Send invitation"
- expect(page).to have_css(".op-toast.-success", text: "An invitation has been sent to foo@example.com")
+ expect_primerized_flash(message: "An invitation has been sent to foo@example.com")
end
it "can not edit attributes of an admin user" do
diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rb
index 9ca3dbb59304..1736832fa2b2 100644
--- a/spec/features/users/password_change_spec.rb
+++ b/spec/features/users/password_change_spec.rb
@@ -60,7 +60,7 @@
click_on "Save"
- expect(page).to have_css(".op-toast", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: "Successful update.")
expect(password).to be_present
# Logout
@@ -90,7 +90,7 @@
expect(Sessions::UserSession.for_user(user.id).count).to be >= 1
click_on "Save"
- expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_account_password_updated))
+ expect_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated))
# The old session is removed
expect(Sessions::UserSession.find_by(session_id: "other")).to be_nil
@@ -126,7 +126,7 @@
find_by_id("settings_password_min_adhered_rules").set 3
scroll_to_and_click(find(".button", text: "Save"))
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: "Successful update.")
Setting.clear_cache
@@ -144,19 +144,19 @@
fill_in "user_password", with: "adminADMIN"
fill_in "user_password_confirmation", with: "adminADMIN"
scroll_to_and_click(find(".button", text: "Save"))
- expect(page).to have_css(".errorExplanation", text: "Password Must contain characters of the following classes")
+ expect_primerized_error("Password Must contain characters of the following classes")
# 2 of 3 classes
fill_in "user_password", with: "adminADMIN123"
fill_in "user_password_confirmation", with: "adminADMIN123"
scroll_to_and_click(find(".button", text: "Save"))
- expect(page).to have_css(".errorExplanation", text: "Password Must contain characters of the following classes")
+ expect_primerized_error("Password Must contain characters of the following classes")
# All classes
fill_in "user_password", with: "adminADMIN!"
fill_in "user_password_confirmation", with: "adminADMIN!"
scroll_to_and_click(find(".button", text: "Save"))
- expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update))
+ expect_primerized_flash(message: I18n.t(:notice_successful_update))
end
end
diff --git a/spec/features/versions/delete_spec.rb b/spec/features/versions/delete_spec.rb
index 5c345e46262a..c93ef2882c11 100644
--- a/spec/features/versions/delete_spec.rb
+++ b/spec/features/versions/delete_spec.rb
@@ -53,7 +53,7 @@
end
end
- expect(page).to have_css(".op-toast.-error", text: I18n.t(:error_can_not_delete_in_use_archived_undisclosed))
+ expect_primerized_error(I18n.t(:error_can_not_delete_in_use_archived_undisclosed))
expect(page).to have_no_css("a", text: "Archived child")
user.update!(admin: true)
@@ -67,7 +67,7 @@
end
end
- expect(page).to have_css(".op-toast.-error", text: "There are also work packages in archived projects.")
+ expect_primerized_error("There are also work packages in archived projects.")
expect(page).to have_css("a", text: "Archived child")
end
end
diff --git a/spec/features/wiki/attachment_upload_spec.rb b/spec/features/wiki/attachment_upload_spec.rb
index 8b0e11226617..4af6efdc1fdc 100644
--- a/spec/features/wiki/attachment_upload_spec.rb
+++ b/spec/features/wiki/attachment_upload_spec.rb
@@ -56,14 +56,11 @@
click_on "Save"
- expect(page).to have_text("Successful creation")
+ expect_and_dismiss_primerized_flash(message: "Successful creation")
expect(page).to have_css("#content img", count: 1)
expect(page).to have_content("Image uploaded the first time")
attachments_list.expect_attached("image.png")
- # required sleep otherwise clicking on the Edit button doesn't do anything
- SeleniumHubWaiter.wait
-
within ".toolbar-items" do
click_on "Edit"
end
@@ -116,7 +113,7 @@
click_on "Save"
- expect(page).to have_text("Successful creation")
+ expect_and_dismiss_primerized_flash(message: "Successful creation")
attachments_list.expect_attached("image.png")
# required sleep otherwise clicking on the Edit button doesn't do anything
diff --git a/spec/features/wiki/edit_new_page_spec.rb b/spec/features/wiki/edit_new_page_spec.rb
index fe11c6b9c3ef..148edc1e2d25 100644
--- a/spec/features/wiki/edit_new_page_spec.rb
+++ b/spec/features/wiki/edit_new_page_spec.rb
@@ -41,6 +41,6 @@
expect(page).to have_field "page_title", with: "Foobar"
click_on "Save"
- expect(page).to have_css(".op-toast.-success", text: "Successful creation.", wait: 10)
+ expect_primerized_flash(message: "Successful creation.", wait: 10)
end
end
diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb
index 07a8605d259c..b9b6cafef913 100644
--- a/spec/features/work_packages/bulk/copy_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb
@@ -316,9 +316,7 @@
click_on "Copy and follow"
- expect(page)
- .to have_css(".op-toast.-success",
- text: I18n.t(:notice_successful_create))
+ expect_primerized_flash(message: I18n.t(:notice_successful_create))
wp_page = Pages::FullWorkPackage.new(WorkPackage.last)
diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb
index c4d0a903fab1..49fa31633a59 100644
--- a/spec/features/work_packages/bulk/move_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/move_work_package_spec.rb
@@ -140,10 +140,7 @@
click_on "Move and follow"
wait_for_reload
- expect(page)
- .to have_css(".op-toast.-error",
- text: I18n.t(:"work_packages.bulk.none_could_be_saved",
- total: 1))
+ expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1)
# Should NOT have moved
child_wp.reload
@@ -170,10 +167,7 @@
click_on "Move and follow"
end
- expect(page)
- .to have_css(".op-toast.-error",
- text: I18n.t(:"work_packages.bulk.none_could_be_saved",
- total: 1))
+ expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1)
child_wp.reload
work_package.reload
expect(work_package.project_id).to eq(project.id)
@@ -215,23 +209,15 @@
end
it "displays an error message explaining which work package could not be moved and why" do
- expect(page)
- .to have_css(".op-toast.-error",
- text: I18n.t("work_packages.bulk.could_not_be_saved"),
- wait: 10)
-
- expect(page)
- .to have_css(
- ".op-toast.-error",
- text: "#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}"
- )
-
- expect(page)
- .to have_css(".op-toast.-error",
- text: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved",
- failing: 1,
- total: 2,
- success: 1))
+ expect_primerized_error(I18n.t("work_packages.bulk.could_not_be_saved"))
+ expect_primerized_error("#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}")
+
+ expect_primerized_error(
+ I18n.t("work_packages.bulk.x_out_of_y_could_be_saved",
+ failing: 1,
+ total: 2,
+ success: 1)
+ )
expect(work_package.reload.project_id).to eq(project2.id)
expect(work_package2.reload.project_id).to eq(project.id)
diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rb
index 6689aff8ae9f..d622ffbee2a3 100644
--- a/spec/features/work_packages/bulk/update_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/update_work_package_spec.rb
@@ -153,21 +153,17 @@
fill_in custom_field.name, with: "Custom field text"
click_on "Submit"
- expect(page)
- .to have_css(
- ".op-toast.-error",
- text: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1)
- )
-
- expect(page)
- .to have_css(
- ".op-toast.-error",
- text: <<~MSG.squish
- #{work_package2.id}:
- #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')}
- #{I18n.t('activerecord.errors.models.work_package.readonly_status')}
- MSG
- )
+ expect_primerized_error(
+ I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1)
+ )
+
+ expect_primerized_error(
+ <<~MSG.squish
+ #{work_package2.id}:
+ #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')}
+ #{I18n.t('activerecord.errors.models.work_package.readonly_status')}
+ MSG
+ )
# Should update 1 work package custom field only
work_package.reload
diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rb
index 5094f8f61573..4b1bc92b9c3b 100644
--- a/spec/features/work_packages/navigation_spec.rb
+++ b/spec/features/work_packages/navigation_spec.rb
@@ -148,11 +148,10 @@
it "loading an unknown work package ID" do
visit "/work_packages/999999999"
- page404 = Pages::Page.new
- page404.expect_toast type: :error, message: I18n.t(:notice_file_not_found)
+ expect_and_dismiss_primerized_flash type: :error, message: I18n.t(:notice_file_not_found)
visit "/projects/#{project.identifier}/work_packages/999999999"
- page404.expect_and_dismiss_toaster type: :error, message: I18n.t("api_v3.errors.not_found.work_package")
+ expect_and_dismiss_primerized_flash type: :error, message: I18n.t("api_v3.errors.not_found.work_package")
end
# Regression #29994
diff --git a/spec/features/wysiwyg/autosave_spec.rb b/spec/features/wysiwyg/autosave_spec.rb
index f67058c2d668..5528605633bf 100644
--- a/spec/features/wysiwyg/autosave_spec.rb
+++ b/spec/features/wysiwyg/autosave_spec.rb
@@ -50,7 +50,7 @@
editor.click_and_type_slowly "Initial version"
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_text "Initial version"
end
@@ -69,7 +69,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_text "This should be saved"
end
diff --git a/spec/features/wysiwyg/bold_behavior_spec.rb b/spec/features/wysiwyg/bold_behavior_spec.rb
index e2e8204af2a2..5521337ed5ca 100644
--- a/spec/features/wysiwyg/bold_behavior_spec.rb
+++ b/spec/features/wysiwyg/bold_behavior_spec.rb
@@ -58,7 +58,7 @@ def bold_keystroke
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful creation.")
within("#content") do
expect(page).to have_css("p") { |node|
diff --git a/spec/features/wysiwyg/html_encoding_spec.rb b/spec/features/wysiwyg/html_encoding_spec.rb
index 230b1b803471..a563dca483ba 100644
--- a/spec/features/wysiwyg/html_encoding_spec.rb
+++ b/spec/features/wysiwyg/html_encoding_spec.rb
@@ -51,7 +51,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_css("p", text: '')
diff --git a/spec/features/wysiwyg/linking_spec.rb b/spec/features/wysiwyg/linking_spec.rb
index 786bb10ac657..77f81cd1a4a4 100644
--- a/spec/features/wysiwyg/linking_spec.rb
+++ b/spec/features/wysiwyg/linking_spec.rb
@@ -49,7 +49,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
wiki_page = project.wiki.pages.first.reload
diff --git a/spec/features/wysiwyg/macros/attribute_macros_spec.rb b/spec/features/wysiwyg/macros/attribute_macros_spec.rb
index 5bbf1c05b606..7b7ad2aa55ac 100644
--- a/spec/features/wysiwyg/macros/attribute_macros_spec.rb
+++ b/spec/features/wysiwyg/macros/attribute_macros_spec.rb
@@ -114,7 +114,7 @@
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
# Expect output widget
within("#content") do
@@ -177,7 +177,7 @@
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful creation.")
within("#content") do
expect(page).to have_css(".custom-option", count: 6)
diff --git a/spec/features/wysiwyg/macros/child_pages_spec.rb b/spec/features/wysiwyg/macros/child_pages_spec.rb
index 9fe0fbb85db2..bf24ba4ca44e 100644
--- a/spec/features/wysiwyg/macros/child_pages_spec.rb
+++ b/spec/features/wysiwyg/macros/child_pages_spec.rb
@@ -112,7 +112,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_css(".pages-hierarchy")
@@ -145,7 +145,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_css(".pages-hierarchy")
diff --git a/spec/features/wysiwyg/macros/code_block_macro_spec.rb b/spec/features/wysiwyg/macros/code_block_macro_spec.rb
index 2893301d2661..730d1f567465 100644
--- a/spec/features/wysiwyg/macros/code_block_macro_spec.rb
+++ b/spec/features/wysiwyg/macros/code_block_macro_spec.rb
@@ -74,7 +74,7 @@ def foobar
end
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
# Expect output widget
within("#content") do
@@ -106,7 +106,7 @@ def foobar
expect(container).to have_css(".op-uc-code-block", text: "asdf")
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful creation.")
wp = WikiPage.last
expect(wp.text.gsub("\r\n", "\n")).to eq("```text\nasdf\n```")
@@ -119,7 +119,7 @@ def foobar
end
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
wp.reload
# Regression added two newlines before fence here
@@ -153,7 +153,7 @@ def foobar
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
wiki_page = project.wiki.find_page("wiki")
text = wiki_page.text.gsub(/\r\n?/, "\n")
diff --git a/spec/features/wysiwyg/macros/embedded_tables_spec.rb b/spec/features/wysiwyg/macros/embedded_tables_spec.rb
index 9a2b198d4fea..9beb1180fa61 100644
--- a/spec/features/wysiwyg/macros/embedded_tables_spec.rb
+++ b/spec/features/wysiwyg/macros/embedded_tables_spec.rb
@@ -105,7 +105,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful creation.")
embedded_table = Pages::EmbeddedWorkPackagesTable.new find(".wiki-content")
embedded_table.expect_work_package_listed wp_task
@@ -141,7 +141,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_and_dismiss_primerized_flash("Successful update.")
# Embedded queries
wikipage = project.wiki.pages.last
diff --git a/spec/features/wysiwyg/macros/work_package_button_spec.rb b/spec/features/wysiwyg/macros/work_package_button_spec.rb
index e133b726fc12..ab3dc6bd57e3 100644
--- a/spec/features/wysiwyg/macros/work_package_button_spec.rb
+++ b/spec/features/wysiwyg/macros/work_package_button_spec.rb
@@ -85,7 +85,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_css("a[href=\"/projects/my-project/work_packages/new?type=#{type.id}\"]")
diff --git a/spec/features/wysiwyg/tables_spec.rb b/spec/features/wysiwyg/tables_spec.rb
index eb780e9cf55d..cd84cf673571 100644
--- a/spec/features/wysiwyg/tables_spec.rb
+++ b/spec/features/wysiwyg/tables_spec.rb
@@ -67,7 +67,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
within("#content") do
expect(page).to have_css("table td", text: "h1")
@@ -116,7 +116,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
within("#content") do
expect(page).to have_css("table th", text: "h1")
@@ -181,7 +181,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
within("#content") do
expect(page).to have_css('td[style*="background-color:#123456"]')
@@ -232,7 +232,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
# table height and width is set on figure
@@ -297,7 +297,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_and_dismiss_primerized_flash(message: "Successful creation.")
within("#content") do
expect(page).to have_css('td[style*="width:250px"]')
diff --git a/spec/features/wysiwyg/work_package_linking_spec.rb b/spec/features/wysiwyg/work_package_linking_spec.rb
index 5b3d54bf3814..9430985035d0 100644
--- a/spec/features/wysiwyg/work_package_linking_spec.rb
+++ b/spec/features/wysiwyg/work_package_linking_spec.rb
@@ -53,7 +53,7 @@
# Save wiki page
click_on "Save"
- expect(page).to have_css(".op-toast.-success")
+ expect_primerized_flash(message: "Successful update.")
within("#content") do
expect(page).to have_css("a.issue", count: 1)
diff --git a/spec/helpers/error_message_helper_spec.rb b/spec/helpers/error_message_helper_spec.rb
index 8beb03106e64..980171dca144 100644
--- a/spec/helpers/error_message_helper_spec.rb
+++ b/spec/helpers/error_message_helper_spec.rb
@@ -30,14 +30,21 @@
RSpec.describe ErrorMessageHelper do
let(:model) { WikiPage.new }
+ let(:errors) { model.errors }
def escape_html(array)
array.map { CGI.escapeHTML _1 }
end
+ subject { flash[:error] }
+
+ before do
+ helper.instance_variable_set(:@wiki_page, model)
+ end
+
shared_examples "error messages rendering" do
context "when no errors" do
- it { expect(rendered).to eq("") }
+ it { expect(subject).to be_nil }
end
context "with one field error" do
@@ -45,9 +52,13 @@ def escape_html(array)
errors.add(:title, :blank)
end
- it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) }
- it { expect(rendered).to include(t("errors.header_invalid_fields", count: 1)) }
- it { expect(rendered).to include(*escape_html(errors.full_messages)) }
+ it "adds the error messages", :aggregate_failures do
+ helper.error_messages_for("wiki_page")
+
+ expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1))
+ expect(subject).to include(t("errors.header_invalid_fields", count: 1))
+ expect(subject).to include(*escape_html(errors.full_messages))
+ end
end
context "with two field errors" do
@@ -56,9 +67,13 @@ def escape_html(array)
errors.add(:author, :blank)
end
- it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) }
- it { expect(rendered).to include(t("errors.header_invalid_fields", count: 2)) }
- it { expect(rendered).to include(*escape_html(errors.full_messages)) }
+ it "adds both error messages", :aggregate_failures do
+ helper.error_messages_for("wiki_page")
+
+ expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2))
+ expect(subject).to include(t("errors.header_invalid_fields", count: 2))
+ expect(subject).to include(*escape_html(errors.full_messages))
+ end
end
context "with one base error" do
@@ -66,10 +81,13 @@ def escape_html(array)
errors.add(:base, :error_unauthorized)
end
- it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) }
- it { expect(rendered).not_to include(t("errors.header_invalid_fields", count: 1)) }
- it { expect(rendered).not_to include(t("errors.header_additional_invalid_fields", count: 1)) }
- it { expect(rendered).to include(*escape_html(errors.full_messages)) }
+ it "adds the one error message", :aggregate_failures do
+ helper.error_messages_for("wiki_page")
+
+ expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1))
+ expect(subject).not_to include(t("errors.header_additional_invalid_fields", count: 1))
+ expect(subject).to include(*escape_html(errors.full_messages))
+ end
end
context "with one base error and one field error" do
@@ -78,9 +96,13 @@ def escape_html(array)
errors.add(:title, :blank)
end
- it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) }
- it { expect(rendered).to include(t("errors.header_additional_invalid_fields", count: 1)) }
- it { expect(rendered).to include(*escape_html(errors.full_messages)) }
+ it "adds both error messages", :aggregate_failures do
+ helper.error_messages_for("wiki_page")
+
+ expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2))
+ expect(subject).to include(t("errors.header_additional_invalid_fields", count: 1))
+ expect(subject).to include(*escape_html(errors.full_messages))
+ end
end
context "with two base errors and two field errors" do
@@ -91,27 +113,28 @@ def escape_html(array)
errors.add(:author, :blank)
end
- it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 4)) }
- it { expect(rendered).to include(t("errors.header_additional_invalid_fields", count: 2)) }
- it { expect(rendered).to include(*escape_html(errors.full_messages)) }
+ it "adds both error messages", :aggregate_failures do
+ helper.error_messages_for("wiki_page")
+
+ expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 4))
+ expect(subject).to include(t("errors.header_additional_invalid_fields", count: 2))
+ expect(subject).to include(*escape_html(errors.full_messages))
+ end
end
end
describe "#error_messages_for" do
- let(:errors) { model.errors }
-
- subject(:rendered) { helper.error_messages_for(model) }
-
it "accesses the model from instance variables if a name is given" do
- helper.instance_variable_set(:@wiki_page, model)
model.errors.add(:base, :error_conflict)
- expect(helper.error_messages_for("wiki_page")).to include(*escape_html(errors.full_messages))
+ helper.error_messages_for("wiki_page")
+ expect(subject).to include(*escape_html(errors.full_messages))
end
it "renders nothing if there is no instance variable with the given name" do
- helper.instance_variable_set(:@wiki_page, model)
model.errors.add(:base, :error_conflict)
- expect(helper.error_messages_for("work_package")).to be_nil
+ helper.error_messages_for("work_package")
+
+ expect(subject).to be_nil
end
include_examples "error messages rendering"
diff --git a/spec/support/components/password_confirmation_dialog.rb b/spec/support/components/password_confirmation_dialog.rb
index f488f806f86b..1870544ff33f 100644
--- a/spec/support/components/password_confirmation_dialog.rb
+++ b/spec/support/components/password_confirmation_dialog.rb
@@ -26,11 +26,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++
+require "support/primerized_flash/expectations"
+
module Components
class PasswordConfirmationDialog
include Capybara::DSL
include Capybara::RSpecMatchers
include RSpec::Matchers
+ include PrimerizedFlash::Expectations
def confirm_flow_with(password, with_keyboard: false, should_fail: false)
expect_open
@@ -68,8 +71,7 @@ def submit(should_fail:, with_keyboard:)
end
if should_fail
- expect(page).to have_css(".op-toast.-error",
- text: I18n.t(:notice_password_confirmation_failed))
+ expect_primerized_error(I18n.t(:notice_password_confirmation_failed))
else
expect(page).to have_no_css(".op-toast.-error")
end
diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb
index fb624b11ed13..dfc03e770df0 100644
--- a/spec/support/pages/page.rb
+++ b/spec/support/pages/page.rb
@@ -27,6 +27,7 @@
#++
require_relative "../toasts/expectations"
+require_relative "../primerized_flash/expectations"
module Pages
class Page
@@ -36,6 +37,7 @@ class Page
include RSpec::Matchers
include OpenProject::StaticRouting::UrlHelpers
include Toasts::Expectations
+ include PrimerizedFlash::Expectations
def current_page?
URI.parse(current_url).path == path
diff --git a/spec/support/pages/projects/settings.rb b/spec/support/pages/projects/settings.rb
index c4ea8fc847f8..1482c6e1e990 100644
--- a/spec/support/pages/projects/settings.rb
+++ b/spec/support/pages/projects/settings.rb
@@ -43,11 +43,6 @@ def visit_tab!(name)
visit "/projects/#{project.identifier}/settings/#{name}"
end
- # only notice is used as opposed to op-toast
- def expect_toast(message:, type: :success)
- expect(page).to have_css(".op-toast.-#{type}", text: message, wait: 10)
- end
-
def expect_type_active(type)
expect_type(type, true)
end
diff --git a/spec/support/primerized_flash/expectations.rb b/spec/support/primerized_flash/expectations.rb
index e13e222bfa2e..1ad9b32bd87a 100644
--- a/spec/support/primerized_flash/expectations.rb
+++ b/spec/support/primerized_flash/expectations.rb
@@ -1,8 +1,17 @@
module PrimerizedFlash
module Expectations
+ def expect_primerized_error(message)
+ expect_primerized_flash(message:, type: :error)
+ end
+
def expect_primerized_flash(message:, type: :success, wait: 20)
- mapped_scheme = expected_flash_type(type)
- expect(page).to have_css(".Banner--#{mapped_scheme}", text: message, wait:)
+ expected_css = expected_flash_css(type)
+ expect(page).to have_css(expected_css, text: message, wait:)
+ end
+
+ def find_primerized_flash(type:)
+ expected_css = expected_flash_css(type)
+ page.find(expected_css)
end
def expect_and_dismiss_primerized_flash(message: nil, type: :success, wait: 20)
@@ -26,12 +35,22 @@ def expect_no_primerized_flash(type: :success, message: nil, wait: 10)
if type.nil?
expect(page).not_to have_test_selector("op-primer-flash-message")
else
- mapped_scheme = expected_flash_type(type)
- expect(page).to have_no_css(".Banner--#{mapped_scheme}", text: message, wait:)
+ expected_css = expected_flash_css(type)
+ expect(page).to have_no_css(expected_css, text: message, wait:)
+ end
+ end
+
+ def expected_flash_css(type)
+ scheme = mapped_flash_type(type)
+ case scheme
+ when :default
+ %{[data-test-selector="op-primer-flash-message"].Banner}
+ else
+ %{[data-test-selector="op-primer-flash-message"].Banner--#{scheme}}
end
end
- def expected_flash_type(type)
+ def mapped_flash_type(type)
case type
when :error
:error # The class is error, but the scheme is danger
diff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rb
index c53065fb4ccb..ef3ac14afcff 100644
--- a/spec/support/toasts/expectations.rb
+++ b/spec/support/toasts/expectations.rb
@@ -4,9 +4,11 @@ def expect_toast(message:, type: :success, wait: 20)
if toast_type == :angular
expect(page).to have_css(".op-toast.-#{type}", text: message, wait:)
elsif type == :error
- expect(page).to have_css(".errorExplanation", text: message)
+ ActiveSupport::Deprecation.warn("Use `expect_primerized_error(message)` instead of expect_toast with type: :error")
+ expect_primerized_error(message)
elsif type == :success
- expect(page).to have_css(".op-toast.-success", text: message)
+ ActiveSupport::Deprecation.warn("Use `expect_primerized_flash(type: :success, message:)` instead of expect_toast with type: :success")
+ expect_primerized_flash(message:)
else
raise NotImplementedError
end