@playpilot/tpi 8.37.2 → 8.38.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.37.2",
3
+ "version": "8.38.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -17,7 +17,7 @@ export function getLinkInjectionElements(parentElement: HTMLElement, excludeElem
17
17
  if (validElements.includes(element)) continue
18
18
  if (excludeElementsSelector && element.matches(excludeElementsSelector)) continue
19
19
 
20
- if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|LABEL|BLOCKQUOTE|H1)$/.test(element.tagName)) continue
20
+ if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|LABEL|BLOCKQUOTE|H1|H2|H3|H4|H5)$/.test(element.tagName)) continue
21
21
 
22
22
  // Ignore elements that are visibly hidden as they are likely only for screen readers.
23
23
  // These elements can be hidden via display: none or via a tiny width or perhaps even a clip path.
@@ -49,10 +49,12 @@
49
49
  </script>
50
50
 
51
51
  <div class="header" class:small>
52
- <ParticipantImage {participant} />
52
+ {#if participant.image}
53
+ <ParticipantImage {participant} />
54
+ {/if}
53
55
 
54
56
  <div>
55
- <div class="heading" use:heading={2} id="heading">{name}</div>
57
+ <div class="heading" class:no-image={!participant.image} use:heading={2} id="heading">{name}</div>
56
58
 
57
59
  {#if description}
58
60
  <p class="description" class:expanded={descriptionExpanded}>
@@ -126,6 +128,10 @@
126
128
  font-size: theme(detail-title-small-font-size, margin(1.25));
127
129
  }
128
130
 
131
+ &.no-image {
132
+ margin-top: margin(0.5);
133
+ }
134
+
129
135
  .small & {
130
136
  font-size: 1.25em;
131
137
  }
@@ -24,7 +24,7 @@
24
24
  }
25
25
  </script>
26
26
 
27
- <div class="image">
27
+ <div class="image" data-testid="participant-image">
28
28
  {#if participant?.image}
29
29
  <img loading="lazy" src={participant.image} alt="" />
30
30
 
@@ -79,9 +79,11 @@ describe('injectionElements.ts', () => {
79
79
  expect(getLinkInjectionElements(parent)[1].tagName).toBe('OL')
80
80
  })
81
81
 
82
- it('Should ignore links, buttons, script tags, style tags, iframes, h1, and more', () => {
82
+ it('Should ignore links, buttons, script tags, style tags, iframes, headings, and more', () => {
83
83
  document.body.innerHTML = `<section>
84
84
  <h1>Some header</h1>
85
+ <h2>Some header</h2>
86
+ <h3>Some header</h3>
85
87
 
86
88
  <a>I am a link</a>
87
89
  <button>And I am a button</button>
@@ -97,7 +99,7 @@ describe('injectionElements.ts', () => {
97
99
 
98
100
  <div>
99
101
  <a>I am another link</a>
100
- <h4>Some smaller header</h4>
102
+ <span>Some smaller header</span>
101
103
  <p>And finally, some text</p>
102
104
  </div>
103
105
  </section>`
@@ -152,9 +152,9 @@ describe('ManualInjection.svelte', () => {
152
152
  vi.mocked(searchTitles).mockResolvedValueOnce([title])
153
153
  vi.mocked(getIndexOfSelection).mockReturnValueOnce({ start: 0, end: 0 })
154
154
 
155
- document.body.innerHTML = '<main><h2>Some title</h2> <p>Some paragraph</p></main>'
155
+ document.body.innerHTML = '<main><span>Some title</span> <p>Some paragraph</p></main>'
156
156
 
157
- const container = document.querySelector('h2')
157
+ const container = document.querySelector('span')
158
158
 
159
159
  // @ts-ignore
160
160
  window.getSelection = vi.fn(() => ({
@@ -1,4 +1,4 @@
1
- import { fireEvent, render, waitFor } from '@testing-library/svelte'
1
+ import { fireEvent, getByTestId, render, waitFor } from '@testing-library/svelte'
2
2
  import { describe, expect, it, vi, beforeEach } from 'vitest'
3
3
 
4
4
  import Participant from '../../../../routes/components/Participants/Participant.svelte'
@@ -124,18 +124,19 @@ describe('Participant.svelte', () => {
124
124
  it('Should render image if given', async () => {
125
125
  const participantWithImage = { ...participants[0], image: 'some-image.jpg' }
126
126
 
127
- const { getByRole } = render(Participant, { participant: participantWithImage })
127
+ const { getByTestId } = render(Participant, { participant: participantWithImage })
128
128
 
129
129
  await waitFor(() => {
130
- expect(getByRole('presentation')).toBeTruthy()
130
+ expect(getByTestId('participant-image')).toBeTruthy()
131
131
  })
132
132
  })
133
133
 
134
134
  it('Should not render image if not given', async () => {
135
- const { queryByRole } = render(Participant, { participant: participants[0] })
135
+ const { queryByTestId } = render(Participant, { participant: participants[0] })
136
136
 
137
137
  await waitFor(() => {
138
- expect(queryByRole('presentation')).not.toBeTruthy()
138
+ expect(queryByTestId('participant-image')).not.toBeTruthy()
139
+ expect(queryByTestId('participant-image')).not.toBeTruthy()
139
140
  })
140
141
  })
141
142