Files
nairobi/spec/system/cookies_consent_spec.rb
taitus dc54fda71b Allow accepting all cookies in consent banner and management component
Create cookie consent "all" when accept all cookies

Set cookie duration to 365 days based on the AEPD's cookie usage guidelines.

Note from the document: "Cookies with a duration of up to 24 months are
considered acceptable as long as they are periodically updated."
Reference: https://www.aepd.es/guias/guia-cookies.pdf
2025-01-23 17:03:30 +01:00

88 lines
2.3 KiB
Ruby

require "rails_helper"
describe "Cookies consent" do
before { Setting["feature.cookies_consent"] = true }
context "Banner consent" do
scenario "Hides the banner when accepting essential cookies and for consecutive visits" do
visit root_path
expect(cookie_by_name("cookies_consent")).to be nil
within ".cookies-consent-banner" do
click_button "Accept essential cookies"
end
expect(cookie_by_name("cookies_consent")[:value]).to eq "essential"
expect(page).not_to have_content "Cookies policy"
refresh
expect(page).not_to have_content "Cookies policy"
end
scenario "Hides the banner when accepting all cookies and for consecutive visits" do
visit root_path
expect(cookie_by_name("cookies_consent")).to be nil
within ".cookies-consent-banner" do
click_button "Accept all"
end
expect(cookie_by_name("cookies_consent")[:value]).to eq "all"
expect(page).not_to have_content "Cookies policy"
refresh
expect(page).not_to have_content "Cookies policy"
end
end
context "Management modal" do
scenario "Allow users to accept essential cookies and hide management modal" do
visit root_path
expect(cookie_by_name("cookies_consent")).to be nil
within ".cookies-consent-banner" do
click_button "Manage cookies"
end
within ".cookies-consent-management" do
click_button "Accept essential cookies"
end
expect(cookie_by_name("cookies_consent")[:value]).to eq "essential"
expect(page).not_to have_content "Cookies policy"
expect(page).not_to have_content "Cookies management"
refresh
expect(page).not_to have_content "Cookies policy"
end
scenario "Allow users to accept all cookies from the cookies management modal" do
visit root_path
expect(cookie_by_name("cookies_consent")).to be nil
within ".cookies-consent-banner" do
click_button "Manage cookies"
end
within ".cookies-consent-management" do
click_button "Accept all"
end
expect(cookie_by_name("cookies_consent")[:value]).to eq "all"
expect(page).not_to have_content "Cookies policy"
expect(page).not_to have_content "Cookies management"
refresh
expect(page).not_to have_content "Cookies policy"
end
end
end