From 50b69eca1d811db07a6062e22a56906912a57d09 Mon Sep 17 00:00:00 2001 From: Lukas Krause Date: Tue, 17 Dec 2024 21:22:46 +0100 Subject: [PATCH] Adapt `requests_index_spec` to cover creators filter --- .../beta/webui/requests_index_spec.rb | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/src/api/spec/features/beta/webui/requests_index_spec.rb b/src/api/spec/features/beta/webui/requests_index_spec.rb index 4648479ba58..635c8e250a3 100644 --- a/src/api/spec/features/beta/webui/requests_index_spec.rb +++ b/src/api/spec/features/beta/webui/requests_index_spec.rb @@ -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