<commit_before>require 'spec_helper'

feature "Cookies", js: true do
  describe "banner" do
    describe "in the homepage" do
      before do
        Spree::Config[:cookies_consent_banner_toggle] = true
        visit root_path       
      end

      scenario "does not show after cookies are accepted" do
        sleep 1
        click_button I18n.t('legal.cookies_banner.cookies_accept_button')
        sleep 2
        expect_not_visible_cookies_banner

        visit root_path
        expect_not_visible_cookies_banner
      end

      scenario "banner contains cookies policy link that opens coookies policy page and closes banner" do
        find("p.ng-binding > a", :text => "cookies policy").click
        sleep 1
        expect_visible_cookies_policy_page
        expect_not_visible_cookies_banner

        find("a.close-reveal-modal").click
        expect_visible_cookies_banner
      end
    end

    describe "in product listing page" do
      before do
        Spree::Config[:cookies_consent_banner_toggle] = true
      end

      scenario "it is showing" do
        visit "/shops"      
        expect_visible_cookies_banner
      end
    end

    describe "disabled in the settings" do
      scenario "it is not showing" do
        Spree::Config[:cookies_consent_banner_toggle] = false
        visit root_path<commit_msg>Sleep to avoid race conditions in cookie spec<commit_after>require 'spec_helper'

feature "Cookies", js: true do
  describe "banner" do
    describe "in the homepage" do
      before do
        Spree::Config[:cookies_consent_banner_toggle] = true
        visit root_path       
      end

      scenario "does not show after cookies are accepted" do
        sleep 1
        click_button I18n.t('legal.cookies_banner.cookies_accept_button')
        sleep 2
        expect_not_visible_cookies_banner

        visit root_path
        sleep 1
        expect_not_visible_cookies_banner
      end

      scenario "banner contains cookies policy link that opens coookies policy page and closes banner" do
        sleep 1
        find("p.ng-binding > a", :text => "cookies policy").click
        sleep 2
        expect_visible_cookies_policy_page
        expect_not_visible_cookies_banner

        find("a.close-reveal-modal").click
        expect_visible_cookies_banner
      end
    end

    describe "in product listing page" do
      before do
        Spree::Config[:cookies_consent_banner_toggle] = true
      end

      scenario "it is showing" do
        visit "/shops"      
        expect_visible_cookies_banner
      end
    end

    describe "disabled in the settings" do
      scenario "it is not showing" do
        Spree::Config[:cookies_consent_banner_toggle] = false
        visit root_path
{'fraction_non_alphanumeric': 0.05490483162518302, 'fraction_numerical': 0.004392386530014641, 'mean_word_length': 2.4420654911838793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5900703', 'n_tokens_mistral': 805, 'n_tokens_neox': 779, 'n_words': 224}