@designcrowd/library.brand-page 6.2.9 → 6.2.10
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/lib/src/{CreatedOnBrandCrowd-de-de-9uC6t5HU.js → CreatedOnBrandCrowd-de-de-CTEj6D-p.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-P6TzcklZ.js → CreatedOnBrandCrowd-en-us-ByFNuMoA.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-DimkGb1_.js → CreatedOnBrandCrowd-es-es-lA_3mWIj.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CL_iFuJw.js → CreatedOnBrandCrowd-fr-ca-CS_YkUz3.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-CL_iFuJw.js → CreatedOnBrandCrowd-fr-fr-CS_YkUz3.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-DSIjEoMv.js → CreatedOnBrandCrowd-pt-br-BoduQ7zJ.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-DSIjEoMv.js → CreatedOnBrandCrowd-pt-pt-BoduQ7zJ.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-CKRvl9Ky.js → CreatedOnDcom-de-de-Co1OO4_u.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-ChplPDfS.js → CreatedOnDcom-en-us-DqFyqxOJ.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-DCIXsW9X.js → CreatedOnDcom-es-es-DhQWyb7C.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-lakt1nLU.js → CreatedOnDcom-fr-ca-DIxstLTf.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-RsGK1y5g.js → CreatedOnDcom-fr-fr-B-z8V1cH.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-DyA4XodM.js → CreatedOnDcom-pt-br-B7AMR1sc.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-BK51dTyw.js → CreatedOnDcom-pt-pt-Cdci4yr3.js} +1 -1
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +7 -5
- package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.js +5 -0
- package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/components/seo-settings/UseExistingDomainModal.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/components/upgrade-to-premium-button/UpgradeToPremiumButton.mixin.d.ts +6 -5
- package/lib/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.d.ts +7 -6
- package/lib/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.js +52 -5
- package/lib/src/css/library.brand-page-brandCrowd.min.css +1 -1
- package/lib/src/css/library.brand-page-brandPage.min.css +1 -1
- package/lib/src/css/library.brand-page-designCom.min.css +1 -1
- package/lib/src/css/library.brand-page-preview.min.css +1 -1
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-Ca7GMpcR.js → lib-Y-hakSU_.js} +265 -233
- package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +6 -5
- package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +6 -5
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +6 -5
- package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +6 -5
- package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +6 -5
- package/lib/src/shared/side-bar/components/SideBar.mixin.d.ts +6 -5
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +6 -5
- package/package.json +1 -1
- package/src/brand-page-maker/components/brandpage-settings/BrandPageSettings.test.ts +323 -0
- package/src/brand-page-maker/components/brandpage-settings/BrandPageSettings.vue +3 -3
- package/src/brand-page-maker/components/sensitive-content/SensitiveContent.vue +23 -3
- package/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.ts +5 -0
- package/src/brand-page-maker/components/seo-settings/SeoPageSettings.vue +2 -0
- package/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.save.test.ts +332 -1
- package/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.ts +83 -5
package/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.save.test.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { describe, test, expect, beforeEach, vi } from 'vitest';
|
|
2
2
|
import { createPinia, setActivePinia } from 'pinia';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useBrandPageContainerStore,
|
|
5
|
+
useBrandPageMakerStore,
|
|
6
|
+
} from '@brand-page-maker/stores';
|
|
7
|
+
import { SENSITIVE_CONTENT_TYPES } from '@brand-page';
|
|
4
8
|
import brandPageClient from '../../../clients/brand-page-client';
|
|
5
9
|
|
|
6
10
|
vi.mock('../../../clients/brand-page-client', () => ({
|
|
7
11
|
default: {
|
|
8
12
|
saveBrandPageAsync: vi.fn(),
|
|
13
|
+
updateBrandPageMetaAsync: vi.fn(),
|
|
14
|
+
updateSensitiveContentAsync: vi.fn(),
|
|
9
15
|
},
|
|
10
16
|
}));
|
|
11
17
|
|
|
@@ -16,6 +22,40 @@ const SAVED = {
|
|
|
16
22
|
canPublish: true,
|
|
17
23
|
};
|
|
18
24
|
|
|
25
|
+
// Both settings writes share `saveSiteBeforeFirstSettingsWrite`; run each
|
|
26
|
+
// never-saved-site scenario over both so a guard dropped from one write
|
|
27
|
+
// method still fails.
|
|
28
|
+
const settingsActions: [
|
|
29
|
+
string,
|
|
30
|
+
(store: ReturnType<typeof useBrandPageContainerStore>) => Promise<void>,
|
|
31
|
+
ReturnType<typeof vi.fn>,
|
|
32
|
+
Record<string, unknown>,
|
|
33
|
+
][] = [
|
|
34
|
+
[
|
|
35
|
+
'updateBrandPageSettings',
|
|
36
|
+
(store) =>
|
|
37
|
+
store.updateBrandPageSettings({
|
|
38
|
+
description: 'New description',
|
|
39
|
+
title: 'New title',
|
|
40
|
+
}),
|
|
41
|
+
vi.mocked(brandPageClient.updateBrandPageMetaAsync),
|
|
42
|
+
{
|
|
43
|
+
pageTitle: 'New title',
|
|
44
|
+
pageDescription: 'New description',
|
|
45
|
+
metaKeywords: [],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
'updateSensitiveContent',
|
|
50
|
+
(store) =>
|
|
51
|
+
store.updateSensitiveContent({
|
|
52
|
+
sensitiveContent: SENSITIVE_CONTENT_TYPES.plus18,
|
|
53
|
+
}),
|
|
54
|
+
vi.mocked(brandPageClient.updateSensitiveContentAsync),
|
|
55
|
+
{ sensitiveContentType: SENSITIVE_CONTENT_TYPES.plus18 },
|
|
56
|
+
],
|
|
57
|
+
];
|
|
58
|
+
|
|
19
59
|
describe('brand-page-container-store saveBrandPage', () => {
|
|
20
60
|
let store: ReturnType<typeof useBrandPageContainerStore>;
|
|
21
61
|
|
|
@@ -104,3 +144,294 @@ describe('brand-page-container-store saveBrandPage', () => {
|
|
|
104
144
|
expect(requestBody()).toMatchObject({ shouldPublish: true });
|
|
105
145
|
});
|
|
106
146
|
});
|
|
147
|
+
|
|
148
|
+
describe('settings on a never-saved site', () => {
|
|
149
|
+
let store: ReturnType<typeof useBrandPageContainerStore>;
|
|
150
|
+
let brandPageMakerStore: ReturnType<typeof useBrandPageMakerStore>;
|
|
151
|
+
|
|
152
|
+
beforeEach(() => {
|
|
153
|
+
vi.clearAllMocks();
|
|
154
|
+
setActivePinia(createPinia());
|
|
155
|
+
|
|
156
|
+
store = useBrandPageContainerStore();
|
|
157
|
+
brandPageMakerStore = useBrandPageMakerStore();
|
|
158
|
+
|
|
159
|
+
// The export is exercised by its own tests; stub it so these cover only the
|
|
160
|
+
// settings-write sequencing.
|
|
161
|
+
vi.spyOn(store, 'exportDesignAsync').mockResolvedValue({} as any);
|
|
162
|
+
|
|
163
|
+
// Real timers inside showNextNotificationMessage would make every test wait
|
|
164
|
+
// out the message-visible duration and dequeue the very message these tests
|
|
165
|
+
// assert on, so only its own invocation is observed here.
|
|
166
|
+
vi.spyOn(
|
|
167
|
+
brandPageMakerStore,
|
|
168
|
+
'showNextNotificationMessage',
|
|
169
|
+
).mockResolvedValue(undefined);
|
|
170
|
+
|
|
171
|
+
vi.mocked(brandPageClient.updateBrandPageMetaAsync).mockResolvedValue({
|
|
172
|
+
pageTitle: 'New title',
|
|
173
|
+
pageDescription: 'New description',
|
|
174
|
+
} as any);
|
|
175
|
+
|
|
176
|
+
vi.mocked(brandPageClient.updateSensitiveContentAsync).mockResolvedValue({
|
|
177
|
+
sensitiveContentType: SENSITIVE_CONTENT_TYPES.plus18,
|
|
178
|
+
} as any);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe('a saved site', () => {
|
|
182
|
+
beforeEach(() => {
|
|
183
|
+
store.designDraftToken = 'draft-123';
|
|
184
|
+
store.brandPageStatus = 'Published';
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Once a token exists — whether from an earlier save or the host's, mid-
|
|
188
|
+
// session — a pre-purchase site writes directly, the same as any other
|
|
189
|
+
// saved site.
|
|
190
|
+
test('saved site writes only the setting', async () => {
|
|
191
|
+
store.isPrePurchase = true;
|
|
192
|
+
|
|
193
|
+
const dispatchSpy = vi.spyOn(window, 'dispatchEvent');
|
|
194
|
+
|
|
195
|
+
await store.updateSensitiveContent({
|
|
196
|
+
sensitiveContent: SENSITIVE_CONTENT_TYPES.plus18,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
expect(
|
|
200
|
+
brandPageClient.updateSensitiveContentAsync,
|
|
201
|
+
).toHaveBeenCalledOnce();
|
|
202
|
+
expect(brandPageClient.updateSensitiveContentAsync).toHaveBeenCalledWith(
|
|
203
|
+
expect.anything(),
|
|
204
|
+
'draft-123',
|
|
205
|
+
expect.objectContaining({
|
|
206
|
+
sensitiveContentType: SENSITIVE_CONTENT_TYPES.plus18,
|
|
207
|
+
}),
|
|
208
|
+
);
|
|
209
|
+
expect(brandPageClient.saveBrandPageAsync).not.toHaveBeenCalled();
|
|
210
|
+
expect(dispatchSpy).not.toHaveBeenCalled();
|
|
211
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(1);
|
|
212
|
+
expect(brandPageMakerStore.notificationMessageQueue[0].type).toBe(
|
|
213
|
+
'success',
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe('post-purchase, never saved', () => {
|
|
219
|
+
beforeEach(() => {
|
|
220
|
+
store.designDraftToken = undefined;
|
|
221
|
+
store.isPrePurchase = false;
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test.each(settingsActions)(
|
|
225
|
+
'saves the site first (%s)',
|
|
226
|
+
async (_name, callAction, endpoint, expectedPayload) => {
|
|
227
|
+
vi.mocked(brandPageClient.saveBrandPageAsync).mockResolvedValue(
|
|
228
|
+
SAVED as any,
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
await callAction(store);
|
|
232
|
+
|
|
233
|
+
expect(brandPageClient.saveBrandPageAsync).toHaveBeenCalledOnce();
|
|
234
|
+
|
|
235
|
+
const [, saveRequest, saveToken] = vi.mocked(
|
|
236
|
+
brandPageClient.saveBrandPageAsync,
|
|
237
|
+
).mock.calls[0];
|
|
238
|
+
|
|
239
|
+
expect(saveRequest).toMatchObject({ saveOnly: true });
|
|
240
|
+
expect(saveToken).toBeFalsy();
|
|
241
|
+
|
|
242
|
+
expect(endpoint).toHaveBeenCalledOnce();
|
|
243
|
+
expect(endpoint).toHaveBeenCalledWith(
|
|
244
|
+
expect.anything(),
|
|
245
|
+
'draft-123',
|
|
246
|
+
expect.objectContaining(expectedPayload),
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const saveOrder = vi.mocked(brandPageClient.saveBrandPageAsync).mock
|
|
250
|
+
.invocationCallOrder[0];
|
|
251
|
+
const writeOrder = endpoint.mock.invocationCallOrder[0];
|
|
252
|
+
|
|
253
|
+
expect(saveOrder).toBeLessThan(writeOrder);
|
|
254
|
+
|
|
255
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(1);
|
|
256
|
+
expect(brandPageMakerStore.notificationMessageQueue[0].type).toBe(
|
|
257
|
+
'success',
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// The save's own banner was disarmed — a later close must not raise it.
|
|
261
|
+
brandPageMakerStore.notificationMessageQueue.length = 0;
|
|
262
|
+
|
|
263
|
+
await store.closePublishModal();
|
|
264
|
+
await store.showSaveSuccessMessage();
|
|
265
|
+
|
|
266
|
+
expect(store.triggerSaveSuccessMessage).toBe(false);
|
|
267
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(0);
|
|
268
|
+
},
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
test.each([
|
|
272
|
+
[
|
|
273
|
+
'save throws',
|
|
274
|
+
(): void => {
|
|
275
|
+
vi.mocked(brandPageClient.saveBrandPageAsync).mockRejectedValue(
|
|
276
|
+
new Error('network'),
|
|
277
|
+
);
|
|
278
|
+
},
|
|
279
|
+
false,
|
|
280
|
+
],
|
|
281
|
+
[
|
|
282
|
+
'save returns nothing',
|
|
283
|
+
(): void => {
|
|
284
|
+
vi.mocked(brandPageClient.saveBrandPageAsync).mockResolvedValue(
|
|
285
|
+
null as any,
|
|
286
|
+
);
|
|
287
|
+
},
|
|
288
|
+
false,
|
|
289
|
+
],
|
|
290
|
+
[
|
|
291
|
+
'save ok, write returns nothing',
|
|
292
|
+
(): void => {
|
|
293
|
+
vi.mocked(brandPageClient.saveBrandPageAsync).mockResolvedValue(
|
|
294
|
+
SAVED as any,
|
|
295
|
+
);
|
|
296
|
+
vi.mocked(
|
|
297
|
+
brandPageClient.updateSensitiveContentAsync,
|
|
298
|
+
).mockResolvedValue(null as any);
|
|
299
|
+
},
|
|
300
|
+
true,
|
|
301
|
+
],
|
|
302
|
+
])(
|
|
303
|
+
'failed first save (%s)',
|
|
304
|
+
async (_case: string, setup: () => void, writeReached: boolean) => {
|
|
305
|
+
setup();
|
|
306
|
+
|
|
307
|
+
await store.updateSensitiveContent({
|
|
308
|
+
sensitiveContent: SENSITIVE_CONTENT_TYPES.plus18,
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(1);
|
|
312
|
+
expect(brandPageMakerStore.notificationMessageQueue[0].type).toBe(
|
|
313
|
+
'error',
|
|
314
|
+
);
|
|
315
|
+
expect(
|
|
316
|
+
brandPageMakerStore.showNextNotificationMessage,
|
|
317
|
+
).toHaveBeenCalled();
|
|
318
|
+
expect(store.isPublishing).toBe(false);
|
|
319
|
+
|
|
320
|
+
if (!writeReached) {
|
|
321
|
+
expect(
|
|
322
|
+
brandPageClient.updateSensitiveContentAsync,
|
|
323
|
+
).not.toHaveBeenCalled();
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe('pre-purchase, never saved', () => {
|
|
330
|
+
beforeEach(() => {
|
|
331
|
+
store.isPrePurchase = true;
|
|
332
|
+
store.designDraftToken = undefined;
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// No listener started a save, so isSaving never went true on the dispatch —
|
|
336
|
+
// the click would otherwise go silent.
|
|
337
|
+
test.each(settingsActions)(
|
|
338
|
+
'pre-purchase asks the host to save, no listener (%s)',
|
|
339
|
+
async (_name, callAction) => {
|
|
340
|
+
const dispatchSpy = vi.spyOn(window, 'dispatchEvent');
|
|
341
|
+
const setIsPublishingSpy = vi.spyOn(store, 'setIsPublishing');
|
|
342
|
+
|
|
343
|
+
await callAction(store);
|
|
344
|
+
|
|
345
|
+
expect(dispatchSpy).toHaveBeenCalledOnce();
|
|
346
|
+
expect((dispatchSpy.mock.calls[0][0] as Event).type).toBe(
|
|
347
|
+
'SAVE_PROGRESS_CLICKED',
|
|
348
|
+
);
|
|
349
|
+
expect(brandPageClient.saveBrandPageAsync).not.toHaveBeenCalled();
|
|
350
|
+
expect(
|
|
351
|
+
brandPageClient.updateSensitiveContentAsync,
|
|
352
|
+
).not.toHaveBeenCalled();
|
|
353
|
+
expect(brandPageClient.updateBrandPageMetaAsync).not.toHaveBeenCalled();
|
|
354
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(1);
|
|
355
|
+
expect(brandPageMakerStore.notificationMessageQueue[0].type).toBe(
|
|
356
|
+
'error',
|
|
357
|
+
);
|
|
358
|
+
expect(setIsPublishingSpy).not.toHaveBeenCalled();
|
|
359
|
+
},
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
// The host's saveDesign sets isSaving synchronously on the dispatch
|
|
363
|
+
// (MakerLeadCaptureModalContainer.vue), before its first await.
|
|
364
|
+
test.each(settingsActions)(
|
|
365
|
+
'pre-purchase asks the host to save, a listener starts a save (%s)',
|
|
366
|
+
async (_name, callAction) => {
|
|
367
|
+
const dispatchSpy = vi
|
|
368
|
+
.spyOn(window, 'dispatchEvent')
|
|
369
|
+
.mockImplementation((event: Event) => {
|
|
370
|
+
if (event.type === 'SAVE_PROGRESS_CLICKED') {
|
|
371
|
+
store.setIsSaving({ isSaving: true });
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return true;
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
await callAction(store);
|
|
378
|
+
|
|
379
|
+
expect(dispatchSpy).toHaveBeenCalledOnce();
|
|
380
|
+
expect(brandPageClient.saveBrandPageAsync).not.toHaveBeenCalled();
|
|
381
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(0);
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe('admin template editor, never saved', () => {
|
|
387
|
+
test.each(settingsActions)(
|
|
388
|
+
'admin never saves (%s)',
|
|
389
|
+
async (_name, callAction) => {
|
|
390
|
+
store.isAdminMaker = true;
|
|
391
|
+
store.designDraftToken = undefined;
|
|
392
|
+
|
|
393
|
+
await callAction(store);
|
|
394
|
+
|
|
395
|
+
expect(brandPageClient.saveBrandPageAsync).not.toHaveBeenCalled();
|
|
396
|
+
expect(
|
|
397
|
+
brandPageClient.updateSensitiveContentAsync,
|
|
398
|
+
).not.toHaveBeenCalled();
|
|
399
|
+
expect(brandPageClient.updateBrandPageMetaAsync).not.toHaveBeenCalled();
|
|
400
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(0);
|
|
401
|
+
},
|
|
402
|
+
);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test.each([
|
|
406
|
+
['a save already running', { isSaving: true }],
|
|
407
|
+
['a publish already running', { isPublishing: true }],
|
|
408
|
+
])(
|
|
409
|
+
'another save running (%s)',
|
|
410
|
+
async (_case: string, flags: Record<string, boolean>) => {
|
|
411
|
+
store.isPrePurchase = false;
|
|
412
|
+
store.designDraftToken = undefined;
|
|
413
|
+
Object.assign(store, flags);
|
|
414
|
+
|
|
415
|
+
const isPublishingBefore = store.isPublishing;
|
|
416
|
+
const setIsPublishingSpy = vi.spyOn(store, 'setIsPublishing');
|
|
417
|
+
|
|
418
|
+
await store.updateSensitiveContent({
|
|
419
|
+
sensitiveContent: SENSITIVE_CONTENT_TYPES.plus18,
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
expect(brandPageClient.saveBrandPageAsync).not.toHaveBeenCalled();
|
|
423
|
+
expect(
|
|
424
|
+
brandPageClient.updateSensitiveContentAsync,
|
|
425
|
+
).not.toHaveBeenCalled();
|
|
426
|
+
expect(store.isPublishing).toBe(isPublishingBefore);
|
|
427
|
+
expect(setIsPublishingSpy).not.toHaveBeenCalled();
|
|
428
|
+
expect(brandPageMakerStore.notificationMessageQueue).toHaveLength(1);
|
|
429
|
+
expect(brandPageMakerStore.notificationMessageQueue[0].type).toBe(
|
|
430
|
+
'error',
|
|
431
|
+
);
|
|
432
|
+
expect(
|
|
433
|
+
brandPageMakerStore.showNextNotificationMessage,
|
|
434
|
+
).toHaveBeenCalled();
|
|
435
|
+
},
|
|
436
|
+
);
|
|
437
|
+
});
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
getAbTestResults,
|
|
24
24
|
type AbTest,
|
|
25
25
|
type LogoContent,
|
|
26
|
+
type SensitiveContent,
|
|
26
27
|
} from '@brand-page';
|
|
27
28
|
import { isLogoContent } from '@brand-page/utils';
|
|
28
29
|
import { useUiEditableLogoStore } from '@shared/logo-settings/store';
|
|
@@ -1336,7 +1337,17 @@ export const useBrandPageContainerStore = defineStore('brandPageContainer', {
|
|
|
1336
1337
|
}
|
|
1337
1338
|
},
|
|
1338
1339
|
|
|
1339
|
-
async updateBrandPageSettings(
|
|
1340
|
+
async updateBrandPageSettings(payload: {
|
|
1341
|
+
description: string;
|
|
1342
|
+
title: string;
|
|
1343
|
+
}): Promise<void> {
|
|
1344
|
+
if (
|
|
1345
|
+
!this.designDraftToken &&
|
|
1346
|
+
!(await this.saveSiteBeforeFirstSettingsWrite())
|
|
1347
|
+
) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1340
1351
|
const brandPageMakerStore = useBrandPageMakerStore();
|
|
1341
1352
|
|
|
1342
1353
|
try {
|
|
@@ -1346,8 +1357,8 @@ export const useBrandPageContainerStore = defineStore('brandPageContainer', {
|
|
|
1346
1357
|
brandPageMakerStore.brandPageType,
|
|
1347
1358
|
this.designDraftToken,
|
|
1348
1359
|
{
|
|
1349
|
-
pageDescription: description,
|
|
1350
|
-
pageTitle: title,
|
|
1360
|
+
pageDescription: payload.description,
|
|
1361
|
+
pageTitle: payload.title,
|
|
1351
1362
|
metaKeywords: [],
|
|
1352
1363
|
},
|
|
1353
1364
|
);
|
|
@@ -1377,7 +1388,16 @@ export const useBrandPageContainerStore = defineStore('brandPageContainer', {
|
|
|
1377
1388
|
}
|
|
1378
1389
|
},
|
|
1379
1390
|
|
|
1380
|
-
async updateSensitiveContent(
|
|
1391
|
+
async updateSensitiveContent(payload: {
|
|
1392
|
+
sensitiveContent: SensitiveContent;
|
|
1393
|
+
}): Promise<void> {
|
|
1394
|
+
if (
|
|
1395
|
+
!this.designDraftToken &&
|
|
1396
|
+
!(await this.saveSiteBeforeFirstSettingsWrite())
|
|
1397
|
+
) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1381
1401
|
const brandPageMakerStore = useBrandPageMakerStore();
|
|
1382
1402
|
|
|
1383
1403
|
try {
|
|
@@ -1387,7 +1407,7 @@ export const useBrandPageContainerStore = defineStore('brandPageContainer', {
|
|
|
1387
1407
|
brandPageMakerStore.brandPageType,
|
|
1388
1408
|
this.designDraftToken,
|
|
1389
1409
|
{
|
|
1390
|
-
sensitiveContentType: sensitiveContent,
|
|
1410
|
+
sensitiveContentType: payload.sensitiveContent,
|
|
1391
1411
|
},
|
|
1392
1412
|
);
|
|
1393
1413
|
|
|
@@ -1416,6 +1436,64 @@ export const useBrandPageContainerStore = defineStore('brandPageContainer', {
|
|
|
1416
1436
|
}
|
|
1417
1437
|
},
|
|
1418
1438
|
|
|
1439
|
+
// Pre-purchase drafts are saved by the host, never the maker — save-publish.md.
|
|
1440
|
+
async saveSiteBeforeFirstSettingsWrite(): Promise<boolean> {
|
|
1441
|
+
if (this.isAdminMaker) {
|
|
1442
|
+
return false;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
const brandPageMakerStore = useBrandPageMakerStore();
|
|
1446
|
+
|
|
1447
|
+
if (this.isPrePurchase) {
|
|
1448
|
+
window.dispatchEvent(new Event('SAVE_PROGRESS_CLICKED'));
|
|
1449
|
+
|
|
1450
|
+
// The host's saveDesign sets isSaving synchronously on the dispatch; if it
|
|
1451
|
+
// didn't, no listener is wired and the click would otherwise go silent.
|
|
1452
|
+
if (!this.isSaving) {
|
|
1453
|
+
await brandPageMakerStore.enqueueErrorMessage();
|
|
1454
|
+
await brandPageMakerStore.showNextNotificationMessage();
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
return false;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
if (this.isSaving || this.isPublishing) {
|
|
1461
|
+
await brandPageMakerStore.enqueueErrorMessage();
|
|
1462
|
+
await brandPageMakerStore.showNextNotificationMessage();
|
|
1463
|
+
|
|
1464
|
+
return false;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
this.setIsPublishing({ isPublishing: true });
|
|
1468
|
+
|
|
1469
|
+
// saveBrandPage enqueues its own error on a throw but not on an empty response.
|
|
1470
|
+
const messagesBeforeSave = [
|
|
1471
|
+
...brandPageMakerStore.notificationMessageQueue,
|
|
1472
|
+
];
|
|
1473
|
+
const result = await this.saveBrandPage({ saveOnly: true });
|
|
1474
|
+
|
|
1475
|
+
if (!result || !result.saved) {
|
|
1476
|
+
const hasErrorQueued =
|
|
1477
|
+
brandPageMakerStore.notificationMessageQueue.some(
|
|
1478
|
+
(message) =>
|
|
1479
|
+
message.type === 'error' && !messagesBeforeSave.includes(message),
|
|
1480
|
+
);
|
|
1481
|
+
|
|
1482
|
+
if (!hasErrorQueued) {
|
|
1483
|
+
await brandPageMakerStore.enqueueErrorMessage();
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
this.setIsPublishing({ isPublishing: false });
|
|
1487
|
+
await brandPageMakerStore.showNextNotificationMessage();
|
|
1488
|
+
|
|
1489
|
+
return false;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
this.setTriggerSaveSuccessMessage({ triggerSaveSuccessMessage: false });
|
|
1493
|
+
|
|
1494
|
+
return true;
|
|
1495
|
+
},
|
|
1496
|
+
|
|
1419
1497
|
async createBrandPageCustomDomain({ domainName }) {
|
|
1420
1498
|
const brandPageMakerStore = useBrandPageMakerStore();
|
|
1421
1499
|
|