Skip to content

Commit a1975cc

Browse files
Merge pull request #632 from citizensadvice/CP-873-Add-feature-tests-in-energy-apps-for-the-cookies
Cp 873 add feature tests in energy apps for the cookies
2 parents a772155 + 5f4b9cd commit a1975cc

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/lint_and_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
CONTENTFUL_CDA_TOKEN: ${{ secrets.CONTENTFUL_CDA_TOKEN }}
8888
CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID }}
8989
CONTENTFUL_ENVIRONMENT_ID: ${{ secrets.CONTENTFUL_ENVIRONMENT_ID }}
90+
FF_NEW_COOKIE_MANAGEMENT: true
9091
needs: lint
9192
steps:
9293
- name: "Checkout"

config/environments/test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# and recreated between test runs. Don't rely on the data there!
99

1010
Rails.application.configure do
11+
config.hosts << "127.0.0.1"
12+
1113
# Configure 'rails notes' to inspect Cucumber files
1214
config.annotations.register_directories("features")
1315
config.annotations.register_extensions("feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@javascript
2+
Feature: Cookie preferences
3+
4+
Scenario: Visiting a page for the first time
5+
Given I am on the Energy Comparison Table page
6+
Then the cookie banner is rendered
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
Then("the cookie banner is rendered") do
4+
expect(page).to have_text("We'd also like to use additional cookies")
5+
expect(page).to have_no_text("It looks like you have JavaScript turned off.")
6+
expect(page).to have_link("find out more about the cookies we use", href: "/about-us/information/how-we-use-cookies/")
7+
expect(page).to have_link("Manage cookies", href: "/cookie-preferences")
8+
end

features/support/env.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# files.
88

99
require "cucumber/rails"
10+
require "capybara/cucumber"
1011

1112
# frozen_string_literal: true
1213

@@ -59,3 +60,7 @@
5960
# The :transaction strategy is faster, but might give you threading problems.
6061
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
6162
# Cucumber::Rails::Database.javascript_strategy = :truncation
63+
64+
Capybara.configure do |config|
65+
config.javascript_driver = :selenium_chrome_headless
66+
end

0 commit comments

Comments
 (0)