Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spec/features/admin/manage_workshop_attendances_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
expect(page).to have_content('1 are attending as students')
expect(page).to_not have_selector('i.fa-magic')

find('span', text: 'Select a member to RSVP', visible: true).click
find('li', text: "#{other_invitation.member.full_name} (#{other_invitation.role})", visible: true).click
# Use the select_from_chosen helper to select the member
select_from_chosen("#{other_invitation.member.full_name} (#{other_invitation.role})", from: 'workshop_invitations')

expect(page).to have_content('2 are attending as students')

Expand Down
5 changes: 5 additions & 0 deletions spec/features/member_feedback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
context 'Submitting a feedback request' do
scenario 'I can see success page with message and link to homepage when valid data is given', js: true do
visit feedback_path(valid_token)

# Wait for Chosen dropdowns to initialize
expect(page).to have_css('#feedback_coach_id_chosen')
expect(page).to have_css('#feedback_tutorial_id_chosen')

within('.rating') { all('li').at(3).click }
select_from_chosen(coach.full_name, from: 'feedback_coach_id')
select_from_chosen(@tutorial.title, from: 'feedback_tutorial_id')
Expand Down
1 change: 1 addition & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
end

Capybara.javascript_driver = :chrome
Capybara.default_max_wait_time = 5
20 changes: 12 additions & 8 deletions spec/support/select_from_chosen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ module SelectFromChosen
def select_from_chosen(item_text, options)
# Find the native <select>
field = find_field(options[:from], :visible => false)
field_id = field[:id]

# Open the Chosen dialog
find("##{field[:id]}_chosen").click
# Find the option value we need to select
option = field.all('option', visible: false).find { |opt| opt.text == item_text }
raise "Option '#{item_text}' not found in select '#{options[:from]}'" unless option
option_value = option.value

# On the search input, type the string we're looking for and press Enter
within field.sibling('.chosen-container') do
input = find("input").native
input.send_keys(item_text)
input.send_key(:return)
end
# Use JavaScript to set the value and trigger Chosen update
page.execute_script <<-JS
$('##{field_id}').val('#{option_value}').trigger('chosen:updated').trigger('change');
JS

# Verify it was set
expect(page).to have_select(field_id, selected: item_text, visible: false)
end
end