Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUU] Activate admin_style_v3 for most system specs #11645

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
500b9ed
Enables admin_style_v3 toggle by default
filipefurtad0 Oct 10, 2023
308c559
Fixes case on assertions, on failing specs
filipefurtad0 Oct 12, 2023
9aecf9f
Brings the tests back to green, after rebasing
filipefurtad0 Oct 25, 2023
5e4381c
Fixes case on failing test
filipefurtad0 Nov 21, 2023
1c580c4
Adds assertions on products page, when no products are found
filipefurtad0 Nov 22, 2023
b9bb4a4
displays a list of products
filipefurtad0 Nov 28, 2023
8a19870
Fixes case on reports_spec.rb
filipefurtad0 Dec 13, 2023
5271361
Fixes case on products_spec.rb
filipefurtad0 Dec 13, 2023
8897e99
Clicks OC warning modal away so other buttons are reachable
filipefurtad0 Dec 13, 2023
4871e00
Deals with overlapping elements
filipefurtad0 Dec 13, 2023
50c7392
Deals with overlapping elements
filipefurtad0 Dec 13, 2023
7303c40
Introduces helper to deal with overlapping elements
filipefurtad0 Dec 13, 2023
c789489
Deals with overlapping elements
filipefurtad0 Dec 13, 2023
2937bdc
Deals with overlapping elements
filipefurtad0 Dec 13, 2023
e09fa3e
Updates v3 products page
filipefurtad0 Dec 13, 2023
3af5330
Updates product category test
filipefurtad0 Jan 3, 2024
d88db13
Updates specs to accomodate changes on warnings/banners
filipefurtad0 Jan 16, 2024
289414a
Adds tests around product creation
filipefurtad0 Jan 16, 2024
5af5eb7
Replaces all with find, within tom_select helper method
filipefurtad0 Jan 17, 2024
c4b2748
Adds pending test case on creating variants
filipefurtad0 Jan 18, 2024
8b036e5
Removes search block - covered already a few lines below
filipefurtad0 Jan 18, 2024
2c37783
Updates selector
filipefurtad0 Jan 26, 2024
0fa272a
Changes helper for dropdown selection
filipefurtad0 Feb 8, 2024
0a4c2a1
Updates tom_select_helper.rb with the recent changes from master
filipefurtad0 Feb 12, 2024
4e24af2
Applies helper changes
filipefurtad0 Feb 12, 2024
03a9f68
Fixes rubocop inconsistency
filipefurtad0 Apr 1, 2024
bcbc7c7
Fixes rubocop inconsistency
filipefurtad0 Apr 1, 2024
5824516
Fixes case
filipefurtad0 Apr 1, 2024
9f98dc2
Adds assertions on table header
filipefurtad0 Apr 1, 2024
80e8177
Mouse hovering displays the text
filipefurtad0 Apr 1, 2024
c226b10
Updates case on orders_spec.rb
filipefurtad0 Apr 16, 2024
ba355fd
Removes mouse clicks to display variants
filipefurtad0 Apr 16, 2024
8028610
Updates spec to create a variant within BUU design
filipefurtad0 Apr 17, 2024
9e25893
Sets variant creation scenarios on_hand/on_demand as shared examples
filipefurtad0 Apr 18, 2024
6dfef81
Fixes rebase
filipefurtad0 May 20, 2024
3a8c44d
fixup: Updates spec to create a variant within BUU design
dacook Jul 1, 2024
39cae44
Fix more uppercase tests after rebase
dacook Jul 1, 2024
5f01bb4
Remove unecessary message
dacook Jul 1, 2024
109432d
fixup: feature toggle old screen
dacook Jul 1, 2024
b1721d6
todo: make specs work with admin_style_v3
dacook Jul 1, 2024
c80199e
Use normal capitalisation for translation
dacook Jul 1, 2024
b1aafbf
Remove old migration spec
dacook Jul 1, 2024
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
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3863,7 +3863,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
logout: "Logout"

