Add system test for tags

This commit is contained in:
Gaetan Craig-Riou
2025-05-05 14:38:09 +10:00
parent 0ca3dca675
commit 347d20c3fb
4 changed files with 28 additions and 2 deletions

View File

@@ -16,4 +16,4 @@
%span=tag
%a.remove-button{ "data-action": "click->tag-list-input-component--tag-list-input#removeTag" }
×
= text_field_tag "variant_add_tag_#{f.object.id}".to_sym, nil, class: "input", placeholder: placeholder, "data-action": "keydown.enter->tag-list-input-component--tag-list-input#addTag keyup->tag-list-input-component--tag-list-input#filterInput", "data-tag-list-input-component--tag-list-input-target": "newTag"
= text_field_tag "variant_add_tag_#{f.object.id}".to_sym, nil, "aria-label": "Tags", class: "input", placeholder: placeholder, "data-action": "keydown.enter->tag-list-input-component--tag-list-input#addTag keyup->tag-list-input-component--tag-list-input#filterInput", "data-tag-list-input-component--tag-list-input-target": "newTag"

View File

@@ -34,6 +34,11 @@ module ProductsHelper
click_button "Search"
end
def search_by_tag(tag)
tomselect_multiselect tag, from: "tags_name_in"
click_button "Search"
end
# Selector for table row that has an input with this value.
# Because there are no visible labels, the user has to assume which product it is, based on the
# visible name.

View File

@@ -377,5 +377,22 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
expect(page).to have_field "Name", with: product_by_category.name
end
end
context "with variant tag", feature: :variant_tag do
before do
create(:variant, tag_list: "organic")
create_products 1
end
it "can search by tag" do
visit admin_products_url
pause
search_by_tag "organic"
expect(page).to have_select "tags_name_in", selected: "organic"
expect(page).to have_content "1 product found for your search criteria. Showing 1 to 1."
expect_products_count_to_be 1
end
end
end
end

View File

@@ -20,7 +20,7 @@ RSpec.describe 'As an enterprise user, I can update my products' do
let(:categories_search_selector) { 'input[placeholder="Search for categories"]' }
let(:tax_categories_search_selector) { 'input[placeholder="Search for tax categories"]' }
describe "updating" do
describe "updating", feature: :variant_tag do
let!(:taxon) { create(:taxon) }
let!(:variant_a1) {
product_a.variants.first.tap{ |v|
@@ -65,6 +65,9 @@ RSpec.describe 'As an enterprise user, I can update my products' do
fill_in "Unit value", with: "500.1"
fill_in "Price", with: "10.25"
fill_in "Tags", with: "tag one"
find_field("Tags").send_keys(:enter) # add the tag
# Stock popout
click_on "On Hand" # activate popout
fill_in "On Hand", with: "-1"
@@ -89,6 +92,7 @@ RSpec.describe 'As an enterprise user, I can update my products' do
.and change{ variant_a1.on_hand }.to(6)
.and change{ variant_a1.variant_unit }.to("volume")
.and change{ variant_a1.variant_unit_scale }.to(0.001)
.and change{ variant_a1.tag_list }.to(["tag one"])
within row_containing_name("Pommes") do
expect(page).to have_field "Name", with: "Pommes"