Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dashboard/test/ui/features/xteam/onetrust_cookie_banner.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@eyes
Feature: OneTrust Cookie banner on various sites

Scenario Outline: Show onetrust cookie banner on GDPR country but not the US
When I open my eyes to test "<test_name>"
And I am on "<url>?otgeo=gb&onetrust_cookie_scripts=production"
And I wait to see "#onetrust-banner-sdk"
Then I see no difference for "OneTrust cookie banner on UK"

Then I am on "<url>?otgeo=us&onetrust_cookie_scripts=production"
And I wait until element "#onetrust-banner-sdk" is not visible
Then I see no difference for "OneTrust cookie banner on US"

Then I close my eyes

Examples:
| url | test_name |
| http://code.org/about | code.org about |
| http://hourofcode.com/uk | hourofcode hompage |
| http://studio.code.org/s/frozen/lessons/1/levels/1 | studio.code.org puzzle |
7 changes: 7 additions & 0 deletions shared/haml/cookie_banner.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-#
This is the old banner we should show GDPR countries in order to inform them
about our privacy policy. This file should be removed once we finish the
'onetrust_cookie_scripts' experiment.

-# Don't show this banner if we are showing the new OneTrust GDPR cookie banner.
- return if experiment_value('onetrust_cookie_scripts')
-#
Only show cookie banner when in a GDPR country, or when we are in the test
environment and the show_cookie_banner_on_test URL parameter is specified,
Expand Down
3 changes: 2 additions & 1 deletion shared/haml/hoc_onetrust_cookie_scripts.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- require '../shared/middleware/helpers/experiments'
-# OneTrust Cookies Consent Notice scripts for hourofcode.com
- cookie_script_env = DCDO.get('onetrust_cookie_scripts', 'off')
- cookie_script_env = experiment_value('onetrust_cookie_scripts')
- if cookie_script_env == 'production'
%script{:src=>"#{CDO.code_org_url}/js/jquery.min.js"}
%script{src: 'https://cdn.cookielaw.org/consent/7c79c547-a2fc-4998-9b21-0c7a5e67e345/OtAutoBlock.js', type: 'text/javascript'}
Expand Down
6 changes: 2 additions & 4 deletions shared/haml/onetrust_cookie_scripts.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
- require '../shared/middleware/helpers/experiments'
-# OneTrust Cookies Consent Notice scripts for code.org
- cookie_script_env = DCDO.get('onetrust_cookie_scripts', 'off')
-# If the user has a cookie to override this, use it. This is for testing purposes.
- cookie_script_env_override = request.cookies['onetrust_cookie_scripts']
- cookie_script_env = cookie_script_env_override if cookie_script_env_override.present?
- cookie_script_env = experiment_value('onetrust_cookie_scripts')
- if cookie_script_env == 'production'
%script{src: 'https://cdn.cookielaw.org/consent/27cca70a-7db3-4852-9ef0-a6660fd0977d/OtAutoBlock.js', type: 'text/javascript'}
%script{src: 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js', type: 'text/javascript', charset: 'UTF-8', 'data-domain-script' => '27cca70a-7db3-4852-9ef0-a6660fd0977d'}
Expand Down
15 changes: 15 additions & 0 deletions shared/middleware/helpers/experiments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Sometimes we want to hide features behind dynamic configurations
# because they are not ready yet. To test these features, you might
# want to use a URL parameter or browser cookie to temporarily
# enable it for a single user. If you want to configure it for all
# users, you can use DCDO.
# If multiple configurations are available, this is the priority
# (from highest to lowest):
# 1. URL Parameter - https://code.org?my_experiment=1
# 2. Browser Cookie - document.cookie = 'my_experiment=1';
# 3. DCDO config - DCDO.set('my_experiment', 1)
def experiment_value(name, default = nil)
return request.params[name] if request.params[name].present?
return request.cookies[name] if request.cookies[name].present?
DCDO.get(name, default)
end