Skip to content

Commit

Permalink
Replace expect_primerized_error -> expect_primerized_flash
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 30, 2024
1 parent 7ea8ba1 commit 62e2a19
Show file tree
Hide file tree
Showing 31 changed files with 69 additions and 67 deletions.
2 changes: 1 addition & 1 deletion modules/bim/spec/features/model_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_primerized_error(expected)
expect_primerized_flash(type: :error, message: expected)

index_page.add_model_allowed false
end
Expand Down
2 changes: 1 addition & 1 deletion modules/bim/spec/features/model_viewer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

it "shows no viewer" do
expected = "[Error 403] You are not authorized to access this page."
expect_primerized_error(expected)
expect_primerized_flash(type: :error, message: expected)

show_model_page.model_viewer_visible false
show_model_page.model_viewer_shows_a_toolbar false
Expand Down
4 changes: 2 additions & 2 deletions modules/boards/spec/features/board_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@

it "does not allow viewing of boards" do
visit project_work_package_board_path(project, board_view)
expect_primerized_error(I18n.t(:notice_not_authorized))
expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized))

board_index.expect_editable false
end
Expand All @@ -311,7 +311,7 @@

it "does not allow viewing of boards" do
board_index.visit!
expect_primerized_error(I18n.t(:notice_not_authorized))
expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized))
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,6 @@
visit history_meeting_path(meeting)

expected = "[Error 403] You are not authorized to access this page."
expect_primerized_error(expected)
expect_primerized_flash(type: :error, message: expected)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CostReportsBaseTable
include Capybara::DSL
include Capybara::RSpecMatchers
include RSpec::Matchers
include PrimerizedFlash::Expectations
include Flash::Expectations

attr_reader :time_logging_modal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
click_button I18n.t(:button_continue)

# Enter valid phone number
expect_primerized_error("Phone number must be of format +XX XXXXXXXXX")
expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX")

SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "+49 123456789"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
click_on "Submit"

# Expect failure
expect_primerized_error(I18n.t("two_factor_authentication.error_invalid_backup_code"))
expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.error_invalid_backup_code"))
expect(page).to have_current_path signin_path

# Try again!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
first_login_step
two_factor_step("whatever")

expect_primerized_error(I18n.t(:notice_account_otp_invalid))
expect_primerized_flash(type: :error, message: I18n.t(:notice_account_otp_invalid))
expect(page).to have_current_path signin_path
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
first_login_step
two_factor_step("whatever")

expect_primerized_error(I18n.t(:notice_account_otp_invalid))
expect_primerized_flash(type: :error, message: I18n.t(:notice_account_otp_invalid))
expect(page).to have_current_path signin_path
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
click_button I18n.t(:button_continue)

# Enter valid phone number
expect_primerized_error("Phone number must be of format +XX XXXXXXXXX")
expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX")
fill_in "device_phone_number", with: "+49 123456789"
click_button I18n.t(:button_continue)

Expand All @@ -56,7 +56,7 @@
expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device"))
expect(page).to have_css("input#otp")

expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid"))
expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid"))

# Fill in correct token
fill_in "otp", with: sms_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def expect_not_logged_in
click_on "Continue"

# Expect error on invalid phone
expect_primerized_error("Phone number must be of format +XX XXXXXXXXX")
expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX")

SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "+49 123456789"
Expand All @@ -71,7 +71,7 @@ def expect_not_logged_in

expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device"))
expect(page).to have_css("input#otp")
expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid"))
expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid"))

SeleniumHubWaiter.wait
# Fill in wrong token
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/attribute_help_texts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
click_button "Save"

# Handle errors
expect_primerized_error("Help text can't be blank.")
expect_primerized_flash(type: :error, message: "Help text can't be blank.")
SeleniumHubWaiter.wait
editor.set_markdown("New**help**text")
click_button "Save"
Expand Down
3 changes: 2 additions & 1 deletion spec/features/admin/enterprise/enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
submit_button.click

