mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Enable/disable affiliate sales data
This commit is contained in:
@@ -29,25 +29,25 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
end
|
||||
|
||||
describe "Discover Regenerative" do
|
||||
let(:section_heading) { self.class.description }
|
||||
|
||||
it "can be enabled and disabled" do
|
||||
visit edit_admin_enterprise_path(enterprise)
|
||||
|
||||
scroll_to :bottom
|
||||
click_link "Connected apps"
|
||||
|
||||
within section_containing_heading "Discover Regenerative" do
|
||||
within section_containing_heading do
|
||||
click_button "Allow data sharing"
|
||||
end
|
||||
|
||||
# (page is reloaded so we need to evaluate within block again)
|
||||
within section_containing_heading "Discover Regenerative" do
|
||||
within section_containing_heading do
|
||||
expect(page).not_to have_button "Allow data sharing"
|
||||
expect(page).to have_button "Loading", disabled: true
|
||||
|
||||
perform_enqueued_jobs(only: ConnectAppJob)
|
||||
end
|
||||
|
||||
within section_containing_heading "Discover Regenerative" do
|
||||
expect(page).not_to have_button "Loading", disabled: true
|
||||
expect(page).to have_content "account is connected"
|
||||
expect(page).to have_link "Manage listing"
|
||||
@@ -55,7 +55,7 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
click_button "Stop sharing"
|
||||
end
|
||||
|
||||
within section_containing_heading "Discover Regenerative" do
|
||||
within section_containing_heading do
|
||||
expect(page).to have_button "Allow data sharing"
|
||||
expect(page).not_to have_button "Stop sharing"
|
||||
expect(page).not_to have_content "account is connected"
|
||||
@@ -68,15 +68,51 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
|
||||
visit "#{edit_admin_enterprise_path(enterprise)}#/connected_apps_panel"
|
||||
|
||||
within section_containing_heading "Discover Regenerative" do
|
||||
within section_containing_heading do
|
||||
expect(page).to have_button("Allow data sharing", disabled: true)
|
||||
expect(page).to have_content "Only managers can connect apps."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def section_containing_heading(heading)
|
||||
describe "Affiliate Sales Data" do
|
||||
let(:section_heading) { "INRAE / UFC QUE CHOISIR Research" }
|
||||
|
||||
it "can be enabled and disabled" do
|
||||
visit edit_admin_enterprise_path(enterprise)
|
||||
|
||||
scroll_to :bottom
|
||||
click_link "Connected apps"
|
||||
|
||||
within section_containing_heading do
|
||||
click_button "Allow data sharing"
|
||||
end
|
||||
|
||||
# (page is reloaded so we need to evaluate within block again)
|
||||
within section_containing_heading do
|
||||
expect(page).not_to have_button "Allow data sharing"
|
||||
click_button "Stop sharing"
|
||||
end
|
||||
|
||||
within section_containing_heading do
|
||||
expect(page).to have_button "Allow data sharing"
|
||||
expect(page).not_to have_button "Stop sharing"
|
||||
end
|
||||
end
|
||||
|
||||
it "can't be enabled by non-manager" do
|
||||
login_as create(:admin_user)
|
||||
|
||||
visit "#{edit_admin_enterprise_path(enterprise)}#/connected_apps_panel"
|
||||
|
||||
within section_containing_heading do
|
||||
expect(page).to have_button("Allow data sharing", disabled: true)
|
||||
expect(page).to have_content "Only managers can connect apps."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def section_containing_heading(heading = section_heading)
|
||||
page.find("h3", text: heading).ancestor("section")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user