diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index ff9c2e19d9..e14ca90559 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -38,7 +38,7 @@ %tr %td.align-left.header = product_form.hidden_field :id, name: "[products][#{i}][id]" #todo: can we remove #{i} and implicitly pop? - .line-clamp-1= product_form.text_field :name, name: "[products][#{i}][name]", id: "_product_name_#{product.id}", 'aria-label': t('admin.products_page.columns.name') + .line-clamp-1= product_form.text_field :name, name: "[products][#{i}][name]", 'aria-label': t('admin.products_page.columns.name') %td.align-right .line-clamp-1= product.sku %td.align-right diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index e5bc71f5ae..bd5abc6c52 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -163,7 +163,9 @@ describe 'As an admin, I can see the new product page' do end it "can update product fields" do - fill_in id: "_product_name_#{product_1.id}", with: "An updated name" + within row_containing_name("product 1") do + fill_in "Name", with: "An updated name" + end expect { click_button "Save changes" @@ -172,7 +174,9 @@ describe 'As an admin, I can see the new product page' do change { product_1.name }.to("An updated name") ) - expect(page).to have_field id: "_product_name_#{product_1.id}", with: "An updated name" + within row_containing_name("An updated name") do + expect(page).to have_field "Name", with: "An updated name" + end pending expect(page).to have_content "Changes saved" end @@ -205,4 +209,11 @@ describe 'As an admin, I can see the new product page' do select category, from: "category_id" 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. + def row_containing_name(value) + "tr:has(input[aria-label=Name][value='#{value}'])" + end end