Skip to content

Commit

Permalink
Adapt requests_index_spec to cover creators filter
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Dec 17, 2024
1 parent 21a9526 commit 50b69ec
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions src/api/spec/features/beta/webui/requests_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,57 @@
# rubocop:enable RSpec/ExampleLength
end

describe 'using the request creator filter', skip: 'Temporarily disable list of creators due to performance issues' do
describe 'using the request creator filter' do
before do
find_by_id('requests-dropdown-trigger').click if mobile? # open the filter dropdown
find_by_id('filter-creator-requests-button').click
end
if mobile?
find_by_id('requests-dropdown-trigger').click # open the filter dropdown
sleep 0.5 # wait for dropdown to open
end

it 'lists only the requests of the selected creator' do
check("creators[#{receiver.login}]")
within('#filters') do
fill_in('creators_search', with: receiver.login[0, 2])
find('.ui-menu-item-wrapper', match: :first).click
# Remove focus from autocomplete search to allow the autosubmit
find('label[for="creators_search"]').click
sleep 2
end

expect(page).to have_link(href: "/request/show/#{outgoing_request.number}")
expect(page).to have_no_link(href: "/request/show/#{incoming_request.number}")
expect(page).to have_no_link(href: "/request/show/#{other_incoming_request.number}")
end
if mobile?
find_by_id('requests-dropdown-trigger').click # open the filter dropdown
sleep 0.5 # wait for dropdown to open
end

it 'allows to filter by multiple request creators' do
check("creators[#{receiver.login}]")
check("creators[#{another_submitter.login}]")
within('#filters') do
fill_in('creators_search', with: another_submitter.login[0, 2])
find('.ui-menu-item-wrapper', match: :first).click
# Remove focus from autocomplete search to allow the autosubmit
find('label[for="creators_search"]').click
sleep 2
end
end

it 'filters the requests by multiple creators' do
expect(page).to have_link(href: "/request/show/#{outgoing_request.number}")
expect(page).to have_link(href: "/request/show/#{other_incoming_request.number}")
expect(page).to have_no_link(href: "/request/show/#{incoming_request.number}")
end

it 'only shows the creators that match the search value filled in the dropdown' do
fill_in('request-creator-search', with: submitter.login[0, 2].to_s)
# rubocop:disable RSpec/ExampleLength
it 'allows to modify the filter selection' do
if mobile?
find_by_id('requests-dropdown-trigger').click # open the filter dropdown
sleep 0.5 # wait for dropdown to open
end

within('div#request-creator-dropdown') do
expect(page).to have_field('creators[]', with: submitter.login.to_s)
expect(page).to have_no_field('creators[]', with: receiver.login.to_s)
within('#filters') do
uncheck("creators[#{receiver.login}]")
sleep 2
end

expect(page).to have_no_link(href: "/request/show/#{outgoing_request.number}")
expect(page).to have_link(href: "/request/show/#{other_incoming_request.number}")
expect(page).to have_no_link(href: "/request/show/#{incoming_request.number}")
end
# rubocop:enable RSpec/ExampleLength
end
end

0 comments on commit 50b69ec

Please sign in to comment.