Skip to content

Commit

Permalink
Adapt specs
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 25, 2024
1 parent 987455a commit 2e51bf9
Show file tree
Hide file tree
Showing 83 changed files with 247 additions and 240 deletions.
2 changes: 1 addition & 1 deletion app/helpers/flash_messages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def render_flash_modal

def mapped_flash_type(type)
case type
when :error
when :error, :danger
:danger
when :warning
:warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions modules/bim/spec/features/bcf/api_authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
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(page).to have_css(".op-toast.-error", text: expected)
expect_primerized_error(expected)

index_page.add_model_allowed false
end
Expand Down
4 changes: 2 additions & 2 deletions modules/bim/spec/features/model_viewer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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(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
Expand All @@ -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
2 changes: 1 addition & 1 deletion modules/boards/spec/features/support/board_index_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/boards/spec/features/support/board_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/budgets/spec/features/budgets/add_budget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion modules/budgets/spec/features/budgets/copy_budget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions modules/ldap_groups/spec/features/administration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions modules/meeting/spec/controllers/meetings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
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(page).to have_css(".op-toast.-error", text: expected)
expect_primerized_error(expected)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down Expand Up @@ -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."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
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(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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!
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(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
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(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
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(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)

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions modules/webhooks/spec/features/manage_webhooks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/news_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/features/activities/wiki_activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 2e51bf9

Please sign in to comment.