Skip to content

Commit

Permalink
Adapt specs
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 26, 2024
1 parent 0813f91 commit 8cbe0c0
Show file tree
Hide file tree
Showing 100 changed files with 320 additions and 332 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
12 changes: 4 additions & 8 deletions modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb
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 All @@ -206,8 +205,7 @@

click_button "Save"

backlogs_page
.expect_and_dismiss_toaster(message: "Successful update.")
expect_and_dismiss_primerized_flash(message: "Successful update.")

# Now works as a sprint instead of a backlog
backlogs_page
Expand All @@ -228,8 +226,7 @@

click_button "Save"

backlogs_page
.expect_and_dismiss_toaster(message: "Successful update.")
expect_and_dismiss_primerized_flash(message: "Successful update.")

# the disabled backlog/sprint is no longer visible
expect(page)
Expand All @@ -250,8 +247,7 @@

click_button "Save"

backlogs_page
.expect_and_dismiss_toaster(message: "Successful update.")
expect_and_dismiss_primerized_flash(message: "Successful update.")

# the disabled backlog/sprint is no longer visible
expect(page)
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/card_view/bulk_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

select budget.subject, from: "work_package_budget_id"
click_on "Submit"
wp_table.expect_and_dismiss_toaster message: "Successful update."
expect_and_dismiss_primerized_flash message: "Successful update."

expect(work_package.reload.budget_id).to eq(budget.id)
expect(work_package2.reload.budget_id).to eq(budget.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
5 changes: 3 additions & 2 deletions modules/bim/spec/features/model_viewer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
uploader: user)
end

let(:show_default_page) { Pages::IfcModels::ShowDefault.new(project) }
let(:show_model_page) { Pages::IfcModels::Show.new(project, model.id) }
let(:model_tree) { Components::XeokitModelTree.new }
let(:card_view) { Pages::WorkPackageCards.new(project) }
Expand Down Expand Up @@ -93,7 +94,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"))
show_default_page.expect_toast(type: :info, message: I18n.t("js.ifc_models.empty_warning"))
end
end
end
Expand Down Expand Up @@ -134,7 +135,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
5 changes: 3 additions & 2 deletions modules/boards/spec/features/boards_global_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@
it "renders a required attribute validation error" do
expect(Boards::Grid.all).to be_empty

new_board_page.expect_toast message: "Project #{I18n.t('activerecord.errors.messages.blank')}",
type: :error
expect_primerized_flash message: "Project #{I18n.t('activerecord.errors.messages.blank')}",
type: :error

new_board_page.expect_project_dropdown
end
end
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

click_on "Create"

expect_and_dismiss_primerized_flash(message: "Successful creation.")

expect(page).to have_css("#content img", count: 1)
expect(page).to have_content("Image uploaded on creation")
attachments_list.expect_attached("image.png")
Expand Down Expand Up @@ -96,6 +98,8 @@

click_on "Create"

expect_and_dismiss_primerized_flash(message: "Successful creation.")

attachments_list.expect_attached("image.png")

within ".toolbar-items" do
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
8 changes: 4 additions & 4 deletions modules/budgets/spec/features/budgets/update_budget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@

# Update first element
budget_page.edit_planned_costs! material_budget_item.id, type: :material, costs: 123
expect(budget_page).to have_content("Successful update")
expect_and_dismiss_primerized_flash(message: "Successful update")
expect(page).to have_css("tbody td.currency", text: "123.00 EUR")

click_on "Update"
Expand Down Expand Up @@ -218,7 +218,7 @@

# Update first element
budget_page.edit_planned_costs! material_budget_item.id, type: :material, costs: 123
expect(budget_page).to have_content("Successful update")
expect_and_dismiss_primerized_flash(message: "Successful update")
expect(page).to have_css("tbody td.currency", text: "USD 123.00")

click_on "Update"
Expand Down Expand Up @@ -258,7 +258,7 @@

# Update first element
budget_page.edit_planned_costs! labor_budget_item.id, type: :labor, costs: 456
expect(budget_page).to have_content("Successful update")
expect_and_dismiss_primerized_flash(message: "Successful update")
expect(page).to have_css("tbody td.currency", text: "456.00 EUR")

click_on "Update"
Expand Down Expand Up @@ -295,7 +295,7 @@

# Update first element
budget_page.edit_planned_costs! labor_budget_item.id, type: :labor, costs: 456
expect(budget_page).to have_content("Successful update")
expect_and_dismiss_primerized_flash(message: "Successful update")
expect(page).to have_css("tbody td.currency", text: "USD 456.00")

click_on "Update"
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
2 changes: 1 addition & 1 deletion modules/meeting/spec/features/meetings_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

field.submit_by_enter

show_page.expect_and_dismiss_toaster message: "Successful update"
expect_and_dismiss_primerized_flash(message: "Successful update")

meeting.reload

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 @@ -26,11 +26,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++

require "support/primerized_flash/expectations"

module Components
class CostReportsBaseTable
include Capybara::DSL
include Capybara::RSpecMatchers
include RSpec::Matchers
include PrimerizedFlash::Expectations

attr_reader :time_logging_modal

Expand Down Expand Up @@ -78,7 +81,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
Loading

0 comments on commit 8cbe0c0

Please sign in to comment.