@playpilot/tpi 8.38.1 → 8.38.3

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.38.1",
3
+ "version": "8.38.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -57,7 +57,7 @@
57
57
  onexpand={(title) => track(TrackingEvent.ExploreTitleRailExpandClick, title, { rail: headings })}
58
58
  fetchFunction={(page) => getListTitles({ ...params, page })}
59
59
  size={properties.size || 'flexible'}
60
- minimumLength={7} />
60
+ minimumLength={properties.minimum ?? 7} />
61
61
  </div>
62
62
  {/each}
63
63
  {:catch}
@@ -168,6 +168,8 @@
168
168
  {/each}
169
169
  </Rail>
170
170
  {:then titles}
171
+ {@const titlesWithoutDuplicates = titles?.filter((a, i, titles) => titles.findIndex(b => (b.sid === a.sid)) === i)}
172
+
171
173
  {#if titles?.length >= minimumLength}
172
174
  <Rail
173
175
  bind:slider
@@ -175,7 +177,7 @@
175
177
  {heading}
176
178
  onchange={(index) => onchange(titles, index)}
177
179
  onresize={() => slider?.reposition()}>
178
- {#each titles as title, index}
180
+ {#each titlesWithoutDuplicates as title, index}
179
181
  {@const expanded = isExpanded(title)}
180
182
  {@const onclick = (event: MouseEvent): void => openTitle(event, titles, index)}
181
183
 
@@ -36,7 +36,7 @@ describe('TitlesRail.svelte', () => {
36
36
  })
37
37
 
38
38
  it('Should render all titles', async () => {
39
- const { getAllByTestId } = render(TitlesRail, { titles: [title, title] })
39
+ const { getAllByTestId } = render(TitlesRail, { titles: [{ ...title, sid: '1' }, { ...title, sid: '2' }] })
40
40
 
41
41
  expect(getAllByTestId('title')).toHaveLength(2)
42
42
  })
@@ -202,13 +202,13 @@ describe('TitlesRail.svelte', () => {
202
202
  })
203
203
 
204
204
  it('Should not render rails if fewer than given mimimumLength of titles were returned', () => {
205
- const { container } = render(TitlesRail, { titles: [title, title], minimumLength: 3 })
205
+ const { container } = render(TitlesRail, { titles: [{ ...title, sid: '1' }, { ...title, sid: '2' }], minimumLength: 3 })
206
206
 
207
207
  expect(container.querySelector('.titles .slider')).not.toBeTruthy()
208
208
  })
209
209
 
210
210
  it('Should render rails if equal or more than given mimimumLength of titles were returned', () => {
211
- const { container } = render(TitlesRail, { titles: [title, title, title], minimumLength: 3 })
211
+ const { container } = render(TitlesRail, { titles: [{ ...title, sid: '1' }, { ...title, sid: '2' }, { ...title, sid: '3' }], minimumLength: 3 })
212
212
 
213
213
  expect(container.querySelector('.titles .slider')).toBeTruthy()
214
214
  })
@@ -221,4 +221,10 @@ describe('TitlesRail.svelte', () => {
221
221
  expect(window.location.href).toContain(`?route=modal&sid=${title.sid}`)
222
222
  expect(openModal).not.toHaveBeenCalledWith()
223
223
  })
224
+
225
+ it('Should remove duplicate titles', () => {
226
+ const { container } = render(TitlesRail, { titles: [title, title] })
227
+
228
+ expect(container.querySelectorAll('.title')).toHaveLength(1)
229
+ })
224
230
  })