Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antopalidi committed Sep 22, 2023
1 parent e56d122 commit 8cc2b12
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@
with.library :rails
end
end

require_relative "./support/custom_autocomplete_select.rb"

RSpec.configure do |config|
config.include CustomAutoCompleteSelect, type: :system
end
20 changes: 20 additions & 0 deletions spec/support/custom_autocomplete_select.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module CustomAutoCompleteSelect
def custom_autocomplete_select(value, from:)
within("div[data-autocomplete-for='#{from}']") do
find(".autocomplete-input").click
find(".autocomplete-input").native.send_keys(value[0..4])

dynamic_list_id = find("[id^=autoComplete_list]")[:id]

expect(page).to have_css("##{dynamic_list_id}") # select should be open now

expect(page).to have_css("#autoComplete_result_0", text: value)
find("#autoComplete_result_0", text: value).hover
expect(page).to have_css("#autoComplete_result_0", text: value)
find("#autoComplete_result_0", text: value).click
expect(page).to have_css(".autocomplete__selected-item", text: value)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
click_link I18n.t("delegations.index.actions.new_delegation", scope: i18n_scope)

within ".new_delegation" do
autocomplete_select "#{granter.name} (@#{granter.nickname})", from: :granter_id
autocomplete_select "#{grantee.name} (@#{grantee.nickname})", from: :grantee_id
custom_autocomplete_select "#{granter.name} (@#{granter.nickname})", from: :granter_id
custom_autocomplete_select "#{grantee.name} (@#{grantee.nickname})", from: :grantee_id

find("*[type=submit]").click
end
Expand Down
2 changes: 2 additions & 0 deletions spec/system/decidim/action_delegator/delegations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
click_button translated(response.title)
click_button I18n.t("decidim.questions.vote_modal_confirm.confirm")

visit decidim_consultations.question_path(question) # to reload the page
click_link(I18n.t("decidim.action_delegator.delegations.has_delegations"))
within "#delegations-modal" do
expect(page).to have_content(t("decidim.questions.vote_button.already_voted"))
Expand All @@ -94,6 +95,7 @@
click_button translated(response.title)
click_button I18n.t("decidim.questions.vote_modal_confirm.confirm")

visit decidim_consultations.question_path(question) # to reload the page
click_link(I18n.t("decidim.action_delegator.delegations.has_delegations"))
within "#delegations-modal" do
expect(page).to have_content(t("decidim.questions.vote_button.already_voted"))
Expand Down

0 comments on commit 8cc2b12

Please sign in to comment.