Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests injecting Google Tag Manager script #3969

Closed
3 tasks
romaricpascal opened this issue Aug 1, 2024 · 0 comments · Fixed by #3972
Closed
3 tasks

Improve tests injecting Google Tag Manager script #3969

romaricpascal opened this issue Aug 1, 2024 · 0 comments · Fixed by #3972

Comments

@romaricpascal
Copy link
Member

romaricpascal commented Aug 1, 2024

What

Prevent our tests from failing if an error occurs inside Google Tag Manager (GTM) script. This might be doable by mocking requests loading the GTM script using Puppeteer's Request Interception mechanism, though there may be other routes just as effective.

While looking in that space, it would also be nice to devise a solution that would allow us to check that the acceptance of cookies triggers the injection of the GTM script (mocking may help for that as well).

Why

The cookie banner tests trigger the injection of the GTM script on the page. If that script throws an error, it results in the test failing. This prevents our tests from running their actual assertion and is problematic as we don't control the code in GTM script.

It would be more resilient from us to isolate ourselves from the actual script from GTM during our tests. If we could, though, it would be nice to add tests checking that we do inject the GTM script when cookies are accepted as I don't believe we have anything at the moment.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

  • Errors in GTM script do not cause our tests to fail

And either:

  • Tests have been added to check that the GTM script is injected on the page
  • An issue has been written to add tests checking the injection of the GTM script on the page
@romaricpascal romaricpascal moved this to Backlog 🏃🏼‍♀️ in GOV.UK Design System cycle board Aug 1, 2024
romaricpascal added a commit that referenced this issue Aug 2, 2024
This makes tests fail when an error happens in a 3rd party code (Google Tag Manager).
This change is only temporary and will be reversed when we implement a longer term solution
to isolate our tests from Google Tag Manager errors.

#3969
@romaricpascal romaricpascal self-assigned this Aug 2, 2024
@romaricpascal romaricpascal moved this from Backlog 🏃🏼‍♀️ to Needs review 🔍 in GOV.UK Design System cycle board Aug 2, 2024
@romaricpascal romaricpascal moved this from Needs review 🔍 to Done 🏁 in GOV.UK Design System cycle board Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done 🏁
Development

Successfully merging a pull request may close this issue.

1 participant