date_range: "Date Range"
status: "status"
status: "Status"
new: "New"
start: "Start"
end: "End"
Expand Down
4 changes: 4 additions & 0 deletions spec/base_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
config.before(:each) do
Flipper.features.each(&:remove)
OpenFoodNetwork::FeatureToggle.setup!

# activate feature toggle admin_style_v3 to use new admin interface and run the build
Flipper.enable(:admin_style_v3)
end

config.before(:each, :feature) do |example|
Expand Down Expand Up @@ -284,6 +287,7 @@ def handle_webmock_error(exception)
config.include OpenFoodNetwork::PerformanceHelper
config.include ActiveJob::TestHelper
config.include ReportsHelper
config.include TomSelectHelper, type: :system

config.include ViewComponent::TestHelpers, type: :component

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion spec/support/features/datepicker_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Features
module DatepickerHelper
def choose_today_from_datepicker
within(".flatpickr-calendar.open") do
find("button", text: "TODAY").click
find("button", text: "Today").click
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/support/overlapping_elements_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

def dismiss_warning
# Click dismiss on distributor warning
click_button 'Dismiss'
end

def trigger_click(id, text)
# replace node buy the elements node, for example
page.find(id, text).trigger("click")
end
39 changes: 39 additions & 0 deletions spec/support/tom_select_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

module TomSelectHelper
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are already some helper for tom select here :

def tomselect_multiselect(value, options)

But like the idea of moving them to their own helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I was unaware of those existing helpers... I'll move them to this file. The build should actually stay green, as we're calling the new file from base_spec_helper...

def tomselect_open(field_name)
page.find("##{field_name}-ts-control").click
end

def tomselect_multiselect(value, options)
tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper")
tomselect_wrapper.find(".ts-control").click
tomselect_wrapper.find(:css, '.ts-dropdown.multi .ts-dropdown-content .option',
text: value).click
end

def tomselect_search_and_select(value, options)
tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper")
tomselect_wrapper.find(".ts-control").click
# Use send_keys as setting the value directly doesn't trigger the search
tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').send_keys(value)
tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click
end

def tomselect_select(value, options)
tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper")
tomselect_wrapper.find(".ts-control").click

tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click
end

def select_tom_select(value, from:)
container = find(:id, from)

within(container) do
find('.ts-control').send_keys(value)
dacook marked this conversation as resolved.
Show resolved Hide resolved
end

find('.ts-dropdown .ts-dropdown-content .option', text: /#{Regexp.quote(value)}/i).click
end
end
4 changes: 2 additions & 2 deletions spec/system/admin/authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_login_button
expect(page).to have_content "DASHBOARD"
expect(page).to have_content "Dashboard"
expect(page).to have_current_path spree.admin_dashboard_path
expect(page).not_to have_content "CONFIGURATION"
expect(page).not_to have_content "Configuration"
end

it "viewing my account" do
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/bulk_order_cancellation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
expect(page).to have_selector('span', text: 'COMPLETE', count: 2)

page.find('#selectAll').trigger('click')
page.find("span.icon-reorder", text: "ACTIONS").click
page.find("span.icon-reorder", text: "Actions").click
within ".ofn-drop-down .menu" do
expect(page).to have_selector("span", text: "Cancel Orders")
page.find("span", text: "Cancel Orders").click
Expand All @@ -43,7 +43,7 @@
.and change { o2.reload.state }.from('complete').to('canceled')
end

# Verify that the orders have a STATE of CANCELLED
# Verify that the orders have a STATE of Cancelled
expect(page).to have_selector('span.canceled', text: 'CANCELLED', count: 2)
end
end
Expand Down
46 changes: 23 additions & 23 deletions spec/system/admin/bulk_order_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
end

it "orders by completion date" do
find("a", text: 'COMPLETED AT').click # sets ascending ordering
find("a", text: 'Completed at').click # sets ascending ordering
expect(page).to have_content(
/#{li2.product.name}.*#{li1.product.name}.*#{li22.product.name}.*#{li21.product.name}/m
)
find("a", text: 'COMPLETED AT').click # sets descending ordering
find("a", text: 'Completed at').click # sets descending ordering
expect(page).to have_content(
/#{li21.product.name}.*#{li22.product.name}.*#{li1.product.name}.*#{li2.product.name}/m
)
Expand Down Expand Up @@ -155,9 +155,9 @@
expect(page).to have_content "Little Fish", count: 15
expect(page).not_to have_content "Big Fish"
end
find("a", text: "Clear").click # closes BOM box
expect(page).to have_content "Little Fish", count: 10
click_link "Clear" # closes BOM box
expect(page).to have_content "Big Fish", count: 5
expect(page).to have_content "Little Fish", count: 10
end
end

Expand Down Expand Up @@ -311,7 +311,7 @@
end

it "displays a column for user's full name" do
expect(page).to have_selector "th.full_name", text: "NAME"
expect(page).to have_selector "th.full_name", text: "Name"
expect(page)
.to have_selector "td.full_name",
text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}"
Expand All @@ -320,33 +320,33 @@

