Skip to content

Commit

Permalink
add gtm test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Sep 30, 2021
1 parent 6a21299 commit d02e45a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tests/integrations/gtm/gtm.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test, expect } from '@playwright/test';

test('gtm', async ({ page }) => {
await page.goto('/integrations/gtm/');

await page.waitForSelector('.completed');

const buttonDataLayerPush = page.locator('#buttonDataLayerPush');
await buttonDataLayerPush.click();

const testDataLayer = page.locator('#testDataLayer');
await expect(testDataLayer).toHaveText('pushed');
});
12 changes: 11 additions & 1 deletion tests/integrations/gtm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
// gtmScript.src = './gtm.js?id=' + i + dataLayer;

firstScript.parentNode.insertBefore(gtmScript, firstScript);

document.body.classList.add('completed');

})(window, document, 'GTM-W275NLW');
</script>
<!-- End Google Tag Manager -->
Expand Down Expand Up @@ -93,14 +96,21 @@
<body>
<h1>Google Tag Manager (GTM) 🎉</h1>

<button onclick="gtmPush()">Partytown dataLayer.push()</button>
<p>
<strong>dataLayer.push</strong>
<span id="testDataLayer"></span>
</p>
<script>
function gtmPush() {
const data = { event: 'button-click', from: 'partytown' };
console.log(`GTM dataLayer.push(${JSON.stringify(data)})`);
dataLayer.push({ event: 'button-click', from: 'partytown' });

const testDataLayer = document.getElementById('testDataLayer');
testDataLayer.textContent = 'pushed';
}
</script>
<button id="buttonDataLayerPush" onclick="gtmPush()">Partytown dataLayer.push()</button>

<p><a href="/integrations/gtm/standard.html">Standard GTM</a></p>
<p><a href="/integrations/">All Integration Tests</a></p>
Expand Down
1 change: 1 addition & 0 deletions tests/platform/anchor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<body >
<h1>Anchor</h1>

<ul>
<li>
<strong>set/get a.href</strong>
<div><a id="testAnchor"></a></div>
Expand Down

1 comment on commit d02e45a

@vercel
Copy link

@vercel vercel bot commented on d02e45a Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.