@capillarytech/creatives-library 9.1.7-alpha.sprint-bee-free-load-fix.35 → 9.1.7

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/AppRoot.js CHANGED
@@ -14,7 +14,6 @@ import { translationMessages } from './i18n';
14
14
  import initialState from './initialState';
15
15
  import pathConfig from './config/path';
16
16
  import { isMFEMode } from './utils/mfeDetect';
17
- import { loadBeePlugin } from './utils/beePluginLoader';
18
17
  import { emitFirstPaintReadyIfNotDataLanding } from './utils/mfeFirstPaintReady';
19
18
  import rebaseHistory from './utils/mfeHistory';
20
19
  import { MFEEventBus } from '@capillarytech/cap-ui-utils';
@@ -87,10 +86,14 @@ const AppRoot = ({ basename: _basename = '/creatives/ui', history: hostHistory }
87
86
  }
88
87
  }, []);
89
88
 
90
- // Preload BeePlugin.js in MFE mode (host index.html lacks it); the editors also load it on demand
89
+ // In MFE mode the HOST's index.html is served, not creatives' — so BeePlugin.js
90
+ // (declared in creatives/index.html) is never loaded. Inject it here so BeeEditor works.
91
91
  useEffect(() => {
92
- if (isMFEMode()) {
93
- loadBeePlugin().catch(() => {});
92
+ if (isMFEMode() && !window.BeePlugin && !document.querySelector('script[src*="BeePlugin.js"]')) {
93
+ const script = document.createElement('script');
94
+ script.src = 'https://app-rsrc.getbee.io/plugin/BeePlugin.js';
95
+ script.type = 'text/javascript';
96
+ document.head.appendChild(script);
94
97
  }
95
98
  }, []);
96
99
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "9.1.7-alpha.sprint-bee-free-load-fix.35",
4
+ "version": "9.1.7",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -343,9 +343,13 @@ export const getTemplateDetails = async ({id, channel}) => {
343
343
  return { ...compressedTemplatesData, response: decompressData};
344
344
  };
345
345
 
346
- export const getDomainProperties = (channels, orgUnitId) => {
346
+ // When `priority` is supplied (e.g. CapNotify passes 'HIGH'), fetch priority-scoped domains instead.
347
+ export const getDomainProperties = (channels, orgUnitId, priority) => {
347
348
  const queryString = channels?.map((channel) => `channel=${channel?.toUpperCase()}`)?.join('&');
348
- const url = `${CAMPAIGNS_API_ORG_ENDPOINT}/meta/domainProperties?${queryString}`;
349
+ const path = priority
350
+ ? `domainPropertiesByPriority?${queryString}&priority=${priority}`
351
+ : `domainProperties?${queryString}`;
352
+ const url = `${CAMPAIGNS_API_ORG_ENDPOINT}/meta/${path}`;
349
353
  return request(url, getAPICallObject('GET', null, false, true, orgUnitId));
350
354
  };
351
355
 
@@ -64,6 +64,30 @@ describe('getDomainProperties -- Test with valid responses', () => {
64
64
  });
65
65
  });
66
66
 
