@playpilot/tpi 8.10.0 → 8.10.2

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.
Files changed (37) hide show
  1. package/.env +1 -1
  2. package/dist/editorial.mount.js +9 -9
  3. package/dist/link-injections.js +1 -1
  4. package/dist/mount.js +6 -6
  5. package/package.json +1 -1
  6. package/src/lib/api/youtubeAvailability.ts +3 -4
  7. package/src/lib/enums/TrackingEvent.ts +4 -4
  8. package/src/lib/fakeData.ts +44 -32
  9. package/src/lib/injection.ts +10 -17
  10. package/src/lib/modal.ts +3 -1
  11. package/src/lib/popover.ts +13 -12
  12. package/src/lib/types/injection.d.ts +5 -0
  13. package/src/routes/components/Editorial/Editor.svelte +2 -3
  14. package/src/routes/components/Editorial/EditorItem.svelte +23 -9
  15. package/src/routes/components/Editorial/ManualInjection.svelte +1 -0
  16. package/src/routes/components/{TitlePopover.svelte → InjectionPopover.svelte} +26 -9
  17. package/src/routes/components/ListTitle.svelte +27 -6
  18. package/src/routes/components/Participant.svelte +18 -6
  19. package/src/routes/components/Playlinks/Playlinks.svelte +2 -1
  20. package/src/routes/components/Title.svelte +1 -1
  21. package/src/routes/components/TrackAnyClick.svelte +15 -2
  22. package/src/routes/components/YouTubeEmbed.svelte +1 -1
  23. package/src/routes/elements/+page.svelte +3 -3
  24. package/src/tests/helpers.js +1 -0
  25. package/src/tests/lib/api/youtubeAvailability.test.js +3 -3
  26. package/src/tests/lib/injection.test.js +44 -3
  27. package/src/tests/lib/popover.test.js +7 -7
  28. package/src/tests/routes/components/Editorial/EditorItem.test.js +10 -0
  29. package/src/tests/routes/components/Editorial/ManualInjection.test.js +4 -0
  30. package/src/tests/routes/components/Editorial/PlaylinkTypeSelect.test.js +2 -0
  31. package/src/tests/routes/components/InjectionPopover.test.js +117 -0
  32. package/src/tests/routes/components/ListTitle.test.js +7 -0
  33. package/src/tests/routes/components/Participant.test.js +7 -0
  34. package/src/tests/routes/components/Playlinks/AfterArticlePlaylinks.test.js +4 -0
  35. package/src/tests/routes/components/Playlinks/Playlinks.test.js +1 -1
  36. package/src/tests/routes/components/TrackAnyClick.test.js +137 -1
  37. package/src/tests/routes/components/TitlePopover.test.js +0 -78
@@ -1,78 +0,0 @@
1
- import { render } from '@testing-library/svelte'
2
- import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
3
-
4
- import TitlePopover from '../../../routes/components/TitlePopover.svelte'
5
- import { title } from '$lib/fakeData'
6
- import { track } from '$lib/tracking'
7
- import { TrackingEvent } from '$lib/enums/TrackingEvent'
8
- import { hasConsentedTo } from '$lib/consent'
9
-
10
- vi.mock('$lib/consent', () => ({
11
- hasConsentedTo: vi.fn(() => true),
12
- }))
13
-
14
- vi.mock('$lib/tracking', () => ({
15
- track: vi.fn(),
16
- }))
17
-
18
- vi.mock('$lib/pixel', () => ({
19
- isPixelAllowed: vi.fn(),
20
- }))
21
-
22
- vi.mock('$lib/api/participants', () => ({
23
- fetchParticipantsForTitle: vi.fn(),
24
- }))
25
-
26
- vi.mock('$lib/api/titles', () => ({
27
- fetchSimilarTitles: vi.fn(),
28
- }))
29
-
30
- describe('TitlePopover.svelte', () => {
31
- beforeEach(() => {
32
- vi.resetAllMocks()
33
- vi.mocked(hasConsentedTo).mockImplementation(() => true)
34
- })
35
-
36
- afterEach(() => {
37
- vi.useRealTimers()
38
- })
39
-
40
- it('Should call track function when rendered', () => {
41
- const event = new MouseEvent('mouseenter')
42
- render(TitlePopover, { event, title })
43
-
44
- expect(track).toHaveBeenCalledWith(TrackingEvent.TitlePopoverView, title)
45
- })
46
-
47
- it('Should call track function with time_spent when destroyed', async () => {
48
- vi.useFakeTimers()
49
-
50
- const event = new MouseEvent('mouseenter')
51
- const { unmount } = render(TitlePopover, { event, title })
52
-
53
- vi.advanceTimersByTime(200)
54
- unmount()
55
-
56
- expect(track).toHaveBeenCalledWith(TrackingEvent.TitlePopoverClose, title, expect.objectContaining({ time_spent: 200 }))
57
- })
58
-
59
- it('Should render top scroll ad when given', () => {
60
- // @ts-ignore
61
- window.PlayPilotLinkInjections = { ads: [{ campaign_format: 'top_scroll', content: {}, cta: {} }] }
62
-
63
- const event = new MouseEvent('mouseenter')
64
- const { container } = render(TitlePopover, { event, title })
65
-
66
- expect(container.querySelector('.top-scroll')).toBeTruthy()
67
- })
68
-
69
- it('Should not render top scroll ad when not given', () => {
70
- // @ts-ignore
71
- window.PlayPilotLinkInjections = { ads: null }
72
-
73
- const event = new MouseEvent('mouseenter')
74
- const { container } = render(TitlePopover, { event, title })
75
-
76
- expect(container.querySelector('.top-scroll')).not.toBeTruthy()
77
- })
78
- })