@playpilot/tpi 6.4.2 → 6.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/routes/+page.svelte
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { mobileBreakpoint } from '$lib/constants'
|
|
3
|
-
import { SplitTest } from '$lib/enums/SplitTest'
|
|
4
|
-
import { isInSplitTestVariant, trackSplitTestAction, trackSplitTestView } from '$lib/splitTest'
|
|
5
3
|
import { onMount } from 'svelte'
|
|
6
4
|
|
|
7
5
|
const linksWithPosters = Array.from(document.querySelectorAll<HTMLElement>('[data-playpilot-poster-url]'))
|
|
@@ -18,27 +16,11 @@
|
|
|
18
16
|
onMount(() => {
|
|
19
17
|
if (!isMobile) return
|
|
20
18
|
|
|
21
|
-
trackSplitTestView(SplitTest.PostersScrollReveal)
|
|
22
|
-
|
|
23
19
|
return destroyAllPosters
|
|
24
20
|
})
|
|
25
21
|
|
|
26
|
-
$effect(() => {
|
|
27
|
-
if (!isMobile) return
|
|
28
|
-
if (!linksWithPosters.length) return
|
|
29
|
-
|
|
30
|
-
const onclick = () => trackSplitTestAction(SplitTest.PostersScrollReveal, 'click')
|
|
31
|
-
|
|
32
|
-
for(const link of linksWithPosters) link.addEventListener('click', onclick)
|
|
33
|
-
|
|
34
|
-
return () => {
|
|
35
|
-
for(const link of linksWithPosters) link.removeEventListener('click', onclick)
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
22
|
function onscroll(): void {
|
|
40
23
|
if (!isMobile) return
|
|
41
|
-
if (!isInSplitTestVariant(SplitTest.PostersScrollReveal)) return
|
|
42
24
|
|
|
43
25
|
setScrollTimeout()
|
|
44
26
|
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from '@testing-library/svelte'
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import PostersScrollReveal from '../../../routes/components/PostersScrollReveal.svelte'
|
|
4
4
|
import { mobileBreakpoint } from '$lib/constants'
|
|
5
|
-
import { isInSplitTestVariant, trackSplitTestAction } from '$lib/splitTest'
|
|
6
|
-
|
|
7
|
-
vi.mock('$lib/splitTest', () => ({
|
|
8
|
-
trackSplitTestView: vi.fn(),
|
|
9
|
-
trackSplitTestAction: vi.fn(),
|
|
10
|
-
isInSplitTestVariant: vi.fn(() => true),
|
|
11
|
-
}))
|
|
12
5
|
|
|
13
6
|
function createPosterLink(top = 0, url = 'poster.jpg') {
|
|
14
7
|
const link = document.createElement('a')
|
|
@@ -37,8 +30,6 @@ describe('FloatingPoster', () => {
|
|
|
37
30
|
|
|
38
31
|
vi.useFakeTimers()
|
|
39
32
|
vi.resetAllMocks()
|
|
40
|
-
|
|
41
|
-
vi.mocked(isInSplitTestVariant).mockReturnValue(true)
|
|
42
33
|
})
|
|
43
34
|
|
|
44
35
|
it('Should create poster when link is in viewport', async () => {
|
|
@@ -147,16 +138,4 @@ describe('FloatingPoster', () => {
|
|
|
147
138
|
window.dispatchEvent(new Event('scroll'))
|
|
148
139
|
expect(document.querySelector('[data-playpilot-poster]')).toBeTruthy()
|
|
149
140
|
})
|
|
150
|
-
|
|
151
|
-
it('Should fire split test tracking on click', async () => {
|
|
152
|
-
createPosterLink(500)
|
|
153
|
-
|
|
154
|
-
render(PostersScrollReveal)
|
|
155
|
-
|
|
156
|
-
window.dispatchEvent(new Event('scroll'))
|
|
157
|
-
|
|
158
|
-
await fireEvent.click(/** @type {HTMLElement} */ (document.querySelector('[data-playpilot-poster]')))
|
|
159
|
-
|
|
160
|
-
expect(trackSplitTestAction).toHaveBeenCalled()
|
|
161
|
-
})
|
|
162
141
|
})
|