Skip to content

Commit

Permalink
Merge pull request #12652 from filipefurtad0/activate_admin_style_v3_…
Browse files Browse the repository at this point in the history
…for_dev_test_and_new_servers

[BUU] Prepares specs for enabling admin_style_v3 by default
  • Loading branch information
mkllnk authored Jul 11, 2024
2 parents f1713b1 + c86f7f9 commit aec9a96
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 96 deletions.
11 changes: 0 additions & 11 deletions spec/support/overlapping_elements_helper.rb

This file was deleted.

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
trigger_click(:link, "Users")
click_link "Users"
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
include AuthenticationHelper
include WebHelper

let(:distributor_enterprise) { create(:distributor_enterprise, with_payment_and_shipping: true) }
let(:oc) { create(:order_cycle, distributors: [distributor_enterprise]) }

it "Alerts for unsaved changes on general settings (/edit) page" do
oc = create(:order_cycle)
login_as_admin
visit edit_admin_order_cycle_path(oc)

Expand All @@ -35,9 +37,6 @@
click_link 'Orders'
end

# Click dismiss on distributor warning
click_button 'Dismiss'

# Click cancel with unsaved changes
dismiss_confirm "" do
click_button 'Cancel'
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/order_cycles/complex_editing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
.to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M"))
expect(page).to have_content "Coordinator #{oc.coordinator.name}"

trigger_click(:button, 'Next')
click_button "Next"

# And I should see the suppliers
expect(page).to have_selector 'td.supplier_name', text: oc.suppliers.first.name
Expand Down Expand Up @@ -76,7 +76,7 @@
selected: supplier.enterprise_fees.first.name
)

trigger_click(:button, 'Next')
click_button "Next"

# And I should see the distributors
expect(page).to have_selector 'td.distributor_name', text: oc.distributors.first.name
Expand Down
26 changes: 17 additions & 9 deletions spec/system/admin/order_cycles/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,32 @@
include AuthenticationHelper
include WebHelper

let(:hub) { create(:distributor_enterprise, with_payment_and_shipping: true) }

it "listing and filtering order cycles" do
# Given some order cycles (created in an arbitrary order)
oc4 = create(:simple_order_cycle, name: 'oc4',
orders_open_at: 2.days.from_now,
orders_close_at: 1.month.from_now)
oc2 = create(:simple_order_cycle, name: 'oc2', orders_close_at: 1.month.from_now)
orders_close_at: 1.month.from_now, distributors: [hub])
oc2 = create(:simple_order_cycle, name: 'oc2',
orders_close_at: 1.month.from_now, distributors: [hub])
oc6 = create(:simple_order_cycle, name: 'oc6',
orders_open_at: 1.month.ago, orders_close_at: 3.weeks.ago)
orders_open_at: 1.month.ago, orders_close_at: 3.weeks.ago,
distributors: [hub])
oc3 = create(:simple_order_cycle, name: 'oc3',
orders_open_at: 1.day.from_now,
orders_close_at: 1.month.from_now)
orders_close_at: 1.month.from_now,
distributors: [hub])
oc5 = create(:simple_order_cycle, name: 'oc5',
orders_open_at: 1.month.ago, orders_close_at: 2.weeks.ago)
oc1 = create(:order_cycle, name: 'oc1')
orders_open_at: 1.month.ago, orders_close_at: 2.weeks.ago,
distributors: [hub])
oc1 = create(:order_cycle, name: 'oc1', distributors: [hub])
oc0 = create(:simple_order_cycle, name: 'oc0',
orders_open_at: nil, orders_close_at: nil)
orders_open_at: nil, orders_close_at: nil,
distributors: [hub])
oc7 = create(:simple_order_cycle, name: 'oc7',
orders_open_at: 2.months.ago, orders_close_at: 5.weeks.ago)
orders_open_at: 2.months.ago, orders_close_at: 5.weeks.ago,
distributors: [hub])
schedule1 = create(:schedule, name: 'Schedule1', order_cycles: [oc1, oc3])
create(:proxy_order, subscription: create(:subscription, schedule: schedule1), order_cycle: oc1)

Expand Down Expand Up @@ -73,7 +81,7 @@

# I can load more order_cycles
expect(page).not_to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}"
trigger_click(:button, "Show 30 more days")
click_button "Show 30 more days"

expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}"

Expand Down
4 changes: 1 addition & 3 deletions spec/system/admin/order_cycles/simple_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,7 @@
"table.exchanges tr.distributor-#{distributor_managed.id} td.tags"
)

# When I save, any exchanges that I can't manage remain
# overlapping warning, we need to use 'node.trigger("click")'
page.find(:button, "Save").trigger("click")
click_button "Save"
expect(page).to have_content "Your order cycle has been updated."

oc.reload
Expand Down
14 changes: 7 additions & 7 deletions spec/system/admin/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def new_order_with_distribution(distributor, order_cycle)

check 'order_use_billing'

trigger_click(:button, 'Update')
click_button "Update"

expect(page).to have_content 'Customer Details updated'

Expand All @@ -156,7 +156,7 @@ def new_order_with_distribution(distributor, order_cycle)
expect(page).to have_field 'order_email', with: customer3.email

expect do
trigger_click(:button, 'Update')
click_button "Update"
expect(page).to have_content 'Customer Details updated'
end.to change { order.reload.customer }.from(customer2).to(customer3)
end
Expand Down Expand Up @@ -292,7 +292,7 @@ def new_order_with_distribution(distributor, order_cycle)
login_as_admin
visit spree.edit_admin_order_path(order)

dismiss_warning
click_button 'Dismiss'

expect(page).to have_select2 "order_distributor_id", with_options: [d.name]
select2_select d.name, from: 'order_distributor_id'
Expand Down Expand Up @@ -778,7 +778,7 @@ def new_order_with_distribution(distributor, order_cycle)
visit spree.edit_admin_order_path(order)

expect(page).not_to have_content different_shipping_method_for_distributor1.name
dismiss_warning
click_button 'Dismiss'

find('.edit-method').click

Expand Down Expand Up @@ -1088,7 +1088,7 @@ def new_order_with_distribution(distributor, order_cycle)
end

# updates the order and verifies the warning disappears
trigger_click(:button, 'Update And Recalculate Fees')
click_button "Update And Recalculate Fees"
expect(page).not_to have_content "Out of Stock"
end
end
Expand All @@ -1099,7 +1099,7 @@ def new_order_with_distribution(distributor, order_cycle)
expect(page).to have_selector 'h1', text: 'Customer Details'
click_link "Order Details"

dismiss_warning
click_button 'Dismiss'

expect(page).to have_content 'Add Product'
select2_select product.name, from: 'add_variant_id', search: true
Expand All @@ -1111,7 +1111,7 @@ def new_order_with_distribution(distributor, order_cycle)
expect(page).to have_select2 'order_distributor_id', with_options: [distributor1.name]
expect(page).not_to have_select2 'order_distributor_id', with_options: [distributor2.name]

dismiss_warning
click_button 'Dismiss'

expect(page).to have_select2 'order_order_cycle_id',
with_options: ["#{order_cycle1.name} (open)"]
Expand Down
12 changes: 4 additions & 8 deletions spec/system/admin/product_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,12 @@
expect(potatoes.variants.first.price).to eq 6.50
expect(potatoes.variants.first.import_date).to be_within(1.minute).of Time.zone.now

wait_until { page.find("a.button.view").present? }

puts "TODO: migrate to v3"
Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page
click_link 'Go To Products Page'

expect(page).to have_content 'Bulk Edit Products'
wait_until { page.find("#p_#{potatoes.id}").present? }
expect(page).to have_field "product_name", with: carrots.name
expect(page).to have_field "product_name", with: potatoes.name

# displays product list
expect(page).to have_field("_products_2_name", with: carrots.name.to_s)
expect(page).to have_field("_products_5_name", with: potatoes.name.to_s)
end

it "displays info about invalid entries but no save button if all items are invalid" do
Expand Down
29 changes: 0 additions & 29 deletions spec/system/admin/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,35 +278,6 @@
expect(page).to have_selector "#p_#{product1.id}"
end
end

context 'a shipped product' do
let!(:order) { create(:shipped_order, line_items_count: 1) }
let!(:line_item) { order.reload.line_items.first }

context "a deleted line item from a shipped order" do
before do
login_as_admin
visit spree.admin_products_path

within "#p_#{order.variants.first.product_id}" do
accept_alert { page.find("[data-powertip=Remove]").click }
end
end

