@prenta/admin 2.7.0 → 2.9.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/CHANGELOG.md +46 -0
- package/design-system/tokens.css +17 -0
- package/design-system/tokens.json +35 -1
- package/design-system/tokens.scss +15 -0
- package/design-system/tokens.tailwind.cjs +14 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +7 -7
- package/dist/AdminRoot.js.map +1 -1
- package/dist/__tests__/components/batch-ai-actions.test.js +4 -0
- package/dist/__tests__/components/batch-ai-actions.test.js.map +1 -1
- package/dist/__tests__/lib/batch-wizard.test.d.ts +2 -0
- package/dist/__tests__/lib/batch-wizard.test.d.ts.map +1 -0
- package/dist/__tests__/lib/batch-wizard.test.js +227 -0
- package/dist/__tests__/lib/batch-wizard.test.js.map +1 -0
- package/dist/__tests__/lib/job-drawer.test.js +2 -0
- package/dist/__tests__/lib/job-drawer.test.js.map +1 -1
- package/dist/__tests__/lib/job-view.test.js +100 -3
- package/dist/__tests__/lib/job-view.test.js.map +1 -1
- package/dist/__tests__/lib/jobs-service.test.js +74 -2
- package/dist/__tests__/lib/jobs-service.test.js.map +1 -1
- package/dist/__tests__/views/appearance-chrome.render.test.d.ts +2 -0
- package/dist/__tests__/views/appearance-chrome.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/appearance-chrome.render.test.js +688 -0
- package/dist/__tests__/views/appearance-chrome.render.test.js.map +1 -0
- package/dist/__tests__/views/header-footer-form.test.d.ts +2 -0
- package/dist/__tests__/views/header-footer-form.test.d.ts.map +1 -0
- package/dist/__tests__/views/header-footer-form.test.js +266 -0
- package/dist/__tests__/views/header-footer-form.test.js.map +1 -0
- package/dist/__tests__/views/jobs-drawer.render.test.js +442 -2
- package/dist/__tests__/views/jobs-drawer.render.test.js.map +1 -1
- package/dist/__tests__/views/jobs-list.render.test.js +7 -5
- package/dist/__tests__/views/jobs-list.render.test.js.map +1 -1
- package/dist/__tests__/views/jobs-wizard.render.test.d.ts +2 -0
- package/dist/__tests__/views/jobs-wizard.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/jobs-wizard.render.test.js +588 -0
- package/dist/__tests__/views/jobs-wizard.render.test.js.map +1 -0
- package/dist/__tests__/views/run-with-ai.render.test.d.ts +2 -0
- package/dist/__tests__/views/run-with-ai.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/run-with-ai.render.test.js +689 -0
- package/dist/__tests__/views/run-with-ai.render.test.js.map +1 -0
- package/dist/components/BatchAiActions.d.ts +8 -1
- package/dist/components/BatchAiActions.d.ts.map +1 -1
- package/dist/components/BatchAiActions.js +3 -2
- package/dist/components/BatchAiActions.js.map +1 -1
- package/dist/lib/api.d.ts +2 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +8 -1
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/batch-wizard.d.ts +118 -0
- package/dist/lib/batch-wizard.d.ts.map +1 -0
- package/dist/lib/batch-wizard.js +216 -0
- package/dist/lib/batch-wizard.js.map +1 -0
- package/dist/lib/chrome-service.d.ts +69 -0
- package/dist/lib/chrome-service.d.ts.map +1 -0
- package/dist/lib/chrome-service.js +108 -0
- package/dist/lib/chrome-service.js.map +1 -0
- package/dist/lib/job-view.d.ts +43 -0
- package/dist/lib/job-view.d.ts.map +1 -1
- package/dist/lib/job-view.js +57 -1
- package/dist/lib/job-view.js.map +1 -1
- package/dist/lib/jobs-service.d.ts +48 -1
- package/dist/lib/jobs-service.d.ts.map +1 -1
- package/dist/lib/jobs-service.js +50 -0
- package/dist/lib/jobs-service.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/AppearanceChrome.d.ts +22 -4
- package/dist/views/AppearanceChrome.d.ts.map +1 -1
- package/dist/views/AppearanceChrome.js +451 -15
- package/dist/views/AppearanceChrome.js.map +1 -1
- package/dist/views/CollectionList.d.ts +3 -1
- package/dist/views/CollectionList.d.ts.map +1 -1
- package/dist/views/CollectionList.js +5 -2
- package/dist/views/CollectionList.js.map +1 -1
- package/dist/views/Jobs/CancelJobDialog.d.ts +7 -1
- package/dist/views/Jobs/CancelJobDialog.d.ts.map +1 -1
- package/dist/views/Jobs/CancelJobDialog.js +13 -3
- package/dist/views/Jobs/CancelJobDialog.js.map +1 -1
- package/dist/views/Jobs/DrawerOverview.d.ts +6 -2
- package/dist/views/Jobs/DrawerOverview.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerOverview.js +6 -3
- package/dist/views/Jobs/DrawerOverview.js.map +1 -1
- package/dist/views/Jobs/DrawerResults.d.ts +13 -3
- package/dist/views/Jobs/DrawerResults.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerResults.js +37 -3
- package/dist/views/Jobs/DrawerResults.js.map +1 -1
- package/dist/views/Jobs/DrawerReview.d.ts +7 -0
- package/dist/views/Jobs/DrawerReview.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerReview.js +1 -1
- package/dist/views/Jobs/DrawerReview.js.map +1 -1
- package/dist/views/Jobs/JobDrawer.d.ts +26 -3
- package/dist/views/Jobs/JobDrawer.d.ts.map +1 -1
- package/dist/views/Jobs/JobDrawer.js +30 -5
- package/dist/views/Jobs/JobDrawer.js.map +1 -1
- package/dist/views/Jobs/JobsTable.d.ts +4 -2
- package/dist/views/Jobs/JobsTable.d.ts.map +1 -1
- package/dist/views/Jobs/JobsTable.js +6 -5
- package/dist/views/Jobs/JobsTable.js.map +1 -1
- package/dist/views/Jobs/NewBatchJob.d.ts +34 -0
- package/dist/views/Jobs/NewBatchJob.d.ts.map +1 -0
- package/dist/views/Jobs/NewBatchJob.js +282 -0
- package/dist/views/Jobs/NewBatchJob.js.map +1 -0
- package/dist/views/Jobs/RunWithAi.d.ts +25 -0
- package/dist/views/Jobs/RunWithAi.d.ts.map +1 -0
- package/dist/views/Jobs/RunWithAi.js +46 -0
- package/dist/views/Jobs/RunWithAi.js.map +1 -0
- package/dist/views/Jobs/WorkerStrip.d.ts +3 -1
- package/dist/views/Jobs/WorkerStrip.d.ts.map +1 -1
- package/dist/views/Jobs/WorkerStrip.js +2 -2
- package/dist/views/Jobs/WorkerStrip.js.map +1 -1
- package/dist/views/Jobs/focus.d.ts +6 -0
- package/dist/views/Jobs/focus.d.ts.map +1 -1
- package/dist/views/Jobs/focus.js +10 -0
- package/dist/views/Jobs/focus.js.map +1 -1
- package/dist/views/Jobs.d.ts +14 -3
- package/dist/views/Jobs.d.ts.map +1 -1
- package/dist/views/Jobs.js +144 -32
- package/dist/views/Jobs.js.map +1 -1
- package/dist/views/MediaBrowser.d.ts +5 -1
- package/dist/views/MediaBrowser.d.ts.map +1 -1
- package/dist/views/MediaBrowser.js +6 -2
- package/dist/views/MediaBrowser.js.map +1 -1
- package/dist/views/Pages/PagesListView.d.ts +5 -1
- package/dist/views/Pages/PagesListView.d.ts.map +1 -1
- package/dist/views/Pages/PagesListView.js +7 -4
- package/dist/views/Pages/PagesListView.js.map +1 -1
- package/dist/views/Posts/PostsListView.d.ts +5 -1
- package/dist/views/Posts/PostsListView.d.ts.map +1 -1
- package/dist/views/Posts/PostsListView.js +7 -4
- package/dist/views/Posts/PostsListView.js.map +1 -1
- package/dist/views/header-footer/AnnouncementTab.d.ts +15 -0
- package/dist/views/header-footer/AnnouncementTab.d.ts.map +1 -0
- package/dist/views/header-footer/AnnouncementTab.js +43 -0
- package/dist/views/header-footer/AnnouncementTab.js.map +1 -0
- package/dist/views/header-footer/ChromeField.d.ts +25 -0
- package/dist/views/header-footer/ChromeField.d.ts.map +1 -0
- package/dist/views/header-footer/ChromeField.js +99 -0
- package/dist/views/header-footer/ChromeField.js.map +1 -0
- package/dist/views/header-footer/ChromePreview.d.ts +31 -0
- package/dist/views/header-footer/ChromePreview.d.ts.map +1 -0
- package/dist/views/header-footer/ChromePreview.js +195 -0
- package/dist/views/header-footer/ChromePreview.js.map +1 -0
- package/dist/views/header-footer/DeveloperTab.d.ts +17 -0
- package/dist/views/header-footer/DeveloperTab.d.ts.map +1 -0
- package/dist/views/header-footer/DeveloperTab.js +98 -0
- package/dist/views/header-footer/DeveloperTab.js.map +1 -0
- package/dist/views/header-footer/RegionTab.d.ts +27 -0
- package/dist/views/header-footer/RegionTab.d.ts.map +1 -0
- package/dist/views/header-footer/RegionTab.js +80 -0
- package/dist/views/header-footer/RegionTab.js.map +1 -0
- package/dist/views/header-footer/chrome-form.d.ts +137 -0
- package/dist/views/header-footer/chrome-form.d.ts.map +1 -0
- package/dist/views/header-footer/chrome-form.js +518 -0
- package/dist/views/header-footer/chrome-form.js.map +1 -0
- package/dist/views/header-footer/code-samples.d.ts +30 -0
- package/dist/views/header-footer/code-samples.d.ts.map +1 -0
- package/dist/views/header-footer/code-samples.js +127 -0
- package/dist/views/header-footer/code-samples.js.map +1 -0
- package/dist/views/header-footer/controls.d.ts +57 -0
- package/dist/views/header-footer/controls.d.ts.map +1 -0
- package/dist/views/header-footer/controls.js +43 -0
- package/dist/views/header-footer/controls.js.map +1 -0
- package/package.json +3 -3
- package/src/AdminRoot.tsx +36 -6
- package/src/__tests__/components/batch-ai-actions.test.tsx +10 -0
- package/src/__tests__/lib/batch-wizard.test.ts +325 -0
- package/src/__tests__/lib/job-drawer.test.ts +2 -0
- package/src/__tests__/lib/job-view.test.ts +123 -2
- package/src/__tests__/lib/jobs-service.test.ts +92 -3
- package/src/__tests__/views/appearance-chrome.render.test.tsx +818 -0
- package/src/__tests__/views/header-footer-form.test.ts +333 -0
- package/src/__tests__/views/jobs-drawer.render.test.tsx +508 -2
- package/src/__tests__/views/jobs-list.render.test.tsx +8 -5
- package/src/__tests__/views/jobs-wizard.render.test.tsx +707 -0
- package/src/__tests__/views/run-with-ai.render.test.tsx +807 -0
- package/src/components/BatchAiActions.tsx +15 -2
- package/src/lib/api.ts +12 -1
- package/src/lib/batch-wizard.ts +313 -0
- package/src/lib/chrome-service.ts +200 -0
- package/src/lib/job-view.ts +95 -1
- package/src/lib/jobs-service.ts +92 -1
- package/src/styles/prenta-tokens.css +17 -0
- package/src/styles/theme.css +15 -0
- package/src/views/AppearanceChrome.tsx +704 -46
- package/src/views/CollectionList.tsx +20 -1
- package/src/views/Jobs/CancelJobDialog.tsx +20 -2
- package/src/views/Jobs/DrawerOverview.tsx +16 -3
- package/src/views/Jobs/DrawerResults.tsx +71 -2
- package/src/views/Jobs/DrawerReview.tsx +1 -1
- package/src/views/Jobs/JobDrawer.tsx +88 -4
- package/src/views/Jobs/JobsTable.tsx +11 -4
- package/src/views/Jobs/NewBatchJob.tsx +857 -0
- package/src/views/Jobs/RunWithAi.tsx +89 -0
- package/src/views/Jobs/WorkerStrip.tsx +16 -11
- package/src/views/Jobs/focus.ts +11 -0
- package/src/views/Jobs.tsx +212 -50
- package/src/views/MediaBrowser.tsx +20 -1
- package/src/views/Pages/PagesListView.tsx +28 -3
- package/src/views/Posts/PostsListView.tsx +26 -3
- package/src/views/header-footer/AnnouncementTab.tsx +231 -0
- package/src/views/header-footer/ChromeField.tsx +358 -0
- package/src/views/header-footer/ChromePreview.tsx +497 -0
- package/src/views/header-footer/DeveloperTab.tsx +331 -0
- package/src/views/header-footer/RegionTab.tsx +398 -0
- package/src/views/header-footer/chrome-form.ts +603 -0
- package/src/views/header-footer/code-samples.ts +146 -0
- package/src/views/header-footer/controls.tsx +166 -0
- package/dist/views/Jobs/placeholders.d.ts +0 -6
- package/dist/views/Jobs/placeholders.d.ts.map +0 -1
- package/dist/views/Jobs/placeholders.js +0 -20
- package/dist/views/Jobs/placeholders.js.map +0 -1
- package/src/views/Jobs/placeholders.tsx +0 -66
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
batchRequest,
|
|
4
|
+
batchSources,
|
|
5
|
+
estimateKey,
|
|
6
|
+
estimateNote,
|
|
7
|
+
estimateTiles,
|
|
8
|
+
fixWithAiPick,
|
|
9
|
+
fixWithAiText,
|
|
10
|
+
instructionError,
|
|
11
|
+
isAdminRole,
|
|
12
|
+
matchProblem,
|
|
13
|
+
operationFits,
|
|
14
|
+
pickedDocuments,
|
|
15
|
+
pickedImages,
|
|
16
|
+
previewKey,
|
|
17
|
+
type BatchDraft,
|
|
18
|
+
} from '../../lib/batch-wizard.js'
|
|
19
|
+
import type { SeoBatchTarget } from '../../lib/jobs-service.js'
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* The batch wizard's rules (P-20), against cms-core `jobs/batch-ai.ts`:
|
|
23
|
+
* which collections it offers, who may apply automatically, what it sends,
|
|
24
|
+
* and the estimate's wording.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function draft(overrides: Partial<BatchDraft> = {}): BatchDraft {
|
|
28
|
+
return {
|
|
29
|
+
operation: 'meta',
|
|
30
|
+
instruction: '',
|
|
31
|
+
field: 'metaDescription',
|
|
32
|
+
collection: 'posts',
|
|
33
|
+
statusFilter: 'published',
|
|
34
|
+
review: 'review',
|
|
35
|
+
onApprove: 'draft',
|
|
36
|
+
selection: null,
|
|
37
|
+
...overrides,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const estimate = (count: number, pct: number | null = 4) => ({
|
|
42
|
+
count,
|
|
43
|
+
sample: [],
|
|
44
|
+
tokens: count * 900,
|
|
45
|
+
minutes: count,
|
|
46
|
+
pctOfMonthlyLimit: pct,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
describe('batchSources', () => {
|
|
50
|
+
it('lists page and post collections in config order, without hidden ones', () => {
|
|
51
|
+
expect(
|
|
52
|
+
batchSources({
|
|
53
|
+
collections: {
|
|
54
|
+
blog: { slug: 'blog', type: 'post', labels: { plural: 'Blog' } },
|
|
55
|
+
navigations: { slug: 'navigations', labels: { plural: 'Menus' } },
|
|
56
|
+
pages: { slug: 'pages', type: 'page', labels: { plural: 'Pages' } },
|
|
57
|
+
'page-tags': { slug: 'page-tags', type: 'post', admin: { hidden: true } },
|
|
58
|
+
news: { slug: 'news', type: 'post' },
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
).toEqual([
|
|
62
|
+
{ id: 'blog', label: 'Blog' },
|
|
63
|
+
{ id: 'pages', label: 'Pages' },
|
|
64
|
+
{ id: 'news', label: 'News' },
|
|
65
|
+
])
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('reads an array of collections, and copes with no config', () => {
|
|
69
|
+
expect(batchSources({ collections: [{ slug: 'posts', type: 'post' }] })).toEqual([
|
|
70
|
+
{ id: 'posts', label: 'Posts' },
|
|
71
|
+
])
|
|
72
|
+
expect(batchSources(undefined)).toEqual([])
|
|
73
|
+
expect(batchSources({})).toEqual([])
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
describe('isAdminRole', () => {
|
|
78
|
+
it('is OWNER and ADMIN, as the server checks', () => {
|
|
79
|
+
expect(['OWNER', 'ADMIN', 'EDITOR', 'AUTHOR', 'VIEWER', undefined].map(isAdminRole)).toEqual([
|
|
80
|
+
true,
|
|
81
|
+
true,
|
|
82
|
+
false,
|
|
83
|
+
false,
|
|
84
|
+
false,
|
|
85
|
+
false,
|
|
86
|
+
])
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe('instructionError', () => {
|
|
91
|
+
it('needs more than 8 characters for a custom instruction only', () => {
|
|
92
|
+
expect(instructionError('custom', ' 12345678 ')).toBe(
|
|
93
|
+
'A custom instruction needs more than 8 characters.',
|
|
94
|
+
)
|
|
95
|
+
expect(instructionError('custom', '123456789')).toBeNull()
|
|
96
|
+
expect(instructionError('meta', '')).toBeNull()
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('operationFits', () => {
|
|
101
|
+
it('runs alt text on picked images only, and the rest on picked documents', () => {
|
|
102
|
+
const images = { source: 'media', documentIds: ['m1'] }
|
|
103
|
+
const posts = { source: 'posts', documentIds: ['p1'] }
|
|
104
|
+
expect(operationFits('alt', images)).toBe(true)
|
|
105
|
+
expect(operationFits('meta', images)).toBe(false)
|
|
106
|
+
expect(operationFits('alt', posts)).toBe(false)
|
|
107
|
+
expect(operationFits('links', posts)).toBe(true)
|
|
108
|
+
expect(operationFits('alt', null)).toBe(true)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe('batchRequest', () => {
|
|
113
|
+
it('sends the kit fields, with no field or filter unless needed', () => {
|
|
114
|
+
expect(batchRequest(draft({ instruction: ' Plain and specific. ' }))).toEqual({
|
|
115
|
+
operation: 'meta',
|
|
116
|
+
source: 'posts',
|
|
117
|
+
statusFilter: 'published',
|
|
118
|
+
review: 'review',
|
|
119
|
+
onApprove: 'draft',
|
|
120
|
+
instruction: 'Plain and specific.',
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('runs alt text on the media library', () => {
|
|
125
|
+
expect(batchRequest(draft({ operation: 'alt' })).source).toBe('media')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('sends the field a custom instruction rewrites', () => {
|
|
129
|
+
expect(
|
|
130
|
+
batchRequest(draft({ operation: 'custom', instruction: 'Translate it.', field: 'seoTitle' })),
|
|
131
|
+
).toMatchObject({ operation: 'custom', field: 'seoTitle', instruction: 'Translate it.' })
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('never publishes when applying automatically', () => {
|
|
135
|
+
expect(batchRequest(draft({ review: 'auto', onApprove: 'publish' }))).toMatchObject({
|
|
136
|
+
review: 'auto',
|
|
137
|
+
onApprove: 'draft',
|
|
138
|
+
})
|
|
139
|
+
expect(batchRequest(draft({ onApprove: 'publish' })).onApprove).toBe('publish')
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('sends picked documents from their own source', () => {
|
|
143
|
+
expect(
|
|
144
|
+
batchRequest(draft({ selection: { source: 'pages', documentIds: ['a', 'b'] } })),
|
|
145
|
+
).toMatchObject({ source: 'pages', filter: { documentIds: ['a', 'b'] } })
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
describe('estimateKey and previewKey', () => {
|
|
150
|
+
it('counts again only for what changes the matches', () => {
|
|
151
|
+
const base = batchRequest(draft())
|
|
152
|
+
expect(estimateKey(batchRequest(draft({ review: 'auto' })))).toBe(estimateKey(base))
|
|
153
|
+
expect(estimateKey(batchRequest(draft({ instruction: 'Shorter.' })))).toBe(estimateKey(base))
|
|
154
|
+
expect(estimateKey(batchRequest(draft({ statusFilter: 'all' })))).not.toBe(estimateKey(base))
|
|
155
|
+
expect(estimateKey(batchRequest(draft({ collection: 'pages' })))).not.toBe(estimateKey(base))
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('previews again when the instruction or field changes', () => {
|
|
159
|
+
const base = batchRequest(draft({ operation: 'custom', instruction: 'Translate it.' }))
|
|
160
|
+
expect(
|
|
161
|
+
previewKey(batchRequest(draft({ operation: 'custom', instruction: 'Translate it!' }))),
|
|
162
|
+
).not.toBe(previewKey(base))
|
|
163
|
+
expect(
|
|
164
|
+
previewKey(
|
|
165
|
+
batchRequest(
|
|
166
|
+
draft({ operation: 'custom', instruction: 'Translate it.', field: 'excerpt' }),
|
|
167
|
+
),
|
|
168
|
+
),
|
|
169
|
+
).not.toBe(previewKey(base))
|
|
170
|
+
expect(
|
|
171
|
+
previewKey(
|
|
172
|
+
batchRequest(draft({ operation: 'custom', instruction: 'Translate it.', review: 'auto' })),
|
|
173
|
+
),
|
|
174
|
+
).toBe(previewKey(base))
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
describe('the estimate', () => {
|
|
179
|
+
it('rounds as the kit does', () => {
|
|
180
|
+
expect(estimateTiles(estimate(42))).toEqual({ minutes: '~42 min', tokens: '~38k tokens' })
|
|
181
|
+
expect(estimateTiles(estimate(1000))).toEqual({
|
|
182
|
+
minutes: '~1,000 min',
|
|
183
|
+
tokens: '~900k tokens',
|
|
184
|
+
})
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('gives the share of the monthly limit, when there is one', () => {
|
|
188
|
+
expect(estimateNote(estimate(42))).toBe(
|
|
189
|
+
'One document per slice, about one a minute. That’s 4% of this month’s AI limit.',
|
|
190
|
+
)
|
|
191
|
+
expect(estimateNote(estimate(2, 0))).toBe(
|
|
192
|
+
'One document per slice, about one a minute. That’s under 1% of this month’s AI limit.',
|
|
193
|
+
)
|
|
194
|
+
expect(estimateNote(estimate(42, null))).toBe('One document per slice, about one a minute.')
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('stops a batch of none, or of more than 1,000', () => {
|
|
198
|
+
expect(matchProblem(estimate(0))).toBe('No documents match this filter.')
|
|
199
|
+
expect(matchProblem(estimate(1000))).toBeNull()
|
|
200
|
+
expect(matchProblem(estimate(1001))).toBe(
|
|
201
|
+
'This matches 1,001 documents. Narrow it to 1,000 or fewer.',
|
|
202
|
+
)
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
describe('a list’s picked documents (P-21)', () => {
|
|
207
|
+
it('runs picked posts of one type as one batch', () => {
|
|
208
|
+
expect(
|
|
209
|
+
pickedDocuments([
|
|
210
|
+
{ collection: 'articles', id: 'a1' },
|
|
211
|
+
{ collection: 'articles', id: 'a2' },
|
|
212
|
+
]),
|
|
213
|
+
).toEqual({ selection: { source: 'articles', documentIds: ['a1', 'a2'] }, reason: null })
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it('holds posts of two types, or none, and says why', () => {
|
|
217
|
+
const why = 'Run with AI works on one post type at a time. Pick posts of a single type.'
|
|
218
|
+
expect(
|
|
219
|
+
pickedDocuments([
|
|
220
|
+
{ collection: 'articles', id: 'a1' },
|
|
221
|
+
{ collection: 'news', id: 'n1' },
|
|
222
|
+
]),
|
|
223
|
+
).toEqual({ selection: null, reason: why })
|
|
224
|
+
expect(pickedDocuments([])).toEqual({ selection: null, reason: why })
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
it('runs picked images on the media library, and holds a pick with none', () => {
|
|
228
|
+
expect(pickedImages(['m1', 'm2'])).toEqual({
|
|
229
|
+
selection: { source: 'media', documentIds: ['m1', 'm2'] },
|
|
230
|
+
reason: null,
|
|
231
|
+
})
|
|
232
|
+
expect(pickedImages([])).toEqual({
|
|
233
|
+
selection: null,
|
|
234
|
+
reason: 'Run with AI writes alt text for images. Pick at least one image.',
|
|
235
|
+
})
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('holds a pick of more than 400, which the estimate can’t carry in its URL', () => {
|
|
239
|
+
const docs = (n: number) =>
|
|
240
|
+
Array.from({ length: n }, (_, i) => ({ collection: 'pages', id: `p${i}` }))
|
|
241
|
+
expect(pickedDocuments(docs(400)).selection?.documentIds).toHaveLength(400)
|
|
242
|
+
expect(pickedDocuments(docs(401))).toEqual({
|
|
243
|
+
selection: null,
|
|
244
|
+
reason: 'Run with AI takes at most 400 documents at a time. Pick fewer.',
|
|
245
|
+
})
|
|
246
|
+
const images = Array.from({ length: 401 }, (_, i) => `m${i}`)
|
|
247
|
+
expect(pickedImages(images)).toEqual({
|
|
248
|
+
selection: null,
|
|
249
|
+
reason: 'Run with AI takes at most 400 images at a time. Pick fewer.',
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
describe('Fix with AI (P-21)', () => {
|
|
255
|
+
function target(
|
|
256
|
+
type: string,
|
|
257
|
+
sources: Array<[string, number, number?]>,
|
|
258
|
+
over: Partial<SeoBatchTarget> = {},
|
|
259
|
+
): SeoBatchTarget {
|
|
260
|
+
return {
|
|
261
|
+
type,
|
|
262
|
+
operation: 'meta',
|
|
263
|
+
autopilot: false,
|
|
264
|
+
sources: sources.map(([source, n, total]) => ({
|
|
265
|
+
source,
|
|
266
|
+
documentIds: Array.from({ length: n }, (_, i) => `${source}-${i}`),
|
|
267
|
+
total: total ?? n,
|
|
268
|
+
})),
|
|
269
|
+
waiting: 0,
|
|
270
|
+
...over,
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const label = (id: string) => ({ pages: 'Pages', posts: 'Posts' })[id] ?? id
|
|
274
|
+
|
|
275
|
+
it('picks the first category, so the largest, with documents and not left to autopilot', () => {
|
|
276
|
+
const categories = [
|
|
277
|
+
{ key: 'thin-content' },
|
|
278
|
+
{ key: 'missing-meta-description' },
|
|
279
|
+
{ key: 'meta-description-length' },
|
|
280
|
+
]
|
|
281
|
+
const meta = target('missing-meta-description', [['pages', 5]])
|
|
282
|
+
const long = target('meta-description-length', [['pages', 1]])
|
|
283
|
+
expect(fixWithAiPick(categories, [long, meta])).toBe(meta)
|
|
284
|
+
expect(fixWithAiPick(categories, [{ ...meta, autopilot: true }, long])).toBe(long)
|
|
285
|
+
expect(fixWithAiPick(categories, [target('missing-meta-description', []), long])).toBe(long)
|
|
286
|
+
expect(fixWithAiPick([{ key: 'thin-content' }], [meta])).toBeNull()
|
|
287
|
+
expect(fixWithAiPick(categories, [])).toBeNull()
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
it('reads as the kit for one content type', () => {
|
|
291
|
+
expect(fixWithAiText(target('missing-meta-description', [['pages', 5]]), label)).toBe(
|
|
292
|
+
'Start a batch job for the 5 missing meta descriptions. You’ll review each one before it’s applied.',
|
|
293
|
+
)
|
|
294
|
+
expect(fixWithAiText(target('missing-meta-description', [['pages', 1]]), label)).toBe(
|
|
295
|
+
'Start a batch job for the 1 missing meta description. You’ll review each one before it’s applied.',
|
|
296
|
+
)
|
|
297
|
+
expect(fixWithAiText(target('meta-description-length', [['pages', 3]]), label)).toBe(
|
|
298
|
+
'Start a batch job to shorten the 3 meta descriptions that are too long. You’ll review each one before it’s applied.',
|
|
299
|
+
)
|
|
300
|
+
expect(fixWithAiText(target('meta-description-length', [['posts', 1]]), label)).toBe(
|
|
301
|
+
'Start a batch job to shorten the 1 meta description that is too long. You’ll review each one before it’s applied.',
|
|
302
|
+
)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('names each content type, the cap, and the documents already waiting', () => {
|
|
306
|
+
expect(
|
|
307
|
+
fixWithAiText(
|
|
308
|
+
target(
|
|
309
|
+
'missing-meta-description',
|
|
310
|
+
[
|
|
311
|
+
['pages', 400, 1203],
|
|
312
|
+
['posts', 2],
|
|
313
|
+
],
|
|
314
|
+
{ waiting: 3 },
|
|
315
|
+
),
|
|
316
|
+
label,
|
|
317
|
+
),
|
|
318
|
+
).toBe(
|
|
319
|
+
'Start a batch job for the 1,205 missing meta descriptions: 1,203 in Pages and 2 in Posts. A batch runs on one content type, so there’s one to set up for each. A batch takes 400 at most, so it starts with the most recently found. 3 others already have a suggestion waiting. You’ll review each one before it’s applied.',
|
|
320
|
+
)
|
|
321
|
+
expect(
|
|
322
|
+
fixWithAiText(target('missing-meta-description', [['pages', 2]], { waiting: 1 }), label),
|
|
323
|
+
).toContain('1 other already has a suggestion waiting.')
|
|
324
|
+
})
|
|
325
|
+
})
|
|
@@ -2,17 +2,22 @@ import { describe, expect, it } from 'vitest'
|
|
|
2
2
|
import type { Job, JobWorkerStatus } from '@prenta/core'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
canActOnJobs,
|
|
6
|
+
canRetryJob,
|
|
5
7
|
countJobs,
|
|
6
8
|
formatCreated,
|
|
7
9
|
formatDuration,
|
|
8
10
|
formatNextRun,
|
|
9
11
|
formatSince,
|
|
10
12
|
hasReviewAction,
|
|
13
|
+
jobActions,
|
|
11
14
|
matchJob,
|
|
15
|
+
retryPoint,
|
|
12
16
|
scheduleLabel,
|
|
13
17
|
toJobRows,
|
|
14
18
|
view,
|
|
15
19
|
type JobRow,
|
|
20
|
+
type JobViewer,
|
|
16
21
|
} from '../../lib/job-view.js'
|
|
17
22
|
|
|
18
23
|
function row(overrides: Partial<JobRow>): JobRow {
|
|
@@ -35,8 +40,10 @@ function row(overrides: Partial<JobRow>): JobRow {
|
|
|
35
40
|
pending: 0,
|
|
36
41
|
items: false,
|
|
37
42
|
review: null,
|
|
43
|
+
adminRetry: false,
|
|
38
44
|
took: null,
|
|
39
45
|
by: 'Brandon West',
|
|
46
|
+
byId: null,
|
|
40
47
|
created: 'now',
|
|
41
48
|
...overrides,
|
|
42
49
|
}
|
|
@@ -386,11 +393,125 @@ describe('toJobRows()', () => {
|
|
|
386
393
|
review: null,
|
|
387
394
|
created: 'Today 12:00',
|
|
388
395
|
})
|
|
389
|
-
expect(cron).toMatchObject({ cancelledBy: 'Dana Cole', by: 'Dana Cole' })
|
|
390
|
-
expect(nightly).toMatchObject({ by: 'Nightly cron', created: 'Yesterday 12:00' })
|
|
396
|
+
expect(cron).toMatchObject({ cancelledBy: 'Dana Cole', by: 'Dana Cole', byId: 'u2' })
|
|
397
|
+
expect(nightly).toMatchObject({ by: 'Nightly cron', byId: null, created: 'Yesterday 12:00' })
|
|
391
398
|
expect(review).toMatchObject({ pending: 2, items: true })
|
|
392
399
|
expect(review && view(review).l).toBe('Needs review')
|
|
393
400
|
})
|
|
401
|
+
|
|
402
|
+
it('counts a batch that hasn’t started by its frozen documents', () => {
|
|
403
|
+
const fresh = (type: string, ids: string[]) =>
|
|
404
|
+
apiJob({
|
|
405
|
+
type,
|
|
406
|
+
progress: { done: 0, total: 0, unit: 'documents', cursor: null, completed: 0 },
|
|
407
|
+
payload: { ...(apiJob({}).payload as object), documentIds: ids } as Job['payload'],
|
|
408
|
+
})
|
|
409
|
+
const [batch, scan, started] = toJobRows(
|
|
410
|
+
[
|
|
411
|
+
fresh('batch-ai', ['a', 'b', 'c']),
|
|
412
|
+
fresh('seo-scan', ['a']),
|
|
413
|
+
apiJob({ progress: { done: 2, total: 5, unit: 'documents', cursor: '2', completed: 2 } }),
|
|
414
|
+
],
|
|
415
|
+
NOW,
|
|
416
|
+
null,
|
|
417
|
+
)
|
|
418
|
+
expect([batch?.total, scan?.total, started?.total]).toEqual([3, 0, 5])
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
it('makes only a stored "Apply automatically" admin-only to retry, as cms-core does', () => {
|
|
422
|
+
const batch = (review: 'review' | 'auto', origin?: 'ai-batch') =>
|
|
423
|
+
apiJob({
|
|
424
|
+
payload: {
|
|
425
|
+
...(apiJob({}).payload as object),
|
|
426
|
+
review,
|
|
427
|
+
...(origin ? { origin } : {}),
|
|
428
|
+
} as Job['payload'],
|
|
429
|
+
})
|
|
430
|
+
const [review, auto, bulk] = toJobRows(
|
|
431
|
+
[batch('review'), batch('auto'), batch('auto', 'ai-batch')],
|
|
432
|
+
NOW,
|
|
433
|
+
null,
|
|
434
|
+
)
|
|
435
|
+
expect([review?.adminRetry, auto?.adminRetry, bulk?.adminRetry]).toEqual([false, true, false])
|
|
436
|
+
// The bulk action still reads as applying directly, for the cancel copy.
|
|
437
|
+
expect(bulk?.review).toBe('auto')
|
|
438
|
+
})
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
const as = (role: string | null, userId: string | null = 'u1'): JobViewer => ({ role, userId })
|
|
442
|
+
|
|
443
|
+
describe('job actions (P-19)', () => {
|
|
444
|
+
it('lets the roles core calls writers run and cancel, and nobody else', () => {
|
|
445
|
+
for (const role of ['OWNER', 'ADMIN', 'EDITOR', 'AUTHOR', 'editor'])
|
|
446
|
+
expect(canActOnJobs(as(role))).toBe(true)
|
|
447
|
+
for (const role of ['VIEWER', 'CLIENT', 'SOMETHING_NEW', null])
|
|
448
|
+
expect(canActOnJobs(as(role))).toBe(false)
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
it('retries a batch for an admin, or for the editor who queued it unless it was "Apply automatically"', () => {
|
|
452
|
+
const mine = row({ review: 'review', byId: 'u1' })
|
|
453
|
+
const theirs = row({ review: 'review', byId: 'u2' })
|
|
454
|
+
const auto = row({ review: 'auto', adminRetry: true, byId: 'u1' })
|
|
455
|
+
// A list's bulk action (`/ai/batch`): it applies directly, but any editor may queue it.
|
|
456
|
+
const legacy = row({ review: 'auto', adminRetry: false, byId: 'u1' })
|
|
457
|
+
const scan = row({ type: 'seo-scan', review: null, byId: null })
|
|
458
|
+
expect([mine, theirs, auto, legacy, scan].map((j) => canRetryJob(j, as('ADMIN')))).toEqual([
|
|
459
|
+
true,
|
|
460
|
+
true,
|
|
461
|
+
true,
|
|
462
|
+
true,
|
|
463
|
+
true,
|
|
464
|
+
])
|
|
465
|
+
expect([mine, theirs, auto, legacy, scan].map((j) => canRetryJob(j, as('EDITOR')))).toEqual([
|
|
466
|
+
true,
|
|
467
|
+
false,
|
|
468
|
+
false,
|
|
469
|
+
true,
|
|
470
|
+
true,
|
|
471
|
+
])
|
|
472
|
+
expect(canRetryJob(mine, as('VIEWER'))).toBe(false)
|
|
473
|
+
expect(canRetryJob(row({ byId: null }), as('EDITOR', null))).toBe(false)
|
|
474
|
+
})
|
|
475
|
+
|
|
476
|
+
it('offers the drawer footer’s actions per state (jobs-drawer.jsx `.jd-f`)', () => {
|
|
477
|
+
const admin = as('ADMIN')
|
|
478
|
+
const actions = (overrides: Partial<JobRow>) => jobActions(row(overrides), admin)
|
|
479
|
+
expect(actions({ state: 'running' })).toEqual({ cancel: true, retry: false, retryNow: false })
|
|
480
|
+
expect(actions({ state: 'running', cancelling: true })).toEqual({
|
|
481
|
+
cancel: false,
|
|
482
|
+
retry: false,
|
|
483
|
+
retryNow: false,
|
|
484
|
+
})
|
|
485
|
+
expect(actions({ state: 'queued', error: 'Boom' })).toEqual({
|
|
486
|
+
cancel: true,
|
|
487
|
+
retry: false,
|
|
488
|
+
retryNow: true,
|
|
489
|
+
})
|
|
490
|
+
// A retry clears a cancel, so a cancelling job doesn't offer it.
|
|
491
|
+
expect(actions({ state: 'queued', error: 'Boom', cancelling: true }).retryNow).toBe(false)
|
|
492
|
+
// A stale lock: the server still holds it as running and would refuse a retry.
|
|
493
|
+
expect(
|
|
494
|
+
actions({ state: 'queued', status: 'running', error: 'Worker stopped mid-slice' }),
|
|
495
|
+
).toEqual({ cancel: true, retry: false, retryNow: false })
|
|
496
|
+
expect(actions({ state: 'dead', error: 'Boom' })).toEqual({
|
|
497
|
+
cancel: false,
|
|
498
|
+
retry: true,
|
|
499
|
+
retryNow: false,
|
|
500
|
+
})
|
|
501
|
+
for (const state of ['succeeded', 'cancelled'] as const)
|
|
502
|
+
expect(actions({ state })).toEqual({ cancel: false, retry: false, retryNow: false })
|
|
503
|
+
expect(jobActions(row({ state: 'dead' }), as('VIEWER'))).toEqual({
|
|
504
|
+
cancel: false,
|
|
505
|
+
retry: false,
|
|
506
|
+
retryNow: false,
|
|
507
|
+
})
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
it('says where a retry picks up, in pages for an SEO scan', () => {
|
|
511
|
+
expect(retryPoint({ type: 'batch-ai', done: 7 })).toBe('document 8')
|
|
512
|
+
expect(retryPoint({ type: 'content-health', done: 0 })).toBe('document 1')
|
|
513
|
+
expect(retryPoint({ type: 'seo-scan', done: 100 })).toBe('page 101')
|
|
514
|
+
})
|
|
394
515
|
})
|
|
395
516
|
|
|
396
517
|
describe('formatting', () => {
|
|
@@ -3,17 +3,87 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
3
3
|
/*
|
|
4
4
|
* The drawer's calls in the Jobs service: the review page query, the
|
|
5
5
|
* decision envelope's `documentStatus` and `notice`, and reading why a
|
|
6
|
-
* decision was refused.
|
|
6
|
+
* decision was refused. And the batch wizard's: estimate, preview, create.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const cmsApi = vi.hoisted(() => vi.fn())
|
|
10
10
|
vi.mock('../../lib/api.js', () => ({ cmsApi, getApiBase: () => '/api/cms' }))
|
|
11
11
|
|
|
12
|
-
const {
|
|
13
|
-
|
|
12
|
+
const {
|
|
13
|
+
createBatchAiJob,
|
|
14
|
+
listSeoBatchTargets,
|
|
15
|
+
decideReviewItem,
|
|
16
|
+
estimateBatchAi,
|
|
17
|
+
listReviewItems,
|
|
18
|
+
previewBatchAi,
|
|
19
|
+
reviewConflict,
|
|
20
|
+
} = await import('../../lib/jobs-service.js')
|
|
14
21
|
|
|
15
22
|
beforeEach(() => cmsApi.mockReset())
|
|
16
23
|
|
|
24
|
+
describe('batch AI', () => {
|
|
25
|
+
const request = {
|
|
26
|
+
operation: 'custom' as const,
|
|
27
|
+
source: 'posts',
|
|
28
|
+
statusFilter: 'all' as const,
|
|
29
|
+
review: 'review' as const,
|
|
30
|
+
onApprove: 'draft' as const,
|
|
31
|
+
instruction: 'Translate it & keep names',
|
|
32
|
+
field: 'excerpt' as const,
|
|
33
|
+
filter: { documentIds: ['a', 'b'] },
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
it('estimates with the request as the query, ids comma-separated', async () => {
|
|
37
|
+
const value = { count: 2, sample: [], tokens: 1800, minutes: 2, pctOfMonthlyLimit: null }
|
|
38
|
+
cmsApi.mockResolvedValue({ data: value, status: 200 })
|
|
39
|
+
expect(await estimateBatchAi(request)).toEqual({ ok: true, value })
|
|
40
|
+
const [endpoint] = cmsApi.mock.calls[0]!
|
|
41
|
+
expect(endpoint).toBe(
|
|
42
|
+
'/jobs/batch-ai/estimate?operation=custom&source=posts&statusFilter=all&field=excerpt&instruction=Translate+it+%26+keep+names&documentIds=a%2Cb',
|
|
43
|
+
)
|
|
44
|
+
cmsApi.mockClear()
|
|
45
|
+
await estimateBatchAi({
|
|
46
|
+
...request,
|
|
47
|
+
operation: 'meta',
|
|
48
|
+
field: undefined,
|
|
49
|
+
instruction: null,
|
|
50
|
+
filter: undefined,
|
|
51
|
+
})
|
|
52
|
+
expect(cmsApi.mock.calls[0]![0]).toBe(
|
|
53
|
+
'/jobs/batch-ai/estimate?operation=meta&source=posts&statusFilter=all',
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('previews with a POST, reading the items', async () => {
|
|
58
|
+
const items = [{ documentId: 'a', title: 'A', after: 'New text.' }]
|
|
59
|
+
cmsApi.mockResolvedValue({ data: { items }, status: 200 })
|
|
60
|
+
expect(await previewBatchAi(request)).toEqual({ ok: true, value: items })
|
|
61
|
+
expect(cmsApi.mock.calls[0]![0]).toBe('/jobs/batch-ai/preview')
|
|
62
|
+
expect(cmsApi.mock.calls[0]![1]).toMatchObject({
|
|
63
|
+
method: 'POST',
|
|
64
|
+
body: JSON.stringify(request),
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('passes a spent cap on', async () => {
|
|
69
|
+
cmsApi.mockResolvedValue({ error: 'AI limit reached', status: 429 })
|
|
70
|
+
expect(await previewBatchAi(request)).toEqual({
|
|
71
|
+
ok: false,
|
|
72
|
+
error: 'AI limit reached',
|
|
73
|
+
status: 429,
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('creates with a POST and returns the job', async () => {
|
|
78
|
+
cmsApi.mockResolvedValue({ data: { id: 'job_420' }, status: 201 })
|
|
79
|
+
expect(await createBatchAiJob(request)).toEqual({ ok: true, value: { id: 'job_420' } })
|
|
80
|
+
expect(cmsApi).toHaveBeenCalledWith('/jobs/batch-ai', {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
body: JSON.stringify(request),
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
17
87
|
describe('listReviewItems', () => {
|
|
18
88
|
it('asks for 20 at a time, from a cursor', async () => {
|
|
19
89
|
cmsApi.mockResolvedValue({ data: { items: [], nextCursor: null }, status: 200 })
|
|
@@ -96,3 +166,22 @@ describe('reviewConflict', () => {
|
|
|
96
166
|
expect(reviewConflict(400, 'This change was already decided.')).toBeNull()
|
|
97
167
|
})
|
|
98
168
|
})
|
|
169
|
+
|
|
170
|
+
describe('listSeoBatchTargets', () => {
|
|
171
|
+
it('reads the targets for Fix with AI, or the server’s refusal', async () => {
|
|
172
|
+
const targets = [
|
|
173
|
+
{
|
|
174
|
+
type: 'missing-meta-description',
|
|
175
|
+
operation: 'meta',
|
|
176
|
+
autopilot: false,
|
|
177
|
+
sources: [{ source: 'pages', documentIds: ['p1'], total: 1 }],
|
|
178
|
+
waiting: 0,
|
|
179
|
+
},
|
|
180
|
+
]
|
|
181
|
+
cmsApi.mockResolvedValue({ data: { targets }, status: 200 })
|
|
182
|
+
expect(await listSeoBatchTargets()).toEqual({ ok: true, value: targets })
|
|
183
|
+
expect(cmsApi.mock.calls[0]![0]).toBe('/seo/issues/batch-targets')
|
|
184
|
+
cmsApi.mockResolvedValue({ error: 'Unauthorized', status: 401 })
|
|
185
|
+
expect(await listSeoBatchTargets()).toEqual({ ok: false, error: 'Unauthorized', status: 401 })
|
|
186
|
+
})
|
|
187
|
+
})
|