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

Fix Kiwisizing bug & Add tests for all integrations #119

Merged
merged 2 commits into from
Mar 21, 2022
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
3 changes: 3 additions & 0 deletions src/lib/web-worker/worker-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const queue = (
$groupedGetters$?: string[],
buffer?: ArrayBuffer | ArrayBufferView
) => {
if (!instance[ApplyPathKey]) {
return;
}
taskQueue.push({
$winId$: instance[WinIdKey],
$instanceId$: instance[InstanceIdKey],
Expand Down
1 change: 1 addition & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ <h2>Service Integration Tests</h2>
<li><a href="/tests/integrations/hubspot/forms.html">Hubspot Forms</a></li>
<li><a href="/tests/integrations/intercom/">Intercom</a></li>
<li><a href="/tests/integrations/jquery/">jQuery</a></li>
<li><a href="/tests/integrations/kiwisizing/">Kiwi Sizing</a></li>
<li><a href="/tests/integrations/mermaid/">Mermaid</a></li>
<li><a href="/tests/integrations/twitter/">Twitter Embed</a></li>
<li><a href="/tests/integrations/wistia/">Wistia</a></li>
Expand Down
8 changes: 8 additions & 0 deletions tests/integrations/clarity/clarity.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

test('Clarity', async ({ page }) => {
await page.goto('/tests/integrations/clarity/');
const element = await page.waitForSelector('#pterrors');

expect(await element.textContent()).toEqual('NO ERROR');
});
14 changes: 14 additions & 0 deletions tests/integrations/clarity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@
})(window, document, "clarity", "script", "avd6npx8xb");
</script>

<script>
setTimeout(() => {
let errors = document.querySelector('[data-pterror]');
let elm = document.createElement('div');
elm.id = 'pterrors';
if (errors) {
elm.textContent = 'ERROR';
} else {
elm.textContent = 'NO ERROR';
}
document.body.appendChild(elm);
}, 2000);
</script>

</head>
<h1>Clarity</h1>

Expand Down
13 changes: 13 additions & 0 deletions tests/integrations/hubspot/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@
margin: 0 5px;
}
</style>
<script>
setTimeout(() => {
let errors = document.querySelector('[data-pterror]');
let elm = document.createElement('div');
elm.id = 'pterrors';
if (errors) {
elm.textContent = 'ERROR';
} else {
elm.textContent = 'NO ERROR';
}
document.body.appendChild(elm);
}, 3000);
</script>
</head>
<body>
<h1>Hubspot Forms 🎉</h1>
Expand Down
8 changes: 8 additions & 0 deletions tests/integrations/hubspot/hubspot.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

test('Hubspot', async ({ page }) => {
await page.goto('/tests/integrations/hubspot/forms.html');
const element = await page.waitForSelector('#pterrors');

expect(await element.textContent()).toEqual('NO ERROR');
});
14 changes: 14 additions & 0 deletions tests/integrations/jquery/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ <h1>jQuery</h1>
})();
</script>

<script>
setTimeout(() => {
let errors = document.querySelector('[data-pterror]');
let elm = document.createElement('div');
elm.id = 'pterrors';
if (errors) {
elm.textContent = 'ERROR';
} else {
elm.textContent = 'NO ERROR';
}
document.body.appendChild(elm);
}, 3000);
</script>

<hr />
<p><a href="/tests/">All Tests</a></p>
</body>
Expand Down
13 changes: 6 additions & 7 deletions tests/integrations/jquery/jquery.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { test, expect } from '@playwright/test';

test('jquery', async ({ page }) => {
// await page.goto('/tests/integrations/jquery/');
// await page.waitForSelector('.completed');
// const buttonDataLayerPush = page.locator('#buttonDataLayerPush');
// await buttonDataLayerPush.click();
// const testDataLayer = page.locator('#testDataLayer');
// await expect(testDataLayer).toHaveText('pushed');
test('JQuery', async ({ page }) => {
await page.goto('/tests/integrations/jquery/');
await page.waitForSelector('.completed');
const element = await page.waitForSelector('#pterrors');

expect(await element.textContent()).toEqual('NO ERROR');
});
142 changes: 142 additions & 0 deletions tests/integrations/kiwisizing/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Partytown Test Page" />

<title>Kiwisizing 🎉</title>

<script>
partytown = {
logCalls: true,
logGetters: true,
logSetters: true,
logImageRequests: true,
logMainAccess: true,
logSendBeaconRequests: true,
logStackTraces: false,
logScriptExecution: true,
forward: ['dataLayer.push', 'fbq', '_', 'customElements'],
resolveUrl: function (url) {
if (
[
'static-tracking.klaviyo.com',
'static.klaviyo.com',
'cdn.static.kiwisizing.com',
'd3hw6dc1ow8pp2.cloudfront.net',
'pixc.com',
].includes(url.hostname)
) {
var proxyUrl = new URL(
'https://cdn.builder.io/api/v1/proxy-api?apiKey=e514f5987eaf4fa1b17ff31a283fe2ad'
);
proxyUrl.searchParams.append('url', url.href);
return proxyUrl;
}
return url;
},
};
</script>
<script src="/~partytown/debug/partytown.js"></script>

<script>
window.KiwiSizing = window.KiwiSizing === undefined ? {} : window.KiwiSizing;
KiwiSizing.shop = 'shyam-partytown-tester.myshopify.com';
</script>

<style>
body {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
Apple Color Emoji, Segoe UI Emoji;
font-size: 12px;
}

h1 {
margin: 0 0 15px 0;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
}

a {
display: block;
padding: 16px 8px;
}

a:link,
a:visited {
text-decoration: none;
color: blue;
}

a:hover {
background-color: #eee;
}

li {
display: flex;
margin: 15px 0;
}

li strong,
li code,
li button {
white-space: nowrap;
flex: 1;
margin: 0 5px;
}
</style>

<script id="shopify-features" type="application/json">
{
"accessToken": "3a857541a8ed3b74db7c1f087d47886d",
"betas": ["rich-media-storefront-analytics"],
"domain": "shyam-partytown-tester.myshopify.com",
"predictiveSearch": true,
"shopId": 61726785721,
"smart_payment_buttons_url": "https:\/\/cdn.shopify.com\/shopifycloud\/payment-sheet\/assets\/latest\/spb.en.js",
"dynamic_checkout_cart_url": "https:\/\/cdn.shopify.com\/shopifycloud\/payment-sheet\/assets\/latest\/dynamic-checkout-cart.en.js",
"locale": "en"
}
</script>

<script
data-source-attribution="shopify.dynamic-checkout"
defer="defer"
src="./shopify-dynamic-checkout.js"
crossorigin="anonymous"
></script>

<script
src="./kiwisizing.SizingPlugin.js?v=308\u0026shop=shyam-partytown-tester.myshopify.com"
type="text/partytown"
></script>

<script>
setTimeout(() => {
let errors = document.querySelector('[data-pterror]');
let elm = document.createElement('div');
elm.id = 'pterrors';
if (errors) {
elm.textContent = 'ERROR';
} else {
elm.textContent = 'NO ERROR';
}
document.body.appendChild(elm);
}, 3000);
</script>
</head>
<body>
<h1>Kiwisizing</h1>

<div data-shopify="payment-button"></div>

<hr />
<p><a href="/tests/integrations/kiwisizing/standard.html">Standard Kiwisizing</a></p>
<p><a href="/tests/">All Tests</a></p>
</body>
</html>
Loading