@playpilot/tpi 3.1.0 → 3.2.0-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/link-injections.js +8 -7
- package/package.json +1 -1
- package/src/lib/api.ts +1 -3
- package/src/lib/auth.ts +13 -1
- package/src/lib/constants.ts +2 -0
- package/src/lib/enums/TrackingEvent.ts +1 -0
- package/src/lib/linkInjection.ts +42 -32
- package/src/lib/scss/global.scss +6 -6
- package/src/lib/scss/variables.scss +2 -0
- package/src/lib/stores/organization.ts +4 -0
- package/src/lib/tracking.ts +14 -1
- package/src/lib/types/injection.d.ts +3 -0
- package/src/routes/+layout.svelte +6 -2
- package/src/routes/+page.svelte +17 -6
- package/src/routes/components/Editorial/AIIndicator.svelte +12 -4
- package/src/routes/components/Editorial/Alert.svelte +12 -2
- package/src/routes/components/Editorial/Editor.svelte +47 -20
- package/src/routes/components/Editorial/EditorItem.svelte +32 -7
- package/src/routes/components/Editorial/PlaylinkTypeSelect.svelte +14 -0
- package/src/routes/components/Editorial/ResizeHandle.svelte +1 -1
- package/src/routes/components/Editorial/Search/TitleSearchItem.svelte +6 -4
- package/src/routes/components/Icons/IconWarning.svelte +5 -0
- package/src/routes/components/TitlePopover.svelte +1 -1
- package/src/tests/lib/auth.test.js +31 -1
- package/src/tests/lib/linkInjection.test.js +79 -48
- package/src/tests/lib/tracking.test.js +61 -1
- package/src/tests/routes/+page.test.js +21 -4
- package/src/tests/routes/components/Editorial/AiIndicator.test.js +12 -5
- package/src/tests/routes/components/Editorial/Alert.test.js +10 -3
- package/src/tests/routes/components/Editorial/Editor.test.js +15 -0
- package/src/tests/routes/components/Editorial/EditorItem.test.js +32 -7
- package/src/tests/routes/components/Editorial/PlaylinkTypeSelect.test.js +13 -1
|
@@ -29,10 +29,10 @@ describe('EditorItem.svelte', () => {
|
|
|
29
29
|
const { getAllByText, container } = render(EditorItem, { linkInjection })
|
|
30
30
|
|
|
31
31
|
await fireEvent.mouseEnter(/** @type {HTMLElement} */ (container.querySelector('.item')))
|
|
32
|
-
expect(/** @type {HTMLElement} */ (getAllByText(linkInjection.title)[0].closest('span')).classList).toContain('injection-highlight')
|
|
32
|
+
expect(/** @type {HTMLElement} */ (getAllByText(linkInjection.title)[0].closest('span')).classList).toContain('playpilot-injection-highlight')
|
|
33
33
|
|
|
34
34
|
await fireEvent.mouseLeave(/** @type {HTMLElement} */ (container.querySelector('.item')))
|
|
35
|
-
expect(/** @type {HTMLElement} */ (getAllByText(linkInjection.title)[0].closest('span')).classList).not.toContain('injection-highlight')
|
|
35
|
+
expect(/** @type {HTMLElement} */ (getAllByText(linkInjection.title)[0].closest('span')).classList).not.toContain('playpilot-injection-highlight')
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
it('Should highlight multiple elements if multiple are present', async () => {
|
|
@@ -44,7 +44,20 @@ describe('EditorItem.svelte', () => {
|
|
|
44
44
|
const { container } = render(EditorItem, { linkInjection })
|
|
45
45
|
|
|
46
46
|
await fireEvent.mouseEnter(/** @type {HTMLElement} */ (container.querySelector('.item')))
|
|
47
|
-
expect(document.querySelectorAll('.injection-highlight')).toHaveLength(2)
|
|
47
|
+
expect(document.querySelectorAll('.playpilot-injection-highlight')).toHaveLength(2)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('Should highlight the sentence the injection is in if an injection failed but a matching sentence exists.', async () => {
|
|
51
|
+
document.body.innerHTML = '<p>This is a sentence with an injection.</p>'
|
|
52
|
+
|
|
53
|
+
const failedInjection = generateInjection('This is a sentence', 'fail')
|
|
54
|
+
|
|
55
|
+
injectLinksInDocument(Array.from(document.querySelectorAll('p')), () => null, { aiInjections: [], manualInjections: [failedInjection] })
|
|
56
|
+
|
|
57
|
+
const { container } = render(EditorItem, { linkInjection })
|
|
58
|
+
|
|
59
|
+
await fireEvent.mouseEnter(/** @type {HTMLElement} */ (container.querySelector('.item')))
|
|
60
|
+
expect(/** @type {HTMLElement} */ (document.querySelector('p')).classList).toContain('playpilot-injection-highlight')
|
|
48
61
|
})
|
|
49
62
|
|
|
50
63
|
it('Should scroll matching link into view when component is clicked', async () => {
|
|
@@ -59,9 +72,9 @@ describe('EditorItem.svelte', () => {
|
|
|
59
72
|
})
|
|
60
73
|
|
|
61
74
|
it('Should not scroll matching link into view when component is clicked but there is no matching injection', async () => {
|
|
62
|
-
document.body.innerHTML = '<p>This has no matching injections.</p>'
|
|
75
|
+
document.body.innerHTML = '<main><p>This has no matching injections.</p></main>'
|
|
63
76
|
|
|
64
|
-
injectLinksInDocument(Array.from(document.querySelectorAll('p')), () => null, linkInjections)
|
|
77
|
+
injectLinksInDocument(Array.from(document.querySelectorAll('main p')), () => null, linkInjections)
|
|
65
78
|
|
|
66
79
|
const { container } = render(EditorItem, { linkInjection })
|
|
67
80
|
|
|
@@ -108,9 +121,9 @@ describe('EditorItem.svelte', () => {
|
|
|
108
121
|
})
|
|
109
122
|
|
|
110
123
|
it('Should show different state when injection failed', () => {
|
|
111
|
-
const { getByText, queryByLabelText } = render(EditorItem, { linkInjection: { ...linkInjection, failed: true } })
|
|
124
|
+
const { getByText, queryByLabelText } = render(EditorItem, { linkInjection: { ...linkInjection, failed: true, failed_message: 'Some message' } })
|
|
112
125
|
|
|
113
|
-
expect(getByText('
|
|
126
|
+
expect(getByText('Some message')).toBeTruthy()
|
|
114
127
|
expect(queryByLabelText('Expand')).not.toBeTruthy()
|
|
115
128
|
expect(track).toHaveBeenCalled()
|
|
116
129
|
})
|
|
@@ -164,4 +177,16 @@ describe('EditorItem.svelte', () => {
|
|
|
164
177
|
expect(queryByText('Visible')).toBeTruthy()
|
|
165
178
|
expect(container.querySelector('.inactive')).not.toBeTruthy()
|
|
166
179
|
})
|
|
180
|
+
|
|
181
|
+
it('Should display an icon when playlink types are invalid', async () => {
|
|
182
|
+
const { getByLabelText } = render(EditorItem, { linkInjection: { ...linkInjection, in_text: false } })
|
|
183
|
+
|
|
184
|
+
expect(getByLabelText('Invalid playlink settings')).toBeTruthy()
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('Should not display an icon when playlink types are valid', async () => {
|
|
188
|
+
const { queryByLabelText } = render(EditorItem, { linkInjection: { ...linkInjection, in_text: true } })
|
|
189
|
+
|
|
190
|
+
expect(queryByLabelText('Invalid playlink settings')).not.toBeTruthy()
|
|
191
|
+
})
|
|
167
192
|
})
|
|
@@ -4,7 +4,7 @@ import { beforeEach, describe, expect, it } from 'vitest'
|
|
|
4
4
|
import PlaylinkTypeSelect from '../../../../routes/components/Editorial/PlaylinkTypeSelect.svelte'
|
|
5
5
|
|
|
6
6
|
describe('PlaylinkTypeSelect.svelte', () => {
|
|
7
|
-
/** @type {LinkInjection} */
|
|
7
|
+
/** @type {import('$lib/types/injection').LinkInjection} */
|
|
8
8
|
const linkInjection = {
|
|
9
9
|
sid: '1',
|
|
10
10
|
title: 'test',
|
|
@@ -60,4 +60,16 @@ describe('PlaylinkTypeSelect.svelte', () => {
|
|
|
60
60
|
expect(getByText('Modal button').classList).toContain('active')
|
|
61
61
|
expect(/** @type {HTMLElement} */(document.querySelector('.active-marker')).classList).toContain('right')
|
|
62
62
|
})
|
|
63
|
+
|
|
64
|
+
it('Should display a message when playlink types are invalid', async () => {
|
|
65
|
+
const { getByText } = render(PlaylinkTypeSelect, { linkInjection: { ...linkInjection, in_text: false } })
|
|
66
|
+
|
|
67
|
+
expect(getByText('At least one layout option must be selected for the playlink to be visible.')).toBeTruthy()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('Should not display a message when playlink types are valid', async () => {
|
|
71
|
+
const { queryByText } = render(PlaylinkTypeSelect, { linkInjection: { ...linkInjection, in_text: true } })
|
|
72
|
+
|
|
73
|
+
expect(queryByText('At least one layout option must be selected for the playlink to be visible.')).not.toBeTruthy()
|
|
74
|
+
})
|
|
63
75
|
})
|