mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Brings the tests back to green, after rebasing
This is a WIP branch, and each time we rebase we'll have some specs breaking. The changes in this commit mostly relate to the change in /admin/products URL, which points to the new BUU prodcts page; disabling the feature around related tests brings the branch back to green.
This commit is contained in:
committed by
David Cook
parent
308c559810
commit
9aecf9feb4
@@ -10,6 +10,11 @@ RSpec.describe '
|
||||
include AuthenticationHelper
|
||||
include WebHelper
|
||||
|
||||
around do |example|
|
||||
Flipper.disable(:admin_style_v3)
|
||||
example.run
|
||||
end
|
||||
|
||||
describe "listing products" do
|
||||
before do
|
||||
login_as_admin
|
||||
@@ -18,7 +23,6 @@ RSpec.describe '
|
||||
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
|
||||
@@ -201,8 +205,8 @@ RSpec.describe '
|
||||
login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
find("a", text: "New Product").click
|
||||
expect(page).to have_content 'New Product'
|
||||
find("a", text: "NEW PRODUCT").click
|
||||
expect(page).to have_content "NEW PRODUCT"
|
||||
|
||||
fill_in 'product_name', with: 'Big Bag Of Apples'
|
||||
select supplier.name, from: 'product_supplier_id'
|
||||
@@ -700,14 +704,14 @@ RSpec.describe '
|
||||
login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
expect(page).to have_selector "th", text: "Name"
|
||||
expect(page).to have_selector "th", text: "Producer"
|
||||
expect(page).to have_selector "th", text: "Price"
|
||||
expect(page).to have_selector "th", text: "On Hand"
|
||||
expect(page).to have_selector "th", text: "NAME"
|
||||
expect(page).to have_selector "th", text: "PRODUCER"
|
||||
expect(page).to have_selector "th", text: "PRICE"
|
||||
expect(page).to have_selector "th", text: "ON HAND"
|
||||
|
||||
toggle_columns /^.{0,1}Producer$/i
|
||||
|
||||
expect(page).not_to have_selector "th", text: "Producer"
|
||||
expect(page).to have_no_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"
|
||||
@@ -815,8 +819,8 @@ RSpec.describe '
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
find("a", text: "New Product").click
|
||||
expect(page).to have_content 'New Product'
|
||||
find("a", text: "NEW PRODUCT").click
|
||||
expect(page).to have_content 'NEW PRODUCT'
|
||||
expect(page).to have_select 'product_supplier_id',
|
||||
with_options: [supplier_managed1.name, supplier_managed2.name,
|
||||
supplier_permitted.name]
|
||||
|
||||
@@ -8,6 +8,11 @@ RSpec.describe "Product Import" do
|
||||
include AuthenticationHelper
|
||||
include WebHelper
|
||||
|
||||
around do |example|
|
||||
Flipper.disable(:admin_style_v3)
|
||||
example.run
|
||||
end
|
||||
|
||||
let!(:admin) { create(:admin_user) }
|
||||
let!(:user) { create(:user) }
|
||||
let!(:user2) { create(:user) }
|
||||
@@ -706,7 +711,8 @@ RSpec.describe "Product Import" do
|
||||
save_data
|
||||
|
||||
expect(page).to have_selector '.created-count', text: '1'
|
||||
expect(page).not_to have_selector '.updated-count'
|
||||
|
||||
expect(page).to have_no_selector '.updated-count'
|
||||
expect(page).to have_content "Go To Products Page"
|
||||
expect(page).to have_content "Upload Another File"
|
||||
|
||||
|
||||
@@ -280,76 +280,86 @@ RSpec.describe '
|
||||
end
|
||||
end
|
||||
|
||||
describe "deleting" do
|
||||
let!(:product1) { create(:simple_product, name: 'a product to keep', supplier: @supplier) }
|
||||
|
||||
context 'a simple product' do
|
||||
let!(:product2) { create(:simple_product, name: 'a product to delete', supplier: @supplier) }
|
||||
|
||||
before do
|
||||
login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
within "#p_#{product2.id}" do
|
||||
accept_alert { page.find("[data-powertip=Remove]").click }
|
||||
end
|
||||
visit current_path
|
||||
end
|
||||
|
||||
it 'removes it from the product list' do
|
||||
expect(page).not_to have_selector "#p_#{product2.id}"
|
||||
expect(page).to have_selector "#p_#{product1.id}"
|
||||
end
|
||||
describe "legacy products page" do
|
||||
around do |example|
|
||||
Flipper.disable(:admin_style_v3)
|
||||
example.run
|
||||
end
|
||||
|
||||
context 'a shipped product' do
|
||||
let!(:order) { create(:shipped_order, line_items_count: 1) }
|
||||
let!(:line_item) { order.reload.line_items.first }
|
||||
describe "deleting" do
|
||||
let!(:product1) { create(:simple_product, name: 'a product to keep', supplier: @supplier) }
|
||||
|
||||
context 'a simple product' do
|
||||
let!(:product2) {
|
||||
create(:simple_product, name: 'a product to delete', supplier: @supplier)
|
||||
}
|
||||
|
||||
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
|
||||
within "#p_#{product2.id}" do
|
||||
accept_alert { page.find("[data-powertip=Remove]").click }
|
||||
end
|
||||
visit current_path
|
||||
end
|
||||
|
||||
it 'removes it from the product list' do
|
||||
visit spree.admin_products_path
|
||||
|
||||
expect(page).not_to have_selector "#p_#{product2.id}"
|
||||
expect(page).to have_selector "#p_#{product1.id}"
|
||||
expect(page).not_to have_selector "#p_#{order.variants.first.product_id}"
|
||||
end
|
||||
end
|
||||
|
||||
it 'keeps the line item on the order (admin)' do
|
||||
visit spree.edit_admin_order_path(order)
|
||||
context 'a shipped product' do
|
||||
let!(:order) { create(:shipped_order, line_items_count: 1) }
|
||||
let!(:line_item) { order.reload.line_items.first }
|
||||
|
||||
expect(page).to have_content(line_item.product.name.to_s)
|
||||
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
|
||||
end
|
||||
|
||||
describe 'cloning' do
|
||||
let!(:product1) {
|
||||
create(:simple_product, name: 'a weight product', supplier: @supplier, variant_unit: "weight")
|
||||
}
|
||||
describe 'cloning' do
|
||||
let!(:product1) {
|
||||
create(:simple_product, name: 'a weight product', supplier: @supplier,
|
||||
variant_unit: "weight")
|
||||
}
|
||||
|
||||
context 'products' do
|
||||
before do
|
||||
login_as_admin
|
||||
visit spree.admin_products_path
|
||||
end
|
||||
|
||||
it 'creates a copy of the product' do
|
||||
within "#p_#{product1.id}" do
|
||||
page.find("[data-powertip=Clone]").click
|
||||
context 'products' do
|
||||
before do
|
||||
login_as_admin
|
||||
visit spree.admin_products_path
|
||||
end
|
||||
visit current_path
|
||||
within "#p_#{product1.id + 1}" do
|
||||
expect(page).to have_input "product_name", with: 'COPY OF a weight product'
|
||||
|
||||
it 'creates a copy of the product' do
|
||||
within "#p_#{product1.id}" do
|
||||
page.find("[data-powertip=Clone]").click
|
||||
end
|
||||
visit current_path
|
||||
within "#p_#{product1.id + 1}" do
|
||||
expect(page).to have_input "product_name", with: 'COPY OF a weight product'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,7 +128,7 @@ RSpec.describe 'Subscriptions' do
|
||||
accept_alert 'Are you sure?' do
|
||||
find("a.cancel-order").click
|
||||
end
|
||||
expect(page).to have_content 'CANCELLED'.upcase
|
||||
expect(page).to have_content 'CANCELLED'
|
||||
expect(proxy_order.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
|
||||
|
||||
# Resuming an order
|
||||
|
||||
@@ -237,12 +237,14 @@ RSpec.describe 'Subscriptions' do
|
||||
expect(page).to have_selector "#subscription-line-items .item", count: 4
|
||||
|
||||
# Delete an existing product
|
||||
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 }
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user