@playpilot/tpi 6.6.4 → 6.7.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 +9 -9
- package/package.json +1 -1
- package/src/lib/enums/TrackingEvent.ts +2 -0
- package/src/routes/components/Button.svelte +17 -7
- package/src/routes/components/ContextMenu.svelte +46 -22
- package/src/routes/components/Editorial/EditorItem.svelte +1 -1
- package/src/routes/components/Icons/IconNotify.svelte +3 -0
- package/src/routes/components/Icons/IconPlay.svelte +2 -2
- package/src/routes/components/Icons/IconSave.svelte +3 -0
- package/src/routes/components/Icons/IconShare.svelte +3 -2
- package/src/routes/components/Notify.svelte +63 -0
- package/src/routes/components/Playlinks/Playlinks.svelte +16 -33
- package/src/routes/components/Rails/TitlesRail.svelte +1 -0
- package/src/routes/components/Save.svelte +40 -0
- package/src/routes/components/Share.svelte +19 -57
- package/src/routes/components/Title.svelte +14 -3
- package/src/routes/components/Trailer.svelte +1 -2
- package/src/tests/routes/components/Button.test.js +6 -0
- package/src/tests/routes/components/ContextMenu.test.js +15 -3
- package/src/tests/routes/components/Playlinks/Playlinks.test.js +4 -3
- package/src/tests/routes/components/Share.test.js +17 -12
- package/src/tests/routes/components/Title.test.js +4 -4
|
@@ -5,6 +5,7 @@ import Share from '../../../routes/components/Share.svelte'
|
|
|
5
5
|
import { copyToClipboard } from '$lib/clipboard'
|
|
6
6
|
import { track } from '$lib/tracking'
|
|
7
7
|
import { TrackingEvent } from '$lib/enums/TrackingEvent'
|
|
8
|
+
import { beforeEach } from 'node:test'
|
|
8
9
|
|
|
9
10
|
vi.mock('$lib/clipboard', () => ({
|
|
10
11
|
copyToClipboard: vi.fn(),
|
|
@@ -15,58 +16,62 @@ vi.mock('$lib/tracking', () => ({
|
|
|
15
16
|
}))
|
|
16
17
|
|
|
17
18
|
describe('Share.svelte', () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.resetAllMocks()
|
|
21
|
+
})
|
|
22
|
+
|
|
18
23
|
it('Should open context menu on click', async () => {
|
|
19
|
-
const {
|
|
24
|
+
const { getByLabelText, queryByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
20
25
|
|
|
21
26
|
expect(queryByText('Copy URL')).not.toBeTruthy()
|
|
22
27
|
expect(queryByText('Email')).not.toBeTruthy()
|
|
23
28
|
|
|
24
|
-
await fireEvent.click(
|
|
29
|
+
await fireEvent.click(getByLabelText('Share'))
|
|
25
30
|
|
|
26
31
|
expect(queryByText('Copy URL')).toBeTruthy()
|
|
27
32
|
expect(queryByText('Email')).toBeTruthy()
|
|
28
33
|
})
|
|
29
34
|
|
|
30
35
|
it('Should close context menu on click of items', async () => {
|
|
31
|
-
const { getByText, queryByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
36
|
+
const { getByLabelText, getByText, queryByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
32
37
|
|
|
33
|
-
await fireEvent.click(
|
|
38
|
+
await fireEvent.click(getByLabelText('Share'))
|
|
34
39
|
await fireEvent.click(getByText('Copy URL'))
|
|
35
40
|
|
|
36
41
|
expect(queryByText('Copy URL')).not.toBeTruthy()
|
|
37
42
|
})
|
|
38
43
|
|
|
39
44
|
it('Should close context menu on click of body', async () => {
|
|
40
|
-
const {
|
|
45
|
+
const { getByLabelText, queryByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
41
46
|
|
|
42
|
-
await fireEvent.click(
|
|
47
|
+
await fireEvent.click(getByLabelText('Share'))
|
|
43
48
|
await fireEvent.click(document.body)
|
|
44
49
|
|
|
45
50
|
expect(queryByText('Copy URL')).not.toBeTruthy()
|
|
46
51
|
})
|
|
47
52
|
|
|
48
53
|
it('Should fire copyToClipboard on click of button', async () => {
|
|
49
|
-
const { getByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
54
|
+
const { getByLabelText, getByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
50
55
|
|
|
51
|
-
await fireEvent.click(
|
|
56
|
+
await fireEvent.click(getByLabelText('Share'))
|
|
52
57
|
await fireEvent.click(getByText('Copy URL'))
|
|
53
58
|
|
|
54
59
|
expect(copyToClipboard).toHaveBeenCalledWith('some-url?utm_source=tpi')
|
|
55
60
|
})
|
|
56
61
|
|
|
57
62
|
it('Should fire track function on click of copy URL button', async () => {
|
|
58
|
-
const { getByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
63
|
+
const { getByLabelText, getByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
59
64
|
|
|
60
|
-
await fireEvent.click(
|
|
65
|
+
await fireEvent.click(getByLabelText('Share'))
|
|
61
66
|
await fireEvent.click(getByText('Copy URL'))
|
|
62
67
|
|
|
63
68
|
expect(track).toHaveBeenCalledWith(TrackingEvent.ShareTitle, null, { title: 'Some title', url: 'http://localhost:3000/', method: 'copy' })
|
|
64
69
|
})
|
|
65
70
|
|
|
66
71
|
it('Should fire track function on click of email button', async () => {
|
|
67
|
-
const { getByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
72
|
+
const { getByLabelText, getByText } = render(Share, { title: 'Some title', url: 'some-url' })
|
|
68
73
|
|
|
69
|
-
await fireEvent.click(
|
|
74
|
+
await fireEvent.click(getByLabelText('Share'))
|
|
70
75
|
await fireEvent.click(getByText('Email'))
|
|
71
76
|
|
|
72
77
|
expect(track).toHaveBeenCalledWith(TrackingEvent.ShareTitle, null, { title: 'Some title', url: 'http://localhost:3000/', method: 'email' })
|
|
@@ -94,14 +94,14 @@ describe('Title.svelte', () => {
|
|
|
94
94
|
})
|
|
95
95
|
|
|
96
96
|
it('Should show trailer button when embeddable_url is given', () => {
|
|
97
|
-
const {
|
|
97
|
+
const { getByLabelText } = render(Title, { title: { ...title, embeddable_url: 'some-url' } })
|
|
98
98
|
|
|
99
|
-
expect(
|
|
99
|
+
expect(getByLabelText('Watch trailer')).toBeTruthy()
|
|
100
100
|
})
|
|
101
101
|
|
|
102
102
|
it('Should not show trailer button when embeddable_url is not given', () => {
|
|
103
|
-
const {
|
|
103
|
+
const { queryByLabelText } = render(Title, { title })
|
|
104
104
|
|
|
105
|
-
expect(
|
|
105
|
+
expect(queryByLabelText('Watch trailer')).not.toBeTruthy()
|
|
106
106
|
})
|
|
107
107
|
})
|