@playpilot/tpi 8.21.7 → 8.21.8-beta.1
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 +11 -11
- package/dist/link-injections.js +2 -2
- package/dist/mount.js +7 -7
- package/package.json +1 -1
- package/src/lib/api/youtubeAvailability.ts +2 -1
- package/src/routes/+page.svelte +1 -1
- package/src/routes/components/Explore/ExploreRouter.svelte +10 -4
- package/src/tests/lib/api/youtubeAvailability.test.js +9 -0
package/package.json
CHANGED
|
@@ -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 =
|
|
5
|
+
const region = (await getRegionBasedOnIp())?.toUpperCase()
|
|
5
6
|
|
|
6
7
|
if (!region) return true
|
|
7
8
|
|
package/src/routes/+page.svelte
CHANGED
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
}} />
|
|
216
216
|
|
|
217
217
|
{#snippet failed()}
|
|
218
|
-
<Alert fixed>An error has
|
|
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
|
-
<
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
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>
|
|
@@ -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
|
})
|