<commit_before>require 'spec_helper'

feature "Using embedded shopfront functionality", js: true do
  include OpenFoodNetwork::EmbeddedPagesHelper

  describe 'embedded groups' do
    let(:enterprise) { create(:distributor_enterprise) }
    let(:group) { create(:enterprise_group, enterprises: [enterprise]) }

    before do
      Spree::Config[:enable_embedded_shopfronts] = true
      Spree::Config[:embedded_shopfronts_whitelist] = 'test.com'
      page.driver.browser.js_errors = false
      allow_any_instance_of(ActionDispatch::Request).to receive(:referer).and_return('https://www.test.com')
      visit "/embedded-group-preview.html?#{group.permalink}"
    end

    it "displays in an iframe" do
      on_embedded_page do
        within 'div#group-page' do
          expect(page).to have_content 'About Us'
        end
      end
    end

    it "displays powered by OFN text at bottom of page" do
      on_embedded_page do<commit_msg>Remove js_errors = false from specs because it is not available in Selenium ChromeDriver<commit_after>require 'spec_helper'

feature "Using embedded shopfront functionality", js: true do
  include OpenFoodNetwork::EmbeddedPagesHelper

  describe 'embedded groups' do
    let(:enterprise) { create(:distributor_enterprise) }
    let(:group) { create(:enterprise_group, enterprises: [enterprise]) }

    before do
      Spree::Config[:enable_embedded_shopfronts] = true
      Spree::Config[:embedded_shopfronts_whitelist] = 'test.com'
      allow_any_instance_of(ActionDispatch::Request).to receive(:referer).and_return('https://www.test.com')
      visit "/embedded-group-preview.html?#{group.permalink}"
    end

    it "displays in an iframe" do
      on_embedded_page do
        within 'div#group-page' do
          expect(page).to have_content 'About Us'
        end
      end
    end

    it "displays powered by OFN text at bottom of page" do
      on_embedded_page do
{'fraction_non_alphanumeric': 0.09660574412532637, 'fraction_numerical': 0.0, 'mean_word_length': 3.7661691542288556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2888000', 'n_tokens_mistral': 593, 'n_tokens_neox': 560, 'n_words': 141}