@playpilot/tpi 5.23.4 → 5.24.0
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/dist/link-injections.js +11 -11
- package/events.md +1 -0
- package/package.json +1 -1
- package/src/lib/api/participants.ts +16 -0
- package/src/lib/api/titles.ts +9 -0
- package/src/lib/data/translations.ts +5 -0
- package/src/lib/enums/TrackingEvent.ts +1 -0
- package/src/lib/modal.ts +20 -7
- package/src/routes/components/ListTitle.svelte +5 -5
- package/src/routes/components/Modal.svelte +1 -1
- package/src/routes/components/Participant.svelte +61 -4
- package/src/routes/components/Rails/ParticipantsRail.svelte +19 -9
- package/src/routes/components/Rails/SimilarRail.svelte +2 -9
- package/src/routes/components/Rails/TitlesRail.svelte +5 -1
- package/src/routes/components/Title.svelte +7 -7
- package/src/routes/components/TitlePoster.svelte +4 -1
- package/src/tests/lib/modal.test.js +7 -0
- package/src/tests/routes/components/Participant.test.js +76 -0
- package/src/tests/routes/components/ParticipantModal.test.js +4 -0
- package/src/tests/routes/components/Rails/ParticipantsRail.test.js +39 -9
- package/src/tests/routes/components/Rails/SimilarRail.test.js +26 -0
- package/src/tests/routes/components/Rails/TitlesRail.test.js +1 -1
- package/src/tests/routes/components/Title.test.js +17 -0
- package/src/tests/routes/components/TitleModal.test.js +15 -9
- package/src/tests/routes/components/TitlePopover.test.js +8 -0
|
@@ -3,11 +3,21 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
|
3
3
|
|
|
4
4
|
import Title from '../../../routes/components/Title.svelte'
|
|
5
5
|
import { title } from '$lib/fakeData'
|
|
6
|
+
import { fetchParticipantsForTitle } from '$lib/api/participants'
|
|
7
|
+
import { fetchSimilarTitles } from '$lib/api/titles'
|
|
6
8
|
|
|
7
9
|
vi.mock('$lib/tracking', () => ({
|
|
8
10
|
track: vi.fn(),
|
|
9
11
|
}))
|
|
10
12
|
|
|
13
|
+
vi.mock('$lib/api/participants', () => ({
|
|
14
|
+
fetchParticipantsForTitle: vi.fn(),
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
vi.mock('$lib/api/titles', () => ({
|
|
18
|
+
fetchSimilarTitles: vi.fn(),
|
|
19
|
+
}))
|
|
20
|
+
|
|
11
21
|
vi.mock('svelte', async (importActual) => ({
|
|
12
22
|
...(await importActual()),
|
|
13
23
|
getContext: vi.fn(),
|
|
@@ -74,4 +84,11 @@ describe('Title.svelte', () => {
|
|
|
74
84
|
|
|
75
85
|
expect(container.querySelector('.paragraph')).not.toBeTruthy()
|
|
76
86
|
})
|
|
87
|
+
|
|
88
|
+
it('Should call fetches for participants and similar titles', () => {
|
|
89
|
+
render(Title, { title })
|
|
90
|
+
|
|
91
|
+
expect(fetchParticipantsForTitle).toHaveBeenCalled()
|
|
92
|
+
expect(fetchSimilarTitles).toHaveBeenCalled()
|
|
93
|
+
})
|
|
77
94
|
})
|
|
@@ -15,6 +15,14 @@ vi.mock('$lib/tracking', () => ({
|
|
|
15
15
|
track: vi.fn(),
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
|
+
vi.mock('$lib/api/participants', () => ({
|
|
19
|
+
fetchParticipantsForTitle: vi.fn(),
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
vi.mock('$lib/api/titles', () => ({
|
|
23
|
+
fetchSimilarTitles: vi.fn(),
|
|
24
|
+
}))
|
|
25
|
+
|
|
18
26
|
describe('TitleModal.svelte', () => {
|
|
19
27
|
beforeEach(() => {
|
|
20
28
|
vi.resetAllMocks()
|
|
@@ -25,16 +33,14 @@ describe('TitleModal.svelte', () => {
|
|
|
25
33
|
vi.useRealTimers()
|
|
26
34
|
})
|
|
27
35
|
|
|
28
|
-
const onclose = vi.fn()
|
|
29
|
-
|
|
30
36
|
it('Should call track function when rendered', () => {
|
|
31
|
-
render(TitleModal, {
|
|
37
|
+
render(TitleModal, { title })
|
|
32
38
|
|
|
33
39
|
expect(track).toHaveBeenCalledWith(TrackingEvent.TitleModalView, title)
|
|
34
40
|
})
|
|
35
41
|
|
|
36
42
|
it('Should call track function when scrolled', async () => {
|
|
37
|
-
const { getByRole } = render(TitleModal, {
|
|
43
|
+
const { getByRole } = render(TitleModal, { title })
|
|
38
44
|
|
|
39
45
|
await fireEvent.scroll(getByRole('dialog'))
|
|
40
46
|
|
|
@@ -44,7 +50,7 @@ describe('TitleModal.svelte', () => {
|
|
|
44
50
|
it('Should call track function with time_spent when destroyed', async () => {
|
|
45
51
|
vi.useFakeTimers()
|
|
46
52
|
|
|
47
|
-
const { unmount } = render(TitleModal, {
|
|
53
|
+
const { unmount } = render(TitleModal, { title })
|
|
48
54
|
|
|
49
55
|
vi.advanceTimersByTime(200)
|
|
50
56
|
unmount()
|
|
@@ -56,7 +62,7 @@ describe('TitleModal.svelte', () => {
|
|
|
56
62
|
// @ts-ignore
|
|
57
63
|
window.PlayPilotLinkInjections = { ads: [{ campaign_format: 'top_scroll', content: {}, cta: {} }] }
|
|
58
64
|
|
|
59
|
-
const { container } = render(TitleModal, {
|
|
65
|
+
const { container } = render(TitleModal, { title })
|
|
60
66
|
|
|
61
67
|
expect(container.querySelector('.top-scroll')).toBeTruthy()
|
|
62
68
|
})
|
|
@@ -65,7 +71,7 @@ describe('TitleModal.svelte', () => {
|
|
|
65
71
|
// @ts-ignore
|
|
66
72
|
window.PlayPilotLinkInjections = { ads: null }
|
|
67
73
|
|
|
68
|
-
const { container } = render(TitleModal, {
|
|
74
|
+
const { container } = render(TitleModal, { title })
|
|
69
75
|
|
|
70
76
|
expect(container.querySelector('.top-scroll')).not.toBeTruthy()
|
|
71
77
|
})
|
|
@@ -74,7 +80,7 @@ describe('TitleModal.svelte', () => {
|
|
|
74
80
|
// @ts-ignore
|
|
75
81
|
window.PlayPilotLinkInjections = { ads: [{ campaign_format: 'card', content: {}, cta: {} }] }
|
|
76
82
|
|
|
77
|
-
const { container } = render(TitleModal, {
|
|
83
|
+
const { container } = render(TitleModal, { title })
|
|
78
84
|
|
|
79
85
|
expect(container.querySelector('.display')).toBeTruthy()
|
|
80
86
|
})
|
|
@@ -83,7 +89,7 @@ describe('TitleModal.svelte', () => {
|
|
|
83
89
|
// @ts-ignore
|
|
84
90
|
window.PlayPilotLinkInjections = { ads: null }
|
|
85
91
|
|
|
86
|
-
const { container } = render(TitleModal, {
|
|
92
|
+
const { container } = render(TitleModal, { title })
|
|
87
93
|
|
|
88
94
|
expect(container.querySelector('.display')).not.toBeTruthy()
|
|
89
95
|
})
|
|
@@ -15,6 +15,14 @@ vi.mock('$lib/tracking', () => ({
|
|
|
15
15
|
track: vi.fn(),
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
|
+
vi.mock('$lib/api/participants', () => ({
|
|
19
|
+
fetchParticipantsForTitle: vi.fn(),
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
vi.mock('$lib/api/titles', () => ({
|
|
23
|
+
fetchSimilarTitles: vi.fn(),
|
|
24
|
+
}))
|
|
25
|
+
|
|
18
26
|
describe('TitlePopover.svelte', () => {
|
|
19
27
|
beforeEach(() => {
|
|
20
28
|
vi.resetAllMocks()
|