it 'removes it from the product list' do
visit spree.admin_products_path

expect(page).to have_selector "#p_#{product1.id}"
expect(page).not_to have_selector "#p_#{order.variants.first.product_id}"
end

it 'keeps the line item on the order (admin)' do
visit spree.edit_admin_order_path(order)

expect(page).to have_content(line_item.product.name.to_s)
end
end
end
end

describe 'cloning' do
Expand Down
21 changes: 7 additions & 14 deletions spec/system/admin/products_v3/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,8 @@ def expect_other_columns_visible
page.find(".vertical-ellipsis-menu").click
page.find(delete_option_selector).click
end
keep_button_selector = "input[type=button][value='Keep product']"
within modal_selector do
page.find(keep_button_selector).click
click_button "Keep product"
end

expect(page).not_to have_selector(modal_selector)
Expand All @@ -364,9 +363,8 @@ def expect_other_columns_visible
page.find(".vertical-ellipsis-menu").click
page.find(delete_option_selector).click
end
keep_button_selector = "input[type=button][value='Keep variant']"
within modal_selector do
page.find(keep_button_selector).click
click_button "Keep variant"
end

expect(page).not_to have_selector(modal_selector)
Expand All @@ -385,9 +383,8 @@ def expect_other_columns_visible
page.find(delete_option_selector).click
end

delete_button_selector = "input[type=button][value='Delete variant']"
within modal_selector do
page.find(delete_button_selector).click
click_button "Delete variant"
end

expect(page).not_to have_selector(modal_selector)
Expand All @@ -402,9 +399,8 @@ def expect_other_columns_visible
page.find(".vertical-ellipsis-menu").click
page.find(delete_option_selector).click
end
delete_button_selector = "input[type=button][value='Delete product']"
within modal_selector do
page.find(delete_button_selector).click
click_button "Delete product"
end
expect(page).not_to have_selector(modal_selector)
expect(page).not_to have_selector(product_selector)
Expand All @@ -424,9 +420,8 @@ def expect_other_columns_visible
page.find(delete_option_selector).click
end

delete_button_selector = "input[type=button][value='Delete variant']"
within modal_selector do
page.find(delete_button_selector).click
click_button "Delete variant"
end

within error_flash_message_selector do
Expand All @@ -439,9 +434,8 @@ def expect_other_columns_visible
page.find(".vertical-ellipsis-menu").click
page.find(delete_option_selector).click
end
delete_button_selector = "input[type=button][value='Delete product']"
within modal_selector do
page.find(delete_button_selector).click
click_button "Delete product"
end
within error_flash_message_selector do
expect(page).to have_content("Unable to delete the product")
Expand All @@ -464,9 +458,8 @@ def expect_other_columns_visible
page.find(delete_option_selector).click
end

delete_button_selector = "input[type=button][value='Delete variant']"
within modal_selector do
page.find(delete_button_selector).click
click_button "Delete variant"
end
end

Expand Down
22 changes: 14 additions & 8 deletions spec/system/admin/subscriptions/smoke_tests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'system_helper'

RSpec.describe 'Subscriptions' do
RSpec.describe 'Subscriptions', feature: :admin_style_v3 do
include AdminHelper
include AuthenticationHelper
include WebHelper
Expand Down Expand Up @@ -242,15 +242,21 @@
expect(page).to have_selector "#subscription-line-items .item", count: 4

# Delete an existing product
puts "TODO: migrate to v3" # but first we need to make the actions menu more accessible.
Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page
login_as_admin
visit spree.admin_products_path
within "#p_#{shop_product2.id}" do
accept_alert { page.find("[data-powertip=Remove]").click }
visit admin_products_url

product_selector = row_containing_name(shop_product2.name)
delete_option_selector = "a[data-controller='modal-link'].delete"
delete_button_selector = "input[type=button][value='Delete product']"
modal_selector = "div[data-modal-target=modal]"

within product_selector do
page.find(".vertical-ellipsis-menu").click
page.find(delete_option_selector).click
end
within modal_selector do
click_button "Delete product"
end

Flipper.enable(:admin_style_v3) # re-enabling it for the rest of the spec
visit edit_admin_subscription_path(subscription)

# Remove deleted shop_variant from the subscription
Expand Down

0 comments on commit aec9a96

Please sign in to comment.