Merge pull request #12898 from dacook/buu-producer-specs

[BUU] Add missing specs
This commit is contained in:
Gaetan Craig-Riou
2024-10-16 10:05:20 +11:00
committed by GitHub
2 changed files with 51 additions and 17 deletions

View File

@@ -47,22 +47,6 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
end
end
it "displays a select box for suppliers, with the appropriate supplier selected" do
pending( "[BUU] Change producer, unit type, category and tax category #11060" )
s1 = FactoryBot.create(:supplier_enterprise)
s2 = FactoryBot.create(:supplier_enterprise)
s3 = FactoryBot.create(:supplier_enterprise)
p1 = FactoryBot.create(:product, supplier_id: s2.id)
p2 = FactoryBot.create(:product, supplier_id: s3.id)
visit spree.admin_products_path
expect(page).to have_select "producer_id", with_options: [s1.name, s2.name, s3.name],
selected: s2.name
expect(page).to have_select "producer_id", with_options: [s1.name, s2.name, s3.name],
selected: s3.name
end
context "with several variants" do
let!(:variant1) { p1.variants.first }
let!(:variant2a) { p2.variants.first }
@@ -91,6 +75,38 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
expect(page).to have_content "4"
end
end
describe "Producer column" do
it "when I have one enterprise" do
visit spree.admin_products_path
expect(page).not_to have_select "Producer"
end
context "when I have multiple enterprises" do
let(:user) { create(:user, enterprises: [producer2, producer1]) }
let(:producer1) { create(:supplier_enterprise, name: "Producer A") }
let(:producer2) { create(:supplier_enterprise, name: "Producer B") }
it "displays a select box for suppliers, with the appropriate supplier selected" do
create(:supplier_enterprise, name: "Producer C")
variant1.update!(supplier: producer1)
variant2a.update!(supplier: producer2)
visit spree.admin_products_path
within row_containing_name "Variant1" do
expect(page).to have_select "Producer", with_options: ["Producer A", "Producer B"],
selected: "Producer A"
end
within row_containing_name "Variant2a" do
expect(page).to have_select "Producer", with_options: ["Producer A", "Producer B"],
selected: "Producer B"
end
end
end
end
end
it "displays a select box for the unit of measure for the product's variants" do
@@ -296,7 +312,7 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
end
end
context "product has producer" do
context "User has multiple producers" do
before { create_products 1 }
# create a product with a different supplier
@@ -334,6 +350,14 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
end
end
context "User has single producer" do
it "producer filter does not show" do
visit admin_products_url
expect(page).not_to have_select "Producers"
end
end
context "product has category" do
before { create_products 1 }

View File

@@ -215,6 +215,8 @@ RSpec.describe 'As an enterprise user, I can update my products' do
end
end
# it "can select only the producers that I manage"
it "discards changes and reloads latest data" do
within row_containing_name("Apples") do
fill_in "Name", with: "Pommes"
@@ -437,6 +439,14 @@ RSpec.describe 'As an enterprise user, I can update my products' do
expect(page).not_to have_css('form.disabled-section#filters')
end
xdescribe "producer" do
it "can select only the producers that I manage"
context " when I manage only one producer" do
it "producer select doesn't show, and is saved correctly"
end
end
context "With 2 products" do
before do
variant_b1