# Error output
expect_primerized_error("Enterprise support token can't be read. Are you sure it is a support token?")
expect_primerized_flash(type: :error,
message: "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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
fill_in "application_redirect_uri", with: "not a url!"
click_on "Create"

expect_primerized_error("Redirect URI must be an absolute URI.")
expect_primerized_flash(type: :error, message: "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_primerized_error('Redirect URI is not providing a "Secure Context"')
expect_primerized_flash(type: :error, message: '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"
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/test_mail_notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
click_link "Send a test email"

expected = "An error occurred while sending mail (#{error_message})"
expect_primerized_error(expected)
expect_primerized_flash(type: :error, message: expected)
expect(page).to have_no_css(".op-toast.-error strong")
end
end
5 changes: 3 additions & 2 deletions spec/features/admin/working_days_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def working_days_setting
dialog.confirm
end

expect_primerized_error("At least one day of the week must be defined as a working day.")
expect_primerized_flash(type: :error, message: "At least one day of the week must be defined as a working day.")
# Restore the checkboxes to their valid state
expect(page).to have_checked_field "Monday"
expect(page).to have_checked_field "Tuesday"
Expand Down Expand Up @@ -171,7 +171,8 @@ def working_days_setting
# Not executing the background jobs
dialog.confirm

expect_primerized_error("The previous changes to the working days configuration have not been applied yet.")
expect_primerized_flash(type: :error,
message: "The previous changes to the working days configuration have not been applied yet.")
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/features/auth/consent_auth_stage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def expect_not_logged_in
# Decline the consent
click_on I18n.t(:button_decline)

expect_primerized_error("[email protected]")
expect_primerized_flash(type: :error, message: "[email protected]")
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions spec/features/projects/modules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@
check "Calendar"
click_button "Save"

expect_primerized_error(
expect_primerized_flash(type: :error, message:
I18n.t(:"activerecord.errors.models.project.attributes.enabled_modules.dependency_missing",
dependency: "Work packages",
module: "Calendars")
)
module: "Calendars"))

expect(page).to have_no_xpath(project_work_packages_menu_link_selector)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
member_with_project_attributes_edit_permissions.reload
dialog.submit

expect_primerized_error(I18n.t(:notice_not_authorized))
expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized))
end
end
end
2 changes: 1 addition & 1 deletion spec/features/projects/projects_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def load_and_open_filters(user)

error_text = "Orders ><script src='/foobar js'></script> is not set to one of the allowed values. and does not exist."
error_html = "Orders &gt;&lt;script src='/foobar js'&gt;&lt;/script&gt; is not set to one of the allowed values. and does not exist."
expect_primerized_error(error_text)
expect_primerized_flash(type: :error, message: error_text)

error_container = find_primerized_flash(type: :error)
expect(error_container["innerHTML"]).to include error_html
Expand Down
5 changes: 3 additions & 2 deletions spec/features/roles/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

click_button "Create"

expect_primerized_error("Name has already been taken")
expect_primerized_flash(type: :error, message: "Name has already been taken")

fill_in "Name", with: "New role name"

Expand All @@ -64,7 +64,8 @@

click_button "Create"

expect_primerized_error("Permissions need to also include 'View members' as 'Manage members' is selected.")
expect_primerized_flash(type: :error,
message: "Permissions need to also include 'View members' as 'Manage members' is selected.")

check "View members"
select existing_role.name, from: "Copy workflow from"
Expand Down
4 changes: 2 additions & 2 deletions spec/features/types/crud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

click_button "Create"

expect_primerized_error("Name has already been taken.")
expect_primerized_flash(type: :error, message: "Name has already been taken.")

# Values are retained
expect(page)
Expand Down Expand Up @@ -122,7 +122,7 @@
end

