@playpilot/tpi 8.21.7 → 8.21.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.21.7",
3
+ "version": "8.21.8",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -1,7 +1,8 @@
1
1
  import { PUBLIC_YOUTUBE_AVAILABILITY_URL } from '$env/static/public'
2
+ import { getRegionBasedOnIp } from './region'
2
3
 
3
4
  export async function isYouTubeVideoAvailableInRegion(videoId: string): Promise<boolean> {
4
- const region = window.PlayPilotLinkInjections?.region?.toUpperCase()
5
+ const region = (await getRegionBasedOnIp())?.toUpperCase()
5
6
 
6
7
  if (!region) return true
7
8
 
@@ -215,7 +215,7 @@
215
215
  }} />
216
216
 
217
217
  {#snippet failed()}
218
- <Alert fixed>An error has occured in the PlayPilot Linkinjections editor view. We've been notified and will investigate!</Alert>
218
+ <Alert fixed>An error has occurred in the PlayPilot Linkinjections editor view. We've been notified and will investigate!</Alert>
219
219
  {/snippet}
220
220
  </svelte:boundary>
221
221
  {/if}
@@ -74,7 +74,13 @@
74
74
 
75
75
  <svelte:window on:popstate={onhashchange} />
76
76
 
77
- <ExploreLayout {navigate} bind:searchQuery bind:filter>
78
- <CurrentRouteComponent {searchQuery} {filter} {navigate} />
79
- <CurrentAppendComponent {navigate} />
80
- </ExploreLayout>
77
+ <svelte:boundary onerror={(error) => console.error(error)}>
78
+ <ExploreLayout {navigate} bind:searchQuery bind:filter>
79
+ <CurrentRouteComponent {searchQuery} {filter} {navigate} />
80
+ <CurrentAppendComponent {navigate} />
81
+ </ExploreLayout>
82
+
83
+ {#snippet failed()}
84
+ <p>An error occurred.</p>
85
+ {/snippet}
86
+ </svelte:boundary>
@@ -5,7 +5,7 @@
5
5
  import Rail from './Rail.svelte'
6
6
  import type { TitleData } from '$lib/types/title'
7
7
  import { openModal } from '$lib/modal'
8
- import { exploreTitleUrl, titleUrl } from '$lib/routes'
8
+ import { exploreTitleUrl } from '$lib/routes'
9
9
  import { generateRandomHash } from '$lib/hash'
10
10
  import { getFirstTitleWithAvailableTrailer } from '$lib/trailer'
11
11
  import { useExploreRouter } from '$lib/explore'
@@ -174,14 +174,15 @@
174
174
  onresize={() => slider?.reposition()}>
175
175
  {#each titles as title, index}
176
176
  {@const expanded = isExpanded(title)}
177
- {@const href = navigateToExplore ? exploreTitleUrl(title) : titleUrl(title)}
178
177
  {@const onclick = (event: MouseEvent): void => openTitle(event, titles, index)}
179
178
 
180
179
  <div class="title" class:expanded data-testid="title">
181
180
  <div class="media">
182
181
  {#if expanded}
183
182
  <div class="video" out:fade={{ delay: 200, duration: 200 }}>
184
- <a class="video-overlay" title="" {href} {onclick}></a>
183
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
184
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
185
+ <div class="video-overlay" title="" {onclick}></div>
185
186
 
186
187
  {#if !!title.embeddable_url}
187
188
  <YouTubeEmbed bind:this={embed} embeddable_url={title.embeddable_url!} muted loop captions showMuteControls />
@@ -190,15 +191,19 @@
190
191
  {/if}
191
192
  </div>
192
193
  {:else}
193
- <a class="poster" {href} {onclick}>
194
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
195
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
196
+ <div class="poster" {onclick}>
194
197
  <TitlePoster {title} width={96} height={144} />
195
- </a>
198
+ </div>
196
199
  {/if}
197
200
  </div>
198
201
 
199
- <a class="heading" {href} {onclick} data-testid="heading">
202
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
203
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
204
+ <span class="heading" {onclick} data-testid="heading">
200
205
  {title.title}
201
- </a>
206
+ </span>
202
207
 
203
208
  {#if aside}
204
209
  <!-- svelte-ignore a11y_click_events_have_key_events -->
@@ -1,6 +1,7 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest'
2
2
  import { isYouTubeVideoAvailableInRegion } from '$lib/api/youtubeAvailability'
3
3
  import { fakeFetch } from '../../helpers'
4
+ import { getRegionBasedOnIp } from '$lib/api/region'
4
5
 
5
6
  vi.mock('$lib/tracking', () => ({
6
7
  track: vi.fn(),
@@ -10,6 +11,10 @@ vi.mock('$env/static/public', () => ({
10
11
  PUBLIC_YOUTUBE_AVAILABILITY_URL: 'https://some-path.com',
11
12
  }))
12
13
 
14
+ vi.mock('$lib/api/region', () => ({
15
+ getRegionBasedOnIp: vi.fn(),
16
+ }))
17
+
13
18
  describe('youtubeAvailability', () => {
14
19
  beforeEach(() => {
15
20
  vi.resetAllMocks()
@@ -17,6 +22,8 @@ describe('youtubeAvailability', () => {
17
22
 
18
23
  // @ts-ignore
19
24
  window.PlayPilotLinkInjections = { region: 'nl' }
25
+
26
+ vi.mocked(getRegionBasedOnIp).mockResolvedValue('nl')
20
27
  })
21
28
 
22
29
  describe('isYouTubeVideoAvailableInRegion', () => {
@@ -24,6 +31,8 @@ describe('youtubeAvailability', () => {
24
31
  // @ts-ignore
25
32
  window.PlayPilotLinkInjections = {}
26
33
 
34
+ vi.mocked(getRegionBasedOnIp).mockResolvedValueOnce('')
35
+
27
36
  expect(await isYouTubeVideoAvailableInRegion('video-id')).toBe(true)
28
37
  expect(global.fetch).not.toHaveBeenCalled()
29
38
  })
@@ -36,16 +36,15 @@ describe('TitlesRail.svelte', () => {
36
36
  })
37
37
 
38
38
  it('Should render all titles', async () => {
39
- const { getAllByTestId, getAllByRole } = render(TitlesRail, { titles: [title, title] })
39
+ const { getAllByTestId } = render(TitlesRail, { titles: [title, title] })
40
40
 
41
41
  expect(getAllByTestId('title')).toHaveLength(2)
42
- expect(getAllByRole('link')[0].getAttribute('href')).toBe(`https://www.playpilot.com/series/${title.slug}/`)
43
42
  })
44
43
 
45
44
  it('Should fire openModal when title is clicked', async () => {
46
- const { getAllByRole } = render(TitlesRail, { titles: [title] })
45
+ const { getByText } = render(TitlesRail, { titles: [title] })
47
46
 
48
- await fireEvent.click(getAllByRole('link')[0])
47
+ await fireEvent.click(getByText(title.title))
49
48
 
50
49
  expect(openModal).toHaveBeenCalledWith({
51
50
  type: 'titles-rail',
@@ -57,9 +56,9 @@ describe('TitlesRail.svelte', () => {
57
56
 
58
57
  it('Should fire given onclick function when title is clicked', async () => {
59
58
  const onclick = vi.fn()
60
- const { getAllByRole } = render(TitlesRail, { titles: [title], onclick })
59
+ const { getByText } = render(TitlesRail, { titles: [title], onclick })
61
60
 
62
- await fireEvent.click(getAllByRole('link')[0])
61
+ await fireEvent.click(getByText(title.title))
63
62
 
64
63
  expect(onclick).toHaveBeenCalledWith(title)
65
64
  })
@@ -215,11 +214,10 @@ describe('TitlesRail.svelte', () => {
215
214
  })
216
215
 
217
216
  it('Should navigate to explore page rather than open modal when navigateToExplore is true', async () => {
218
- const { getAllByRole } = render(TitlesRail, { titles: [title], navigateToExplore: true })
217
+ const { getByText } = render(TitlesRail, { titles: [title], navigateToExplore: true })
219
218
 
220
- await fireEvent.click(getAllByRole('link')[0])
219
+ await fireEvent.click(getByText(title.title))
221
220
 
222
- expect(getAllByRole('link')[0].getAttribute('href')).toContain(`?route=modal&sid=${title.sid}`)
223
221
  expect(window.location.href).toContain(`?route=modal&sid=${title.sid}`)
224
222
  expect(openModal).not.toHaveBeenCalledWith()
225
223
  })