67
+ describe('getDomainProperties -- endpoint selection', () => {
68
+ const originalFetch = global.fetch;
69
+ beforeEach(() => {
70
+ global.fetch = jest.fn(() => Promise.resolve({ status: 200, json: () => Promise.resolve({}) }));
71
+ });
72
+ afterEach(() => {
73
+ global.fetch = originalFetch;
74
+ });
75
+
76
+ it('calls domainProperties when no priority is given', () => {
77
+ getDomainProperties(['sms', 'EMAIL'], null);
78
+ const [url] = global.fetch.mock.calls[0];
79
+ expect(url).toContain('/meta/domainProperties?channel=SMS&channel=EMAIL&time=');
80
+ expect(url).not.toContain('domainPropertiesByPriority');
81
+ expect(url).not.toContain('priority=');
82
+ });
83
+
84
+ it('calls domainPropertiesByPriority with the priority param when priority is given', () => {
85
+ getDomainProperties(['EMAIL'], null, 'HIGH');
86
+ const [url] = global.fetch.mock.calls[0];
87
+ expect(url).toContain('/meta/domainPropertiesByPriority?channel=EMAIL&priority=HIGH&time=');
88
+ });
89
+ });
90
+
67
91
  describe('getCdnTransformationConfigs -- Test with valid responses', () => {
68
92
  it('Should return correct response', () =>
69
93
  expect(getCdnTransformationConfig()).toEqual(Promise.resolve()));
@@ -19,10 +19,7 @@ import CapInput from "@capillarytech/cap-ui-library/CapInput";
19
19
  import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
20
20
  import CapSpin from "@capillarytech/cap-ui-library/CapSpin";
21
21
  import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
22
- import CapError from "@capillarytech/cap-ui-library/CapError";
23
- import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
24
22
  import config from '../../config/app';
25
- import { destroyBeeInstance, initBeeEditor } from '../../utils/beePluginLoader';
26
23
  import makeSelectBEE from './selectors';
27
24
  import messages from './messages';
28
25
  import * as beeActions from './actions';
@@ -78,9 +75,6 @@ function BeeEditor(props) {
78
75
  const [rowMetaInfo, setRowMetaInfo] = useState({});
79
76
  const [rowName, setRowName] = useState('');
80
77
  const [rowCategory, setRowCategory] = useState('');
81
- const [isBeePluginLoading, setIsBeePluginLoading] = useState(false);
82
- const [hasBeePluginLoadError, setHasBeePluginLoadError] = useState(false);
83
- const [beePluginLoadAttempt, setBeePluginLoadAttempt] = useState(0);
84
78
  const beePluginInstanceRef = useRef(null);
85
79
  const initializedBeeJsonRef = useRef(null); // Track which beeJson we've initialized for
86
80
  const isInitializingRef = useRef(false); // Track if initialization is in progress
@@ -256,48 +250,41 @@ function BeeEditor(props) {
256
250
 
257
251
  // Clean up previous instance if it exists
258
252
  if (beePluginInstanceRef.current) {
259
- destroyBeeInstance(beePluginInstanceRef.current);
253
+ try {
254
+ beePluginInstanceRef.current.destroy();
255
+ } catch (e) {
256
+ console.warn('[BeeEditor] useEffect - Error destroying previous BEE plugin:', e);
257
+ }
260
258
  beePluginInstanceRef.current = null;
261
259
  }
262
260
 
263
- let isEffectCancelled = false;
264
- setHasBeePluginLoadError(false);
265
- setIsBeePluginLoading(!window.BeePlugin);
266
- initBeeEditor({
267
- tokenData: currentTokenData,
268
- beeConfig,
269
- getBeeJson: () => beeJson,
270
- isCancelled: () => isEffectCancelled,
271
- onPluginLoaded: () => setIsBeePluginLoading(false),
272
- })
273
- .then((instance) => {
274
- if (!instance) {
275
- return;
276
- }
261
+ try {
262
+ window.BeePlugin.create(currentTokenData, beeConfig, (instance) => {
277
263
  beePluginInstance = instance;
278
264
  beePluginInstanceRef.current = instance;
265
+ const parseJson = typeof beeJson === 'string' ? JSON.parse(beeJson) : beeJson;
266
+ beePluginInstance.start(parseJson);
279
267
  saveBeeInstance(beePluginInstance);
280
268
  // Mark this beeJson as initialized and clear initialization flag
281
269
  initializedBeeJsonRef.current = initializationKey;
282
270
  isInitializingRef.current = false;
283
- })
284
- .catch((error) => {
285
- if (isEffectCancelled) {
286
- return;
287
- }
288
- console.error('[BeeEditor] Error creating BEE plugin:', error);
289
- setIsBeePluginLoading(false);
290
- setHasBeePluginLoadError(true);
291
- isInitializingRef.current = false;
292
271
  });
272
+ } catch (error) {
273
+ // Reset flag on error
274
+ console.error('[BeeEditor] Error creating BEE plugin:', error);
275
+ isInitializingRef.current = false;
276
+ }
293
277
  return () => {
294
- isEffectCancelled = true;
295
278
  clearInterval(intervalTimer);
296
279
  // Reset initialization flag on cleanup
297
280
  isInitializingRef.current = false;
298
281
  // Clean up BEE plugin instance if it exists
299
282
  if (beePluginInstanceRef.current) {
300
- destroyBeeInstance(beePluginInstanceRef.current);
283
+ try {
284
+ beePluginInstanceRef.current.destroy();
285
+ } catch (e) {
286
+ console.warn('[BeeEditor] useEffect cleanup - Error destroying BEE plugin:', e);
287
+ }
301
288
  beePluginInstanceRef.current = null;
302
289
  }
303
290
  // Note: We don't reset initializedBeeJsonRef here because:
@@ -306,12 +293,7 @@ function BeeEditor(props) {
306
293
  };
307
294
  // Only depend on beeJson, uid, and id - not tokenData
308
295
  // tokenData is accessed via ref to prevent re-initialization when it changes
309
- }, [beeJson, uid, id, beePluginLoadAttempt]);
310
-
311
- const onRetryBeePluginLoad = () => {
312
- setBeePluginLoadAttempt((attempt) => attempt + 1);
313
- };
314
-
296
+ }, [beeJson, uid, id]);
315
297
  const callbackSaveRow = (status, errorMsg) => {
316
298
  if (status === 'success') {
317
299
  CapNotification.success({message: formatMessage(messages.rowCreationSuccessMgs), key: 'create-custom-row-success'});
@@ -385,17 +367,8 @@ function BeeEditor(props) {
385
367
  </>
386
368
  );
387
369
  return (
388
- <CapSpin spinning={saveRowRequest || isBeePluginLoading}>
389
- {hasBeePluginLoadError ? (
390
- <CapColumn className="bee-plugin-load-error">
391
- <CapError type="error">{formatMessage(messages.beePluginLoadError)}</CapError>
392
- <CapButton type="secondary" onClick={onRetryBeePluginLoad}>
393
- {formatMessage(messages.retry)}
394
- </CapButton>
395
- </CapColumn>
396
- ) : (
397
- <CapColumn id="bee-plugin-container" className="bee-plugin-container" />
398
- )}
370
+ <CapSpin spinning={saveRowRequest || false}>
371
+ <div id="bee-plugin-container" style={{ height: "650px" }}></div>
399
372
  <TagList
400
373
  moduleFilterEnabled={moduleFilterEnabled}
401
374
  label={label}
@@ -1,15 +1,3 @@
1
- .bee-plugin-container {
2
- height: 40.625rem;
3
- }
4
-
5
- .bee-plugin-load-error {
6
- padding: 1.5rem 0;
7
-
8
- > * + * {
9
- margin-top: 1rem;
10
- }
11
- }
12
-
13
1
  .custom-row-modal {
14
2
  .ant-modal-footer {
15
3
  text-align: left;
@@ -64,12 +64,4 @@ export default defineMessages({
64
64
  id: `${prefix}.rowCreationFailureMgs`,
65
65
  defaultMessage: 'Error in row creation',
66
66
  },
67
- beePluginLoadError: {
68
- id: `${prefix}.beePluginLoadError`,
69
- defaultMessage: 'Unable to load the drag & drop editor. Check your network connection and try again.',
70
- },
71
- retry: {
72
- id: `${prefix}.retry`,
73
- defaultMessage: 'Retry',
74
- },
75
67
  });
@@ -6,7 +6,6 @@ import { connect } from 'react-redux';
6
6
  import { createStructuredSelector } from 'reselect';
7
7
  import CapRow from '@capillarytech/cap-ui-library/CapRow';
8
8
  import { UserIsAuthenticated } from '../../utils/authWrapper';
9
- import { initBeeEditor } from '../../utils/beePluginLoader';
10
9
  import TagList from '../TagList';
11
10
  import {
12
11
  ANDROID, BEE_LAYOUT_OPTIONS, MOBILE, UNSUBSCRIBE,
@@ -114,28 +113,18 @@ function BeePopupEditor(props) {
114
113
  saveBeeData(jsonFile, htmlFile, device);
115
114
  },
116
115
  };
117
- let isEffectCancelled = false;
118
- initBeeEditor({
119
- tokenData,
120
- beeConfig,
121
- // Read the ref at create time: the effect closure may hold stale beeJson when template data loads async
122
- getBeeJson: () => beeJsonRef.current,
123
- isCancelled: () => isEffectCancelled,
124
- })
125
- .then((instance) => {
126
- if (!instance) {
127
- return;
128
- }
129
- beePluginInstance = instance;
130
- beeInstanceRef.current = instance;
131
- saveBeeInstance(beePluginInstance, device);
132
- isInitializedRef.current = true;
133
- })
134
- .catch((error) => {
135
- console.error('[BeePopupEditor] Error creating BEE plugin:', error);
136
- });
116
+ window.BeePlugin.create(tokenData, beeConfig, (instance) => {
117
+ beePluginInstance = instance;
118
+ beeInstanceRef.current = instance;
119
+ // Use ref to get the latest beeJson — the closure captures the value at effect time,
120
+ // but beeJsonRef.current is always up-to-date (e.g. when template data loads async)
121
+ const latestBeeJson = beeJsonRef.current;
122
+ const parseJson = typeof latestBeeJson === 'string' ? JSON.parse(latestBeeJson) : latestBeeJson;
123
+ beePluginInstance.start(parseJson);
124
+ saveBeeInstance(beePluginInstance, device);
125
+ isInitializedRef.current = true;
126
+ });
137
127
  return () => {
138
- isEffectCancelled = true;
139
128
  clearInterval(intervalTimer);
140
129
  // Reset initialization flag when component unmounts or layout changes
141
130
  isInitializedRef.current = false;
@@ -491,6 +491,7 @@ const ChannelSelectionStep = ({
491
491
  onDeliverySettingChange={(deliverySetting) => onChange({ deliverySetting })}
492
492
  onDomainPropertiesLoaded={setDomainPropertiesData}
493
493
  orgUnitId={config?.context?.ouId}
494
+ domainPropertiesPriority={config?.context?.domainPropertiesPriority}
494
495
  intl={intl}
495
496
  />
496
497
  )}
@@ -37,6 +37,7 @@ const DeliverySettingsSection = ({
37
37
  onDeliverySettingChange,
38
38
  onDomainPropertiesLoaded,
39
39
  orgUnitId,
40
+ domainPropertiesPriority,
40
41
  intl,
41
42
  }) => {
42
43
  const [showSlidebox, setShowSlidebox] = useState(false);
@@ -119,7 +120,7 @@ const DeliverySettingsSection = ({
119
120
  // uses) so both screens fetch domains for the same org unit; fall back to the logged-in
120
121
  // user's own cached OU only when a consumer hasn't supplied one.
121
122
  const resolvedOrgUnitId = orgUnitId ?? (loadItem('ouId') || loadItem('orgID'));
122
- const response = await getDomainProperties(deliveryFetchChannels, resolvedOrgUnitId);
123
+ const response = await getDomainProperties(deliveryFetchChannels, resolvedOrgUnitId, domainPropertiesPriority);
123
124
  if (!cancelled) {
124
125
  const raw = response?.entity || response;
125
126
  // Normalize channel keys to uppercase (API may return Viber, viber, etc.)
@@ -365,6 +366,8 @@ DeliverySettingsSection.propTypes = {
365
366
  onDeliverySettingChange: PropTypes.func,
366
367
  onDomainPropertiesLoaded: PropTypes.func,
367
368
  orgUnitId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
369
+ // Consumer opt-in (config.context.domainPropertiesPriority) — switches to domainPropertiesByPriority.
370
+ domainPropertiesPriority: PropTypes.string,
368
371
  intl: PropTypes.object.isRequired,
369
372
  };
370
373
 
@@ -374,6 +377,7 @@ DeliverySettingsSection.defaultProps = {
374
377
  deliverySetting: null,
375
378
  onDeliverySettingChange: null,
376
379
  orgUnitId: undefined,
380
+ domainPropertiesPriority: undefined,
377
381
  };
378
382
 
379
383
  export default injectIntl(DeliverySettingsSection);
@@ -154,6 +154,7 @@ function renderSection(props = {}) {
154
154
  deliverySetting = {},
155
155
  onDeliverySettingChange,
156
156
  orgUnitId,
157
+ domainPropertiesPriority,
157
158
  } = props;
158
159
  return render(
159
160
  <IntlProvider locale="en" messages={{}} defaultLocale="en">
@@ -163,6 +164,7 @@ function renderSection(props = {}) {
163
164
  deliverySetting={deliverySetting}
164
165
  onDeliverySettingChange={onDeliverySettingChange}
165
166
  orgUnitId={orgUnitId}
167
+ domainPropertiesPriority={domainPropertiesPriority}
166
168
  />
167
169
  </IntlProvider>,
168
170
  );
@@ -298,7 +300,7 @@ describe('DeliverySettingsSection — marketer flows', () => {
298
300
 
299
301
  renderSection({ contentItems: [{ channel: 'SMS' }] });
300
302
 
301
- await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'fallback-org'));
303
+ await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'fallback-org', undefined));
302
304
  });
303
305
 
304
306
  it('prefers the consumer-supplied orgUnitId (config.context.ouId) over local storage — same source Preview-and-test uses, so both fetch the same org unit', async () => {
@@ -307,7 +309,24 @@ describe('DeliverySettingsSection — marketer flows', () => {
307
309
 
308
310
  renderSection({ contentItems: [{ channel: 'SMS' }], orgUnitId: 'consumer-ou' });
309
311
 
310
- await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou'));
312
+ await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou', undefined));
313
+ });
314
+
315
+ it('forwards the consumer-supplied domainPropertiesPriority (e.g. CapNotify HIGH) to the domain-properties fetch', async () => {
316
+ getDomainProperties.mockResolvedValue({ entity: apiEntity.SMS });
317
+
318
+ renderSection({ contentItems: [{ channel: 'SMS' }], orgUnitId: 'consumer-ou', domainPropertiesPriority: 'HIGH' });
319
+
320
+ await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou', 'HIGH'));
321
+ expect(await screen.findByText('+1002003001')).toBeInTheDocument();
322
+ });
323
+
324
+ it('does not pass a priority when the consumer has not opted in', async () => {
325
+ getDomainProperties.mockResolvedValue({ entity: apiEntity.SMS });
326
+
327
+ renderSection({ contentItems: [{ channel: 'SMS' }], orgUnitId: 'consumer-ou' });
328
+
329
+ await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou', undefined));
311
330
  });
312
331
 
313
332
  it('accepts the whole response as the entity when `entity` is omitted (some clients)', async () => {
@@ -611,7 +630,7 @@ describe('DeliverySettingsSection — marketer flows', () => {
611
630
 
612
631
  renderSection({ contentItems: [rcsWithFallbackContentItem] });
613
632
 
614
- await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS', 'SMS'], 'test-ou'));
633
+ await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS', 'SMS'], 'test-ou', undefined));
615
634
  });
616
635
 
617
636
  it('does not fetch SMS domains when the RCS content has no SMS-fallback content', async () => {
@@ -619,7 +638,7 @@ describe('DeliverySettingsSection — marketer flows', () => {
619
638
 
620
639
  renderSection({ contentItems: [{ channel: 'RCS' }] });
621
640
 
622
- await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS'], 'test-ou'));
641
+ await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS'], 'test-ou', undefined));
623
642
  });
624
643
 
625
644
  it('shows a "Fallback SMS sender ID" summary row sourced from the SMS domain default sender', async () => {
@@ -756,8 +756,6 @@ export function SlideBoxContent(props) {
756
756
  const isBEETemplate = templateData?.base?.is_drag_drop === true
757
757
  || templateData?.base?.is_drag_drop === 1;
758
758
  if (supportCKEditor || isBEETemplate) {
759
- // Host-supplied BEE content is the latest edit; fetching by _id would reload the original template over it
760
- const hasHostBEEContent = isBEETemplate && !isEmpty(templateData?.base?.json_content);
761
759
  return (
762
760
  <Email
763
761
  key="cretives-container-email-edit"
@@ -769,7 +767,7 @@ export function SlideBoxContent(props) {
769
767
  route={{ name: 'email' }}
770
768
  isGetFormData={isGetFormData}
771
769
  getFormdata={getFormData}
772
- params={{ id: hasHostBEEContent ? undefined : templateData._id }}
770
+ params={{ id: templateData._id }}
773
771
  templateData={templateData}
774
772
  getFormSubscriptionData={getFormData}
775
773
  getDefaultTags={type}
@@ -580,7 +580,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
580
580
  const beeJson = `BEEeditor${currentTab > 1 ? currentTab : ''}json`;
581
581
  const beeToken = `BEEeditor${currentTab > 1 ? currentTab : ''}token`;
582
582
  let beeJsonValue = '';
583
- const selectedId = _.get(nextProps, 'Email.templateDetails._id', '') || '';
583
+ const selectedId = _.get(this.props, 'Email.templateDetails._id', '') || '';
584
584
 
585
585
  // Get beeJsonValue from template data - check multiple sources
586
586
  // First check if it's already in formData (from setEditData)
@@ -637,7 +637,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
637
637
  is_drag_drop: true,
638
638
  [beeJson]: finalBeeJsonValue,
639
639
  [beeToken]: nextProps.Email.CmsSettings.tokenData,
640
- id: selectedId || existingFormData.id,
640
+ id: selectedId,
641
641
  // Also store json-content for reference
642
642
  'json-content': finalBeeJsonValue,
643
643
  };
@@ -83,8 +83,6 @@ const useEmailWrapper = ({
83
83
  pathname: `/email/create`,
84
84
  query: { module: 'library', type: 'embedded' },
85
85
  });
86
- // On create, `location` is the host app's route (e.g. a promotion /edit/:id URL), so it must not mark the email as an edit
87
- const routeLocation = isEditEmail ? location : undefined;
88
86
 
89
87
  // Cleanup effect
90
88
  useEffect(() => () => {
@@ -157,7 +155,7 @@ const useEmailWrapper = ({
157
155
  }
158
156
 
159
157
  // Check if we're in edit mode (need to check BEE status for editor selection)
160
- const hasParamsId = params?.id || routeLocation?.query?.id || routeLocation?.params?.id || routeLocation?.pathname?.includes('/edit/');
158
+ const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
161
159
  const isEditMode = hasParamsId;
162
160
 
163
161
  // Only check BEE enabled status for new flow (when supportCKEditor is false)
@@ -175,7 +173,7 @@ const useEmailWrapper = ({
175
173
  // Make API call to check BEE enabled status using new endpoint
176
174
  emailActions.getCmsAccounts('BEE_PLUGIN');
177
175
  }
178
- }, [currentStep, emailActions, params?.id, routeLocation?.query?.id, routeLocation?.params?.id, routeLocation?.pathname]);
176
+ }, [currentStep, emailActions, params?.id, location?.query?.id, location?.params?.id, location?.pathname]);
179
177
 
180
178
  // Effect to update isBeeEditorEnabled based on new API response
181
179
  // This effect watches for isBeeEnabled from the new API response
@@ -207,23 +205,23 @@ const useEmailWrapper = ({
207
205
  if (!isEditEmail) {
208
206
  return;
209
207
  }
210
- const hasParamsId = params?.id || routeLocation?.query?.id || routeLocation?.params?.id || routeLocation?.pathname?.includes('/edit/');
208
+ const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
211
209
  const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
212
210
  const hasTemplateDataProp = templateData && !isEmpty(templateData);
213
211
  const isTemplateLoading = Email?.getTemplateDetailsInProgress;
214
212
 
215
213
  // Only fetch if we have an ID, don't have template data yet, and not already loading
216
214
  if (hasParamsId && !hasTemplateDetails && !hasTemplateDataProp && !isTemplateLoading && emailActions?.getTemplateDetails) {
217
- let templateId = params?.id || routeLocation?.query?.id || routeLocation?.params?.id;
218
- if (!templateId && routeLocation?.pathname?.includes('/edit/')) {
219
- const [, extractedId] = routeLocation.pathname.match(/\/edit\/([^/]+)/) || [];
215
+ let templateId = params?.id || location?.query?.id || location?.params?.id;
216
+ if (!templateId && location?.pathname?.includes('/edit/')) {
217
+ const [, extractedId] = location.pathname.match(/\/edit\/([^/]+)/) || [];
220
218
  if (extractedId) templateId = extractedId;
221
219
  }
222
220
  if (templateId) {
223
221
  emailActions.getTemplateDetails(templateId, 'email');
224
222
  }
225
223
  }
226
- }, [isEditEmail, params?.id, routeLocation?.query?.id, routeLocation?.params?.id, routeLocation?.pathname, Email?.templateDetails, Email?.getTemplateDetailsInProgress, templateData, emailActions]);
224
+ }, [isEditEmail, params?.id, location?.query?.id, location?.params?.id, location?.pathname, Email?.templateDetails, Email?.getTemplateDetailsInProgress, templateData, emailActions]);
227
225
 
228
226
  // Effect to set BEETemplate when template details are loaded for BEE templates
229
227
  // This ensures Email component can properly initialize BEE editor
@@ -281,9 +279,9 @@ const useEmailWrapper = ({
281
279
  const isBEEAppEnable = checkBeeEditorEnabled();
282
280
  // Check if we're in edit mode - check multiple sources for id
283
281
  const hasParamsId = params?.id
284
- || routeLocation?.query?.id
285
- || routeLocation?.params?.id
286
- || (routeLocation?.pathname && routeLocation.pathname.includes('/edit/'));
282
+ || location?.query?.id
283
+ || location?.params?.id
284
+ || (location?.pathname && location.pathname.includes('/edit/'));
287
285
  const cmsMode = hasParamsId ? 'open' : 'create';
288
286
  // Extract langId from active tab
289
287
  const activeTabForLang = get(editTemplateData, 'versions.base.activeTab', 'en');
@@ -548,9 +546,9 @@ const useEmailWrapper = ({
548
546
  useEffect(() => {
549
547
  // If templateData is cleared/null and we're not in edit mode, reset selectedCreateMode
550
548
  const hasParamsId = params?.id
551
- || routeLocation?.query?.id
552
- || routeLocation?.params?.id
553
- || routeLocation?.pathname?.includes('/edit/');
549
+ || location?.query?.id
550
+ || location?.params?.id
551
+ || location?.pathname?.includes('/edit/');
554
552
  const hasTemplateData = templateData && !isEmpty(templateData);
555
553
  const isEditMode = hasParamsId || hasTemplateData;
556
554
 
@@ -563,7 +561,7 @@ const useEmailWrapper = ({
563
561
  // This preserves user selection while in content creation
564
562
  setSelectedCreateMode('');
565
563
  }
566
- }, [templateData, params?.id, routeLocation?.query?.id, routeLocation?.params?.id, routeLocation?.pathname, selectedCreateMode, templateName, currentStep, emailCreateMode]);
564
+ }, [templateData, params?.id, location?.query?.id, location?.params?.id, location?.pathname, selectedCreateMode, templateName, currentStep, emailCreateMode]);
567
565
 
568
566
  // Derived state
569
567
  const supportCKEditorFlag = hasSupportCKEditor();
@@ -591,7 +589,7 @@ const useEmailWrapper = ({
591
589
  // Check if we're editing an existing template
592
590
  // CRITICAL: Only treat as edit mode if we have params.id (actual edit URL) or templateData prop
593
591
  // Don't use templateDetails existence alone, as it might persist from previous template
594
- const hasParamsId = params?.id || routeLocation?.query?.id || routeLocation?.params?.id || routeLocation?.pathname?.includes('/edit/');
592
+ const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
595
593
  const hasTemplateDataProp = templateData && !isEmpty(templateData);
596
594
  // CRITICAL: Consider it edit mode if we have params.id OR templateData prop (library mode)
597
595
  // This allows editor type determination even when template data is still loading
@@ -708,13 +706,13 @@ const useEmailWrapper = ({
708
706
  const emailParams = {};
709
707
  if (params?.id) {
710
708
  emailParams.id = params.id;
711
- } else if (routeLocation?.query?.id) {
712
- emailParams.id = routeLocation.query.id;
713
- } else if (routeLocation?.params?.id) {
714
- emailParams.id = routeLocation.params.id;
715
- } else if (routeLocation?.pathname?.includes('/edit/')) {
709
+ } else if (location?.query?.id) {
710
+ emailParams.id = location.query.id;
711
+ } else if (location?.params?.id) {
712
+ emailParams.id = location.params.id;
713
+ } else if (location?.pathname?.includes('/edit/')) {
716
714
  // Extract id from pathname if it's in the format /edit/:id
717
- const match = routeLocation.pathname.match(/\/edit\/([^/]+)/);
715
+ const match = location.pathname.match(/\/edit\/([^/]+)/);
718
716
  // Reject sentinel strings that come from unguarded template literals
719
717
  // (e.g. `/edit/${maybeUndefined}` → "/edit/undefined"), so they don't
720
718
  // get treated as real template ids downstream.
@@ -802,7 +800,7 @@ const useEmailWrapper = ({
802
800
  // Check if we're in edit mode (templateDetails or BEETemplate exists, or params.id exists)
803
801
  const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
804
802
  const hasBEETemplate = Email?.BEETemplate && !isEmpty(Email.BEETemplate);
805
- const hasParamsId = params?.id || routeLocation?.query?.id || routeLocation?.params?.id || routeLocation?.pathname?.includes('/edit/');
803
+ const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
806
804
  const isEditMode = hasTemplateDetails || hasBEETemplate || hasParamsId;
807
805
 
808
806
  // In edit mode (when supportCKEditor is false), always show editor
@@ -844,7 +842,7 @@ const useEmailWrapper = ({
844
842
 
845
843
  // For Editor: Show editor when template is selected
846
844
  return !isEmpty(SelectedEdmDefaultTemplate);
847
- }, [currentStep, selectedCreateMode, supportCKEditorFlag, emailCreateMode, EmailLayout, SelectedEdmDefaultTemplate, Email?.templateDetails, Email?.BEETemplate, params?.id, routeLocation?.query?.id, routeLocation?.params?.id, routeLocation?.pathname, emailProps?.editor, emailProps?.selectedEditorMode]);
845
+ }, [currentStep, selectedCreateMode, supportCKEditorFlag, emailCreateMode, EmailLayout, SelectedEdmDefaultTemplate, Email?.templateDetails, Email?.BEETemplate, params?.id, location?.query?.id, location?.params?.id, location?.pathname, emailProps?.editor, emailProps?.selectedEditorMode]);
848
846
 
849
847
  // Memoize static data
850
848
  const modes = useMemo(() => {
@@ -1,106 +0,0 @@
1
- export const BEE_PLUGIN_SCRIPT_URL = 'https://app-rsrc.getbee.io/plugin/BeePlugin.js';
2
- export const BEE_PLUGIN_LOAD_TIMEOUT_MS = 30000;
3
-
4
- let beePluginPromise = null;
5
-
6
- // Hosts consuming creatives as a library or MFE may not ship BeePlugin.js, so load it on demand
7
- export const loadBeePlugin = () => {
8
- if (window.BeePlugin) {
9
- return Promise.resolve(window.BeePlugin);
10
- }
11
- if (beePluginPromise) {
12
- return beePluginPromise;
13
- }
14
- beePluginPromise = new Promise((resolve, reject) => {
15
- const existingScript = document.querySelector('script[src*="BeePlugin.js"]');
16
- const script = existingScript || document.createElement('script');
17
- let timeoutId = null;
18
- const fail = (error) => {
19
- clearTimeout(timeoutId);
20
- beePluginPromise = null;
21
- // Drop the tag so a retry injects a fresh one instead of waiting on a dead script
22
- script.remove();
23
- reject(error);
24
- };
25
- const onLoad = () => {
26
- if (window.BeePlugin) {
27
- clearTimeout(timeoutId);
28
- resolve(window.BeePlugin);
29
- return;
30
- }
31
- fail(new Error('BeePlugin.js loaded but window.BeePlugin is undefined'));
32
- };
33
- const onError = () => fail(new Error(`Failed to load ${BEE_PLUGIN_SCRIPT_URL}`));
34
- timeoutId = setTimeout(
35
- () => fail(new Error(`Timed out loading ${BEE_PLUGIN_SCRIPT_URL}`)),
36
- BEE_PLUGIN_LOAD_TIMEOUT_MS,
37
- );
38
- script.addEventListener('load', onLoad, { once: true });
39
- script.addEventListener('error', onError, { once: true });
40
- if (!existingScript) {
41
- script.src = BEE_PLUGIN_SCRIPT_URL;
42
- script.type = 'text/javascript';
43
- script.async = true;
44
- document.head.appendChild(script);
45
- }
46
- });
47
- return beePluginPromise;
48
- };
49
-
50
- // Tears down an editor that will not be used; destroy can throw if BEE never finished mounting
51
- export const destroyBeeInstance = (instance) => {
52
- try {
53
- if (typeof instance?.destroy === 'function') {
54
- instance.destroy();
55
- }
56
- } catch (error) {
57
- console.warn('[beePluginLoader] Error destroying BEE plugin:', error);
58
- }
59
- };
60
-
61
- // Creates a BEE editor and starts it with the template JSON (string or object) returned by getBeeJson
62
- export const startBeePlugin = (BeePlugin, {
63
- tokenData, beeConfig, getBeeJson, isCancelled = () => false,
64
- }) => new Promise((resolve, reject) => {
65
- BeePlugin.create(tokenData, beeConfig, (instance) => {
66
- // create calls back asynchronously; never start an obsolete editor into the shared container
67
- if (isCancelled()) {
68
- destroyBeeInstance(instance);
69
- resolve(null);
70
- return;
71
- }
72
- try {
73
- const beeJson = getBeeJson();
74
- instance.start(typeof beeJson === 'string' ? JSON.parse(beeJson) : beeJson);
75
- resolve(instance);
76
- } catch (error) {
77
- destroyBeeInstance(instance);
78
- reject(error);
79
- }
80
- });
81
- });
82
-
83
- // Loads BeePlugin.js and starts the editor; resolves null when the caller was cleaned up in the meantime
84
- export const initBeeEditor = ({
85
- tokenData,
86
- beeConfig,
87
- getBeeJson,
88
- isCancelled,
89
- onPluginLoaded = () => {},
90
- }) => loadBeePlugin()
91
- .then((BeePlugin) => {
92
- if (isCancelled()) {
93
- return null;
94
- }
95
- onPluginLoaded();
96
- return startBeePlugin(BeePlugin, {
97
- tokenData, beeConfig, getBeeJson, isCancelled,
98
- });
99
- })
100
- .then((instance) => {
101
- if (instance && isCancelled()) {
102
- destroyBeeInstance(instance);
103
- return null;
104
- }
105
- return instance;
106
- });
@@ -1,199 +0,0 @@
1
- const SCRIPT_SELECTOR = 'script[src*="BeePlugin.js"]';
2
-
3
- const getLoader = () => {
4
- let loader;
5
- jest.isolateModules(() => {
6
- // Fresh module per test so the cached script promise does not leak between tests
7
- // eslint-disable-next-line global-require
8
- loader = require('../beePluginLoader');
9
- });
10
- return loader;
11
- };
12
-
13
- describe('loadBeePlugin', () => {
14
- const mockBeePlugin = { create: jest.fn() };
15
-
16
- beforeEach(() => {
17
- delete window.BeePlugin;
18
- document.head.innerHTML = '';
19
- });
20
-
21
- afterEach(() => {
22
- jest.useRealTimers();
23
- delete window.BeePlugin;
24
- });
25
-
26
- it('resolves immediately without injecting a script when BeePlugin is already loaded', async () => {
27
- window.BeePlugin = mockBeePlugin;
28
- const { loadBeePlugin } = getLoader();
29
- await expect(loadBeePlugin()).resolves.toBe(mockBeePlugin);
30
- expect(document.querySelector(SCRIPT_SELECTOR)).toBeNull();
31
- });
32
-
33
- it('injects the script once and resolves when it loads', async () => {
34
- const { loadBeePlugin, BEE_PLUGIN_SCRIPT_URL } = getLoader();
35
- const firstLoad = loadBeePlugin();
36
- const secondLoad = loadBeePlugin();
37
- const scripts = document.querySelectorAll(SCRIPT_SELECTOR);
38
- expect(scripts).toHaveLength(1);
39
- expect(scripts[0].src).toBe(BEE_PLUGIN_SCRIPT_URL);
40
- expect(secondLoad).toBe(firstLoad);
41
- window.BeePlugin = mockBeePlugin;
42
- scripts[0].dispatchEvent(new Event('load'));
43
- await expect(firstLoad).resolves.toBe(mockBeePlugin);
44
- });
45
-
46
- it('waits on a host-provided script instead of injecting another', async () => {
47
- const hostScript = document.createElement('script');
48
- hostScript.src = 'https://app-rsrc.getbee.io/plugin/BeePlugin.js';
49
- document.head.appendChild(hostScript);
50
- const { loadBeePlugin } = getLoader();
51
- const load = loadBeePlugin();
52
- expect(document.querySelectorAll(SCRIPT_SELECTOR)).toHaveLength(1);
53
- window.BeePlugin = mockBeePlugin;
54
- hostScript.dispatchEvent(new Event('load'));
55
- await expect(load).resolves.toBe(mockBeePlugin);
56
- });
57
-
58
- it('rejects on script error, removes the tag and allows a retry', async () => {
59
- const { loadBeePlugin } = getLoader();
60
- const failedLoad = loadBeePlugin();
61
- document.querySelector(SCRIPT_SELECTOR).dispatchEvent(new Event('error'));
62
- await expect(failedLoad).rejects.toThrow('Failed to load');
63
- expect(document.querySelector(SCRIPT_SELECTOR)).toBeNull();
64
-
65
- const retryLoad = loadBeePlugin();
66
- expect(retryLoad).not.toBe(failedLoad);
67
- window.BeePlugin = mockBeePlugin;
68
- document.querySelector(SCRIPT_SELECTOR).dispatchEvent(new Event('load'));
69
- await expect(retryLoad).resolves.toBe(mockBeePlugin);
70
- });
71
-
72
- it('rejects when the script loads but does not define BeePlugin', async () => {
73
- const { loadBeePlugin } = getLoader();
74
- const load = loadBeePlugin();
75
- document.querySelector(SCRIPT_SELECTOR).dispatchEvent(new Event('load'));
76
- await expect(load).rejects.toThrow('window.BeePlugin is undefined');
77
- });
78
-
79
- it('rejects after the timeout when the script never settles', async () => {
80
- jest.useFakeTimers();
81
- const { loadBeePlugin, BEE_PLUGIN_LOAD_TIMEOUT_MS } = getLoader();
82
- const load = loadBeePlugin();
83
- jest.advanceTimersByTime(BEE_PLUGIN_LOAD_TIMEOUT_MS);
84
- await expect(load).rejects.toThrow('Timed out');
85
- expect(document.querySelector(SCRIPT_SELECTOR)).toBeNull();
86
- });
87
- });
88
-
89
- describe('startBeePlugin', () => {
90
- const tokenData = { access_token: 'token' };
91
- const beeConfig = { uid: 'uid' };
92
- let instance;
93
- let BeePlugin;
94
-
95
- beforeEach(() => {
96
- instance = { start: jest.fn(), destroy: jest.fn() };
97
- BeePlugin = { create: jest.fn((token, config, onCreated) => onCreated(instance)) };
98
- });
99
-
100
- it('creates the editor and starts it with parsed JSON when given a string', async () => {
101
- const { startBeePlugin } = getLoader();
102
- const result = await startBeePlugin(BeePlugin, { tokenData, beeConfig, getBeeJson: () => '{"page":{}}' });
103
- expect(BeePlugin.create).toHaveBeenCalledWith(tokenData, beeConfig, expect.any(Function));
104
- expect(instance.start).toHaveBeenCalledWith({ page: {} });
105
- expect(result).toBe(instance);
106
- });
107
-
108
- it('starts the editor with an object template as-is', async () => {
109
- const { startBeePlugin } = getLoader();
110
- const template = { page: { rows: [] } };
111
- await startBeePlugin(BeePlugin, { tokenData, beeConfig, getBeeJson: () => template });
112
- expect(instance.start).toHaveBeenCalledWith(template);
113
- });
114
-
115
- it('rejects without starting when the template JSON is invalid', async () => {
116
- const { startBeePlugin } = getLoader();
117
- await expect(
118
- startBeePlugin(BeePlugin, { tokenData, beeConfig, getBeeJson: () => '{invalid' }),
119
- ).rejects.toThrow(SyntaxError);
120
- expect(instance.start).not.toHaveBeenCalled();
121
- expect(instance.destroy).toHaveBeenCalledTimes(1);
122
- });
123
- });
124
-
125
- describe('destroyBeeInstance', () => {
126
- it('destroys the editor and tolerates a missing or failing destroy', () => {
127
- const { destroyBeeInstance } = getLoader();
128
- const instance = { destroy: jest.fn() };
129
- destroyBeeInstance(instance);
130
- expect(instance.destroy).toHaveBeenCalledTimes(1);
131
-
132
- const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
133
- expect(() => destroyBeeInstance({ destroy: () => { throw new Error('not mounted'); } })).not.toThrow();
134
- expect(() => destroyBeeInstance(undefined)).not.toThrow();
135
- warn.mockRestore();
136
- });
137
- });
138
-
139
- describe('initBeeEditor', () => {
140
- const tokenData = { access_token: 'token' };
141
- const beeConfig = { uid: 'uid' };
142
- let instance;
143
-
144
- beforeEach(() => {
145
- instance = { start: jest.fn(), destroy: jest.fn() };
146
- window.BeePlugin = { create: jest.fn((token, config, onCreated) => onCreated(instance)) };
147
- });
148
-
149
- afterEach(() => {
150
- delete window.BeePlugin;
151
- });
152
-
153
- it('loads the plugin, reports it, and resolves the started editor', async () => {
154
- const { initBeeEditor } = getLoader();
155
- const onPluginLoaded = jest.fn();
156
- const result = await initBeeEditor({
157
- tokenData, beeConfig, getBeeJson: () => '{"page":{}}', isCancelled: () => false, onPluginLoaded,
158
- });
159
- expect(onPluginLoaded).toHaveBeenCalledTimes(1);
160
- expect(instance.start).toHaveBeenCalledWith({ page: {} });
161
- expect(result).toBe(instance);
162
- });
163
-
164
- it('does not create the editor when cancelled before the plugin loads', async () => {
165
- const { initBeeEditor } = getLoader();
166
- const result = await initBeeEditor({
167
- tokenData, beeConfig, getBeeJson: () => '{}', isCancelled: () => true,
168
- });
169
- expect(window.BeePlugin.create).not.toHaveBeenCalled();
170
- expect(result).toBeNull();
171
- });
172
-
173
- it('destroys an editor created after cancellation without starting it', async () => {
174
- const { initBeeEditor } = getLoader();
175
- let cancelled = false;
176
- window.BeePlugin.create.mockImplementation((token, config, onCreated) => {
177
- cancelled = true;
178
- onCreated(instance);
179
- });
180
- const result = await initBeeEditor({
181
- tokenData, beeConfig, getBeeJson: () => '{}', isCancelled: () => cancelled,
182
- });
183
- expect(instance.start).not.toHaveBeenCalled();
184
- expect(instance.destroy).toHaveBeenCalledTimes(1);
185
- expect(result).toBeNull();
186
- });
187
-
188
- it('destroys an editor cancelled after it started', async () => {
189
- const { initBeeEditor } = getLoader();
190
- let cancelled = false;
191
- instance.start.mockImplementation(() => { cancelled = true; });
192
- const result = await initBeeEditor({
193
- tokenData, beeConfig, getBeeJson: () => '{}', isCancelled: () => cancelled,
194
- });
195
- expect(instance.start).toHaveBeenCalledTimes(1);
196
- expect(instance.destroy).toHaveBeenCalledTimes(1);
197
- expect(result).toBeNull();
198
- });
199
- });
@@ -1,78 +0,0 @@
1
- import React from 'react';
2
- import '@testing-library/jest-dom';
3
- import { render, screen, fireEvent, waitFor } from '../../../utils/test-utils';
4
- import { initBeeEditor } from '../../../utils/beePluginLoader';
5
- import BeeEditor from '../index';
6
-
7
- // initBeeEditor's own load/start/cancel behaviour is covered in utils/tests/beePluginLoader.test.js
8
- jest.mock('../../../utils/beePluginLoader', () => ({
9
- ...jest.requireActual('../../../utils/beePluginLoader'),
10
- initBeeEditor: jest.fn(),
11
- }));
12
-
13
- jest.mock('../../TagList', () => () => null);
14
-
15
- const mockBeePluginInstance = { start: jest.fn(), destroy: jest.fn() };
16
-
17
- const defaultProps = {
18
- uid: 'test-uid',
19
- id: 'bee-editor',
20
- beeJson: '{"page":{}}',
21
- tokenData: { access_token: 'token' },
22
- saveBeeInstance: jest.fn(),
23
- saveBeeData: jest.fn(),
24
- tags: [],
25
- };
26
-
27
- const getInitOptions = () => initBeeEditor.mock.calls[initBeeEditor.mock.calls.length - 1][0];
28
-
29
- describe('BeeEditor BeePlugin loading', () => {
30
- beforeEach(() => {
31
- jest.spyOn(console, 'error').mockImplementation(() => {});
32
- });
33
-
34
- afterEach(() => {
35
- console.error.mockRestore();
36
- });
37
-
38
- it('starts the BEE editor with its template and saves the instance', async () => {
39
- initBeeEditor.mockResolvedValue(mockBeePluginInstance);
40
- const { container } = render(<BeeEditor {...defaultProps} />);
41
-
42
- await waitFor(() => expect(defaultProps.saveBeeInstance).toHaveBeenCalledWith(mockBeePluginInstance));
43
- const { tokenData, getBeeJson, isCancelled } = getInitOptions();
44
- expect(tokenData).toEqual(defaultProps.tokenData);
45
- expect(getBeeJson()).toBe(defaultProps.beeJson);
46
- expect(isCancelled()).toBe(false);
47
- expect(container.querySelector('#bee-plugin-container')).toBeInTheDocument();
48
- });
49
-
50
- it('shows an error with retry when the plugin script fails, and recovers on retry', async () => {
51
- initBeeEditor
52
- .mockRejectedValueOnce(new Error('Failed to load'))
53
- .mockResolvedValueOnce(mockBeePluginInstance);
54
- const { container } = render(<BeeEditor {...defaultProps} />);
55
-
56
- expect(await screen.findByText(/Unable to load the drag & drop editor/)).toBeInTheDocument();
57
- expect(container.querySelector('#bee-plugin-container')).not.toBeInTheDocument();
58
-
59
- fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
60
-
61
- await waitFor(() => expect(defaultProps.saveBeeInstance).toHaveBeenCalledWith(mockBeePluginInstance));
62
- expect(initBeeEditor).toHaveBeenCalledTimes(2);
63
- expect(screen.queryByText(/Unable to load the drag & drop editor/)).not.toBeInTheDocument();
64
- expect(container.querySelector('#bee-plugin-container')).toBeInTheDocument();
65
- });
66
-
67
- it('reports cancellation after unmount and saves nothing when no editor is returned', async () => {
68
- let resolveInit;
69
- initBeeEditor.mockReturnValue(new Promise((resolve) => { resolveInit = resolve; }));
70
- const { unmount } = render(<BeeEditor {...defaultProps} />);
71
- unmount();
72
-
73
- expect(getInitOptions().isCancelled()).toBe(true);
74
- resolveInit(null);
75
- await Promise.resolve();
76
- expect(defaultProps.saveBeeInstance).not.toHaveBeenCalled();
77
- });
78
- });