it "displays a column for order date" do
expect(page).to have_selector "th.date",
text: 'Completed at'.upcase
text: 'Completed at'
expect(page).to have_selector "td.date", text: o1.completed_at.strftime('%B %d, %Y')
expect(page).to have_selector "td.date", text: o2.completed_at.strftime('%B %d, %Y')
end

it "displays a column for producer" do
expect(page).to have_selector "th.producer", text: "PRODUCER"
expect(page).to have_selector "th.producer", text: "Producer"
expect(page).to have_selector "td.producer", text: li1.product.supplier.name
expect(page).to have_selector "td.producer", text: li2.product.supplier.name
end

it "displays a column for variant description, which shows only product name " \
"when options text is blank" do
expect(page).to have_selector "th.variant", text: "PRODUCT: UNIT"
expect(page).to have_selector "th.variant", text: "Product: Unit"
expect(page).to have_selector "td.variant", text: li1.product.name
expect(page).to have_selector "td.variant",
text: "#{li2.product.name}: #{li2.variant.options_text}"
end

it "displays a field for quantity" do
expect(page).to have_selector "th.quantity", text: "QUANTITY"
expect(page).to have_selector "th.quantity", text: "Quantity"
expect(page).to have_field "quantity", with: li1.quantity.to_s
expect(page).to have_field "quantity", with: li2.quantity.to_s
end

it "displays a column for max quantity" do
expect(page).to have_selector "th.max", text: "MAX"
expect(page).to have_selector "th.max", text: "Max"
expect(page).to have_selector "td.max", text: li1.max_quantity.to_s
expect(page).to have_selector "td.max", text: li2.max_quantity.to_s
end
Expand Down Expand Up @@ -550,13 +550,13 @@

context "using column display toggle" do
it "displays the default selected columns" do
expect(page).to have_selector "th", text: "NAME"
expect(page).to have_selector "th", text: "Name"
expect(page).to have_selector "th",
text: 'Completed at'.upcase
expect(page).to have_selector "th", text: "PRODUCER"
expect(page).to have_selector "th", text: "PRODUCT: UNIT"
expect(page).to have_selector "th", text: "QUANTITY"
expect(page).to have_selector "th", text: "MAX"
text: 'Completed at'
expect(page).to have_selector "th", text: "Producer"
expect(page).to have_selector "th", text: "Product: Unit"
expect(page).to have_selector "th", text: "Quantity"
expect(page).to have_selector "th", text: "Max"
end

context "hiding a column, by de-selecting it from the drop-down" do
Expand All @@ -565,13 +565,13 @@
end