it "renders an error message with links to the archived project in the projects list" do
expect_primerized_error project.name
expect_primerized_flash type: :error, message: project.name
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/features/users/password_change_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@
fill_in "user_password", with: "adminADMIN"
fill_in "user_password_confirmation", with: "adminADMIN"
scroll_to_and_click(find(".button", text: "Save"))
expect_primerized_error("Password Must contain characters of the following classes")
expect_primerized_flash(type: :error, message: "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_primerized_error("Password Must contain characters of the following classes")
expect_primerized_flash(type: :error, message: "Password Must contain characters of the following classes")

# All classes
fill_in "user_password", with: "adminADMIN!"
Expand Down
4 changes: 2 additions & 2 deletions spec/features/versions/delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
end
end

expect_primerized_error(I18n.t(:error_can_not_delete_in_use_archived_undisclosed))
expect_primerized_flash(type: :error, message: I18n.t(:error_can_not_delete_in_use_archived_undisclosed))
expect(page).to have_no_css("a", text: "Archived child")

user.update!(admin: true)
Expand All @@ -67,7 +67,7 @@
end
end

expect_primerized_error("There are also work packages in archived projects.")
expect_primerized_flash(type: :error, message: "There are also work packages in archived projects.")
expect(page).to have_css("a", text: "Archived child")
end
end
18 changes: 11 additions & 7 deletions spec/features/work_packages/bulk/copy_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,17 @@
it "fails, informing of the reasons" do
click_on "Copy and follow"

expect_primerized_error(I18n.t("work_packages.bulk.none_could_be_saved", total: 3))
expect_primerized_error(I18n.t("work_packages.bulk.selected_because_descendants", total: 3, selected: 2))
expect_primerized_error("#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}")
expect_primerized_error("#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}")
expect_primerized_error(
"#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}"
)
expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 3))
expect_primerized_flash(type: :error,
message: I18n.t(
"work_packages.bulk.selected_because_descendants", total: 3, selected: 2
))
expect_primerized_flash(type: :error,
message: "#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}")
expect_primerized_flash(type: :error,
message: "#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}")
expect_primerized_flash(type: :error, message:
"#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}")
end

context "when the limit to move in the frontend is 0",
Expand Down
14 changes: 7 additions & 7 deletions spec/features/work_packages/bulk/move_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
click_on "Move and follow"
wait_for_reload

expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1)
expect_primerized_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1)

# Should NOT have moved
child_wp.reload
Expand All @@ -167,7 +167,7 @@
click_on "Move and follow"
end

expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1)
expect_primerized_flash type: :error, message: 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)
Expand Down Expand Up @@ -209,15 +209,15 @@
end

it "displays an error message explaining which work package could not be moved and why" do
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_flash(type: :error, message: I18n.t("work_packages.bulk.could_not_be_saved"))
expect_primerized_flash(type: :error,
message: "#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}")

expect_primerized_error(
expect_primerized_flash(type: :error, message:
I18n.t("work_packages.bulk.x_out_of_y_could_be_saved",
failing: 1,
total: 2,
success: 1)
)
success: 1))

expect(work_package.reload.project_id).to eq(project2.id)
expect(work_package2.reload.project_id).to eq(project.id)
Expand Down
14 changes: 7 additions & 7 deletions spec/features/work_packages/bulk/update_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@
fill_in "Parent", with: "-1"
click_on "Submit"

expect_primerized_error(I18n.t("work_packages.bulk.none_could_be_saved", total: 2))
expect_primerized_error("#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}")
expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 2))
expect_primerized_flash(type: :error,
message: "#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}")

expect_primerized_error(
expect_primerized_flash(type: :error, message:
<<~MSG.squish
#{work_package2.id}:
Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}
Expand Down Expand Up @@ -142,11 +143,10 @@
fill_in custom_field.name, with: "Custom field text"
click_on "Submit"

expect_primerized_error(
I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1)
)
expect_primerized_flash(type: :error, message:
I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1))

expect_primerized_error(
expect_primerized_flash(type: :error, message:
<<~MSG.squish
#{work_package2.id}:
#{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')}
Expand Down
Loading

0 comments on commit 62e2a19

Please sign in to comment.