Merge pull request #12525 from mkllnk/fdc-import

Add compatibility to the DFC product import for FDC (Shopify) API
This commit is contained in:
Maikel
2024-06-13 09:51:05 +10:00
committed by GitHub
11 changed files with 569 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -40,4 +40,9 @@ VCR.configure do |config|
config.filter_sensitive_data('<HIDDEN-OPENID-TOKEN>') { |interaction|
interaction.response.body.match(/"refresh_token":"([^"]+)"/)&.public_send(:[], 1)
}
# FDC specific parameter:
config.filter_sensitive_data('<HIDDEN-OPENID-TOKEN>') { |interaction|
interaction.request.body.match(/"accessToken":"([^"]+)"/)&.public_send(:[], 1)
}
end

View File

@@ -41,4 +41,27 @@ RSpec.describe "DFC Product Import" do
expect(page).to have_content "Importing a DFC product catalog"
expect(page).to have_content "Imported products: 1"
end
it "imports from a FDC catalog", vcr: true do
user.oidc_account.update!(
uid: "testdfc@protonmail.com",
refresh_token: ENV.fetch("OPENID_REFRESH_TOKEN"),
updated_at: 1.day.ago,
)
visit admin_product_import_path
select enterprise.name, from: "Enterprise"
url = "https://food-data-collaboration-produc-fe870152f634.herokuapp.com/fdc/products?shop=test-hodmedod.myshopify.com"
fill_in "catalog_url", with: url
expect {
click_button "Import"
}.to change {
enterprise.supplied_products.count
}
expect(page).to have_content "Importing a DFC product catalog"
end
end