Skip to content

Commit

Permalink
Remove UA from cookie functions code
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Jul 30, 2024
1 parent 57d0f01 commit 95a57c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
global_bar_seen: 'settings',
govuk_browser_upgrade_dismisssed: 'settings',
govuk_not_first_visit: 'settings',
analytics_next_page_call: 'usage',
user_nation: 'settings',
_ga: 'usage',
_gid: 'usage',
_gat: 'usage',
'JS-Detection': 'usage',
TLSversion: 'usage',
_ga_VBLT2V3FZR: 'usage', // gtag cookie used to persist the session state, integration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ describe('Cookie helper functions', function () {
var date = new Date()
date.setTime(date.valueOf() + (365 * 24 * 60 * 60 * 1000))

GOVUK.setCookie('analytics_next_page_call', 'test', { expires: date.toUTCString(), domain: window.location.hostname, path: '/' })
GOVUK.setCookie('JS-Detection', 'test', { expires: date.toUTCString(), domain: window.location.hostname, path: '/' })

expect(GOVUK.getCookie('analytics_next_page_call')).toBe('test')
expect(GOVUK.getCookie('JS-Detection')).toBe('test')

GOVUK.setDefaultConsentCookie()

expect(GOVUK.getConsentCookie().usage).toBe(false)
expect(GOVUK.getCookie('analytics_next_page_call')).toBeFalsy()
expect(GOVUK.getCookie('JS-Detection')).toBeFalsy()
})

it('deletes cookies regardless of subdomains', function () {
Expand Down Expand Up @@ -154,16 +154,16 @@ describe('Cookie helper functions', function () {
it('deletes relevant cookies in that category if consent is set to false', function () {
GOVUK.setConsentCookie({ usage: true })

GOVUK.setCookie('analytics_next_page_call', 'this is a usage cookie')
GOVUK.setCookie('JS-Detection', 'this is a usage cookie')

expect(GOVUK.cookie('analytics_next_page_call')).toBe('this is a usage cookie')
expect(GOVUK.cookie('JS-Detection')).toBe('this is a usage cookie')

spyOn(GOVUK, 'setCookie').and.callThrough()
GOVUK.setConsentCookie({ usage: false })

expect(GOVUK.setCookie).toHaveBeenCalledWith('cookies_policy', '{"essential":true,"settings":false,"usage":false,"campaigns":false}', Object({ days: 365 }))
expect(GOVUK.getConsentCookie().usage).toBe(false)
expect(GOVUK.cookie('analytics_next_page_call')).toBeFalsy()
expect(GOVUK.cookie('JS-Detection')).toBeFalsy()
})
})

Expand Down Expand Up @@ -200,11 +200,11 @@ describe('Cookie helper functions', function () {
it('returns the consent for a given cookie', function () {
GOVUK.setConsentCookie({ usage: false })

expect(GOVUK.checkConsentCookie('analytics_next_page_call', 'set a usage cookie')).toBeFalsy()
expect(GOVUK.checkConsentCookie('JS-Detection', 'set a usage cookie')).toBeFalsy()

GOVUK.setConsentCookie({ usage: true })

expect(GOVUK.checkConsentCookie('analytics_next_page_call', 'set a usage cookie')).toBeTruthy()
expect(GOVUK.checkConsentCookie('JS-Detection', 'set a usage cookie')).toBeTruthy()
})

it('denies consent for cookies not in our list of cookies', function () {
Expand Down

0 comments on commit 95a57c1

Please sign in to comment.