@playpilot/tpi 8.35.0-beta.1 → 8.35.0-beta.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.
- package/dist/editorial.mount.js +9 -9
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +6 -6
- package/package.json +1 -1
- package/src/lib/data/translations.ts +40 -0
- package/src/lib/fakeData.ts +6 -0
- package/src/lib/types/filter.d.ts +5 -2
- package/src/lib/types/participant.d.ts +1 -1
- package/src/routes/components/Explore/Filter/Filter.svelte +10 -4
- package/src/routes/components/Explore/Filter/FilterSorting.svelte +5 -4
- package/src/routes/components/Explore/Routes/ExploreResults.svelte +12 -7
- package/src/routes/components/GridTitle.svelte +11 -4
- package/src/routes/components/Modals/Modal.svelte +1 -1
- package/src/routes/components/Modals/ParticipantModal.svelte +1 -5
- package/src/routes/components/Participants/Participant.svelte +75 -135
- package/src/tests/routes/components/Participants/Participant.test.js +52 -14
|
@@ -3,15 +3,15 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
|
3
3
|
|
|
4
4
|
import Participant from '../../../../routes/components/Participants/Participant.svelte'
|
|
5
5
|
import { participants, title } from '$lib/fakeData'
|
|
6
|
-
import {
|
|
6
|
+
import { fetchTitles } from '$lib/api/titles'
|
|
7
7
|
import { Sorting } from '$lib/enums/Sorting'
|
|
8
8
|
|
|
9
9
|
vi.mock('$lib/tracking', () => ({
|
|
10
10
|
track: vi.fn(),
|
|
11
11
|
}))
|
|
12
12
|
|
|
13
|
-
vi.mock('$lib/api/
|
|
14
|
-
|
|
13
|
+
vi.mock('$lib/api/titles', () => ({
|
|
14
|
+
fetchTitles: vi.fn(),
|
|
15
15
|
}))
|
|
16
16
|
|
|
17
17
|
describe('Participant.svelte', () => {
|
|
@@ -19,18 +19,20 @@ describe('Participant.svelte', () => {
|
|
|
19
19
|
vi.resetAllMocks()
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
it('Should call
|
|
22
|
+
it('Should call fetchTitles on mount', async () => {
|
|
23
23
|
render(Participant, { participant: participants[0] })
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
await waitFor(() => {
|
|
26
|
+
expect(fetchTitles).toHaveBeenCalled()
|
|
27
|
+
})
|
|
26
28
|
})
|
|
27
29
|
|
|
28
30
|
it('Should render fetched titles after showing skeletons', async () => {
|
|
29
|
-
vi.mocked(
|
|
31
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce({ results: [title, title], next: 'next', previous: 'previous' })
|
|
30
32
|
|
|
31
33
|
const { getAllByTestId } = render(Participant, { participant: participants[0] })
|
|
32
34
|
|
|
33
|
-
expect(getAllByTestId('skeleton')).toHaveLength(
|
|
35
|
+
expect(getAllByTestId('skeleton')).toHaveLength(24)
|
|
34
36
|
|
|
35
37
|
await waitFor(() => {
|
|
36
38
|
expect(getAllByTestId('title')).toHaveLength(2)
|
|
@@ -38,7 +40,7 @@ describe('Participant.svelte', () => {
|
|
|
38
40
|
})
|
|
39
41
|
|
|
40
42
|
it('Should not show load more button while loading and when fewer than page size of titles are fetched', async () => {
|
|
41
|
-
vi.mocked(
|
|
43
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce({ results: [title, title], next: 'next', previous: 'previous' })
|
|
42
44
|
|
|
43
45
|
const { queryByText, getAllByTestId } = render(Participant, { participant: participants[0] })
|
|
44
46
|
|
|
@@ -52,8 +54,8 @@ describe('Participant.svelte', () => {
|
|
|
52
54
|
})
|
|
53
55
|
|
|
54
56
|
it('Should show load more button after loading and if more than page size of titles are fetched', async () => {
|
|
55
|
-
const resolved = Array(30).fill(title)
|
|
56
|
-
vi.mocked(
|
|
57
|
+
const resolved = ({ results: Array(30).fill(title), next: 'next', previous: 'previous' })
|
|
58
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce(resolved)
|
|
57
59
|
|
|
58
60
|
const { getByText } = render(Participant, { participant: participants[0] })
|
|
59
61
|
|
|
@@ -63,8 +65,8 @@ describe('Participant.svelte', () => {
|
|
|
63
65
|
})
|
|
64
66
|
|
|
65
67
|
it('Should fetch more titles when load more button is clicked', async () => {
|
|
66
|
-
const resolved = Array(30).fill(title)
|
|
67
|
-
vi.mocked(
|
|
68
|
+
const resolved = ({ results: Array(30).fill(title), next: 'next', previous: 'previous' })
|
|
69
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce(resolved)
|
|
68
70
|
|
|
69
71
|
const { getByText } = render(Participant, { participant: participants[0] })
|
|
70
72
|
|
|
@@ -72,7 +74,34 @@ describe('Participant.svelte', () => {
|
|
|
72
74
|
|
|
73
75
|
await fireEvent.click(getByText('Show more'))
|
|
74
76
|
|
|
75
|
-
expect(
|
|
77
|
+
expect(fetchTitles).toHaveBeenCalledWith({ page: 2, page_size: expect.any(Number), participant_job: null, participant_sid: participants[0].sid })
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('Should include participant role in fetchTitles when selected and refetch', async () => {
|
|
81
|
+
const resolved = ({ results: Array(30).fill(title), next: 'next', previous: 'previous' })
|
|
82
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce(resolved)
|
|
83
|
+
|
|
84
|
+
const { getByText } = render(Participant, { participant: participants[0] })
|
|
85
|
+
|
|
86
|
+
await fireEvent.click(getByText('Actor'))
|
|
87
|
+
|
|
88
|
+
await waitFor(() => {
|
|
89
|
+
expect(fetchTitles).toHaveBeenCalledWith(expect.objectContaining({ participant_job: 'actor' }))
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('Should include selected sorting specific to participants', async () => {
|
|
94
|
+
const resolved = ({ results: Array(30).fill(title), next: 'next', previous: 'previous' })
|
|
95
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce(resolved)
|
|
96
|
+
|
|
97
|
+
const { getByText } = render(Participant, { participant: participants[0] })
|
|
98
|
+
|
|
99
|
+
await fireEvent.click(getByText('Sort by'))
|
|
100
|
+
await fireEvent.click(getByText('Year'))
|
|
101
|
+
|
|
102
|
+
await waitFor(() => {
|
|
103
|
+
expect(fetchTitles).toHaveBeenCalledWith(expect.objectContaining({ ordering: Sorting.Chronological }))
|
|
104
|
+
})
|
|
76
105
|
})
|
|
77
106
|
|
|
78
107
|
it('Should render as small variant when given', () => {
|
|
@@ -93,11 +122,20 @@ describe('Participant.svelte', () => {
|
|
|
93
122
|
})
|
|
94
123
|
|
|
95
124
|
it('Should not render image if not given', async () => {
|
|
96
|
-
|
|
97
125
|
const { queryByRole } = render(Participant, { participant: participants[0] })
|
|
98
126
|
|
|
99
127
|
await waitFor(() => {
|
|
100
128
|
expect(queryByRole('presentation')).not.toBeTruthy()
|
|
101
129
|
})
|
|
102
130
|
})
|
|
131
|
+
|
|
132
|
+
it('Should render description and toggle more on click of Read more button', async () => {
|
|
133
|
+
const { getByText } = render(Participant, { participant: participants[0] })
|
|
134
|
+
|
|
135
|
+
expect(getByText(participants[0].description)).toBeTruthy()
|
|
136
|
+
|
|
137
|
+
await fireEvent.click(getByText('Read more'))
|
|
138
|
+
|
|
139
|
+
expect(getByText('Read less')).toBeTruthy()
|
|
140
|
+
})
|
|
103
141
|
})
|