@playpilot/tpi 8.15.0 → 8.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.15.0",
3
+ "version": "8.15.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -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 { titleUrl } from '$lib/routes'
8
+ import { exploreTitleUrl, titleUrl } from '$lib/routes'
9
9
  import { generateRandomHash } from '$lib/hash'
10
10
  import { getFirstTitleWithAvailableTrailer } from '$lib/trailer'
11
11
  import { useExploreRouter } from '$lib/explore'
@@ -19,6 +19,7 @@
19
19
  size?: 'small' | 'large' | 'huge' | 'flexible'
20
20
  aside?: boolean,
21
21
  expandable?: boolean,
22
+ navigateToExplore?: boolean,
22
23
  expandedTitle?: TitleData | null,
23
24
  expandedRailKey?: string | null,
24
25
  onclick?: (title: TitleData) => void,
@@ -32,6 +33,7 @@
32
33
  size = 'small',
33
34
  aside = false,
34
35
  expandable = false,
36
+ navigateToExplore = false,
35
37
  expandedTitle = $bindable(null),
36
38
  expandedRailKey = $bindable(null),
37
39
  onclick = () => null,
@@ -80,14 +82,19 @@
80
82
 
81
83
  if (!event) return
82
84
 
85
+ embed?.toggleMute(true)
86
+ onclick(title)
87
+
88
+ if (navigateToExplore) {
89
+ window.location.href = exploreTitleUrl(title)
90
+ return
91
+ }
92
+
83
93
  if (useExploreRouter()) {
84
94
  openModal({ event, type: 'titles-rail', data: titles as TitleData[], returnToTitle, props: { initialIndex: index } })
85
95
  } else {
86
96
  openModal({ event, data: title, returnToTitle })
87
97
  }
88
-
89
- embed?.toggleMute(true)
90
- onclick(title)
91
98
  }
92
99
 
93
100
  async function expandFirstAvailableTrailer(): Promise<void> {
@@ -167,7 +174,7 @@
167
174
  onresize={() => slider?.reposition()}>
168
175
  {#each titles as title, index}
169
176
  {@const expanded = isExpanded(title)}
170
- {@const href = titleUrl(title)}
177
+ {@const href = navigateToExplore ? exploreTitleUrl(title) : titleUrl(title)}
171
178
  {@const onclick = (event: MouseEvent): void => openTitle(event, titles, index)}
172
179
 
173
180
  <div class="title" class:expanded data-testid="title">
@@ -35,7 +35,11 @@
35
35
 
36
36
  {#if titles.length}
37
37
  <div class="widget" bind:this={element} data-testid="widget">
38
- <TitlesRail {titles} {heading} onclick={(title) => track(TrackingEvent.WidgetArticleRailTitleClick, title)} />
38
+ <TitlesRail
39
+ {titles}
40
+ {heading}
41
+ navigateToExplore={!!window.PlayPilotLinkInjections?.config?.open_tpi_links_in_explore}
42
+ onclick={(title) => track(TrackingEvent.WidgetArticleRailTitleClick, title)} />
39
43
  </div>
40
44
  {/if}
41
45
 
@@ -969,7 +969,7 @@ describe('injection.ts', () => {
969
969
  injectLinksInDocument(elements, { aiInjections: [injection], manualInjections: [] })
970
970
 
971
971
  const link = /** @type {HTMLAnchorElement} */ (document.querySelector('a'))
972
- expect(link.href).toBe(window.PlayPilotLinkInjections.config.explore_navigation_path + `?route=title&sid=${injection.title_details?.sid}`)
972
+ expect(link.href).toBe(window.PlayPilotLinkInjections.config.explore_navigation_path + `?route=modal&sid=${injection.title_details?.sid}`)
973
973
  expect(link.target).not.toBeTruthy()
974
974
  })
975
975
 
@@ -21,7 +21,7 @@ describe('$lib/routes', () => {
21
21
  explore_navigation_path: 'https://some-path.com/explore',
22
22
  }
23
23
 
24
- expect(exploreTitleUrl(title)).toBe(`https://some-path.com/explore?route=title&sid=${title.sid}`)
24
+ expect(exploreTitleUrl(title)).toBe(`https://some-path.com/explore?route=modal&sid=${title.sid}`)
25
25
  })
26
26
  })
27
27
  })
@@ -213,4 +213,14 @@ describe('TitlesRail.svelte', () => {
213
213
 
214
214
  expect(container.querySelector('.titles .slider')).toBeTruthy()
215
215
  })
216
+
217
+ it('Should navigate to explore page rather than open modal when navigateToExplore is true', async () => {
218
+ const { getAllByRole } = render(TitlesRail, { titles: [title], navigateToExplore: true })
219
+
220
+ await fireEvent.click(getAllByRole('link')[0])
221
+
222
+ expect(getAllByRole('link')[0].getAttribute('href')).toContain(`?route=modal&sid=${title.sid}`)
223
+ expect(window.location.href).toContain(`?route=modal&sid=${title.sid}`)
224
+ expect(openModal).not.toHaveBeenCalledWith()
225
+ })
216
226
  })