it "shows all default columns, except the de-selected column" do
expect(page).not_to have_selector "th", text: "PRODUCER"
expect(page).to have_selector "th", text: "NAME"
expect(page).not_to have_selector "th", text: "Producer"
expect(page).to have_selector "th", text: "Name"
expect(page).to have_selector "th",
text: 'Completed at'.upcase
expect(page).to have_selector "th", text: "PRODUCT: UNIT"
expect(page).to have_selector "th", text: "QUANTITY"
expect(page).to have_selector "th", text: "MAX"
text: 'Completed at'
expect(page).to have_selector "th", text: "Product: Unit"
expect(page).to have_selector "th", text: "Quantity"
expect(page).to have_selector "th", text: "Max"
end
end
end
Expand Down Expand Up @@ -1209,7 +1209,7 @@

context "clicking 'Clear' in group buy box" do
before :each do
find("a", text: "Clear").click
click_link "Clear" # closes BOM box
end

it "shows all products and clears group buy box" do
Expand Down
19 changes: 8 additions & 11 deletions spec/system/admin/bulk_product_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

RSpec.describe '
As an Administrator
I want to be able to manage products in bulk
I want to be able to manage products in bulk (with the old Products screen)
' do
include AdminHelper
include AuthenticationHelper
include WebHelper

before { Flipper.disable(:admin_style_v3) }

describe "listing products" do
before do
login_as_admin
Expand All @@ -18,19 +20,12 @@
it "displays a list of products" do
p1 = FactoryBot.create(:product)
p2 = FactoryBot.create(:product)

visit spree.admin_products_path

expect(page).to have_field "product_name", with: p1.name
expect(page).to have_field "product_name", with: p2.name
end

it "displays a message when number of products is zero" do
visit spree.admin_products_path

expect(page).to have_text "No products yet. Why don't you add some?"
end

Comment on lines -28 to -33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main commit message doesn't reflect the commit content.

it "displays a select box for suppliers, with the appropriate supplier selected" do
s1 = FactoryBot.create(:supplier_enterprise)
s2 = FactoryBot.create(:supplier_enterprise)
Expand Down Expand Up @@ -202,7 +197,7 @@
visit spree.admin_products_path

find("a", text: "NEW PRODUCT").click
expect(page).to have_content 'NEW PRODUCT'
expect(page).to have_content "NEW PRODUCT"

fill_in 'product_name', with: 'Big Bag Of Apples'
select supplier.name, from: 'product_supplier_id'
Expand Down Expand Up @@ -311,8 +306,10 @@
end

it "creating a variant with unit value is: '120g' and 'on_demand' checked" do
scroll_to(:bottom)

within "tr#v_#{v2.id}" do
page.find(".add-variant").trigger("click")
page.find(".add-variant").click
end

within "tr#v_-1" do
Expand Down Expand Up @@ -705,7 +702,7 @@

toggle_columns /^.{0,1}Producer$/i

expect(page).not_to have_selector "th", text: "PRODUCER"
expect(page).not_to have_selector "th", text: "Producer"
expect(page).to have_selector "th", text: "NAME"
expect(page).to have_selector "th", text: "PRICE"
expect(page).to have_selector "th", text: "ON HAND"
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/configuration/general_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

context 'editing currency symbol position' do
it 'updates its position' do
expect(page).to have_content('CURRENCY SETTINGS')
expect(page).to have_content('Currency Settings')

within('.currency') do
find("[for='currency_symbol_position_after']").click
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/customers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
end

it 'updates the existing billing address' do
expect(page).to have_content 'BILLING ADDRESS'
expect(page).to have_content 'Billing Address'
first('#bill-address-link').click
wait_for_modal_fade_in

Expand All @@ -374,7 +374,7 @@
end

it 'creates a new shipping address' do
expect(page).to have_content 'SHIPPING ADDRESS'
expect(page).to have_content 'Shipping Address'

first('#ship-address-link').click
wait_for_modal_fade_in
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/enterprise_roles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
def navigate_to_enterprise_users
scroll_to(:bottom)
within ".side_menu" do
click_link "Users"
trigger_click(:link, "Users")
end
end

Expand Down
Loading
Loading