From da5f1b0b38d41669d4070cec1ce793e906edb80d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 21 Apr 2021 09:44:30 +0200 Subject: [PATCH] Update test for subscriptions search by email and name - We now display the name of the customer so we can search by its name: add specs about search by email/name --- spec/features/admin/subscriptions_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/features/admin/subscriptions_spec.rb b/spec/features/admin/subscriptions_spec.rb index 0b73748b97..0059c7692e 100644 --- a/spec/features/admin/subscriptions_spec.rb +++ b/spec/features/admin/subscriptions_spec.rb @@ -17,6 +17,8 @@ feature 'Subscriptions' do context 'listing subscriptions' do let!(:subscription) { create(:subscription, shop: shop, with_items: true, with_proxy_orders: true) } + let!(:customer) { create(:customer, name: "Customer A") } + let!(:other_subscription) { create(:subscription, shop: shop, customer: customer, with_items: true, with_proxy_orders: true) } let!(:subscription2) { create(:subscription, shop: shop2, with_items: true, with_proxy_orders: true) } let!(:subscription_unmanaged) { create(:subscription, shop: shop_unmanaged, with_items: true, with_proxy_orders: true) } @@ -57,10 +59,27 @@ feature 'Subscriptions' do # Using the Quick Search expect(page).to have_selector "tr#so_#{subscription.id}" + expect(page).to have_selector "tr#so_#{other_subscription.id}" + + # Using the Quick Search: no result fill_in 'query', with: 'blah blah blah' expect(page).to have_no_selector "tr#so_#{subscription.id}" + expect(page).to have_no_selector "tr#so_#{other_subscription.id}" + + # Using the Quick Search: filter by email + fill_in 'query', with: other_subscription.customer.email + expect(page).to have_selector "tr#so_#{other_subscription.id}" + expect(page).to have_no_selector "tr#so_#{subscription.id}" + + # Using the Quick Search: filter by name + fill_in 'query', with: other_subscription.customer.name + expect(page).to have_selector "tr#so_#{other_subscription.id}" + expect(page).to have_no_selector "tr#so_#{subscription.id}" + + # Using the Quick Search: reset filter fill_in 'query', with: '' expect(page).to have_selector "tr#so_#{subscription.id}" + expect(page).to have_selector "tr#so_#{other_subscription.id}" # Toggling columns expect(page).to have_selector "th.customer"