learningtribes-studio-frontend 1.4.2-alpha.4 → 1.4.2-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessibilityPolicy.min.js +2 -2
- package/dist/assets.min.css +1 -1
- package/dist/assets.min.js +1 -1
- package/dist/assets.min.js.map +1 -1
- package/dist/common.min.css +2 -2
- package/dist/common.min.js +7 -7
- package/dist/common.min.js.map +1 -1
- package/dist/courseHealthCheck.min.js +1 -1
- package/dist/courseOutlineHealthCheck.min.js +1 -1
- package/dist/editImageModal.min.css +1 -1
- package/dist/editImageModal.min.js +1 -1
- package/dist/editImageModal.min.js.map +1 -1
- package/dist/i18n/messages/de_DE.json +3 -1
- package/dist/i18n/messages/es_419.json +2 -0
- package/dist/i18n/messages/fr.json +2 -0
- package/dist/i18n/messages/it_IT.json +3 -1
- package/dist/i18n/messages/pt_BR.json +3 -1
- package/dist/i18n/messages/zh_CN.json +2 -0
- package/dist/i18nMessages.min.js +1 -1
- package/dist/i18nMessages.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AssetsDropZone/AssetsDropZone.scss +110 -77
- package/src/components/AssetsDropZone/AssetsDropZone.test.jsx +3 -1
- package/src/components/AssetsDropZone/displayMessages.jsx +12 -2
- package/src/components/AssetsDropZone/index.jsx +176 -88
- package/src/components/AssetsList/AssetsList.scss +18 -18
- package/src/components/AssetsList/AssetsList.test.jsx +125 -145
- package/src/components/AssetsList/index.jsx +20 -2
- package/src/components/EditImageModal/EditImageModal.scss +2 -0
- package/src/components/EditImageModal/EditImageModal.test.jsx +126 -230
- package/src/components/EditImageModal/displayMessages.jsx +11 -6
- package/src/components/EditImageModal/index.jsx +76 -211
- package/src/data/i18n/default/transifex_input.json +5 -2
- package/src/data/i18n/locales/de_DE.json +3 -1
- package/src/data/i18n/locales/es_419.json +2 -0
- package/src/data/i18n/locales/fr.json +2 -0
- package/src/data/i18n/locales/it_IT.json +3 -1
- package/src/data/i18n/locales/pt_BR.json +3 -1
- package/src/data/i18n/locales/zh_CN.json +2 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, CheckBox, Fieldset, Modal, InputText, StatusAlert, Variant } from '@edx/paragon';
|
|
2
|
-
import { IntlProvider
|
|
2
|
+
import { IntlProvider } from 'react-intl';
|
|
3
3
|
import { Provider } from 'react-redux';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
@@ -41,7 +41,6 @@ const getInsertImageButton = editImageModal =>
|
|
|
41
41
|
(getModalFooter(editImageModal).find(Button).first());
|
|
42
42
|
const getNextButton = editImageModal =>
|
|
43
43
|
(getModalFooter(editImageModal).find(Button).first());
|
|
44
|
-
const getPreviousButton = editImageModal => (getModalBody(editImageModal).find(Button));
|
|
45
44
|
|
|
46
45
|
const getImageDescriptionFieldset = editImageModal =>
|
|
47
46
|
(getFormContainer(editImageModal).find(Fieldset).at(0));
|
|
@@ -159,10 +158,11 @@ describe('EditImageModal', () => {
|
|
|
159
158
|
expect(getModalBody(editImageModal).find('Connect(AssetsDropZone)')).toHaveLength(1);
|
|
160
159
|
});
|
|
161
160
|
|
|
162
|
-
it('
|
|
163
|
-
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
it('no insert header', () => {
|
|
162
|
+
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
163
|
+
message => message.prop('message') === messages.editImageModalInsertHeader,
|
|
164
|
+
);
|
|
165
|
+
expect(header).toHaveLength(0);
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
it('a loading icon', () => {
|
|
@@ -218,30 +218,29 @@ describe('EditImageModal', () => {
|
|
|
218
218
|
expect(getModalBody(editImageModal).find('Connect(AssetsDropZone)')).toHaveLength(1);
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
it('
|
|
222
|
-
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('
|
|
223
|
-
expect(header).toHaveLength(
|
|
224
|
-
expect(header.prop('message')).toEqual(messages.editImageModalInsertHeader);
|
|
221
|
+
it('no insert header', () => {
|
|
222
|
+
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('message') === messages.editImageModalInsertHeader);
|
|
223
|
+
expect(header).toHaveLength(0);
|
|
225
224
|
});
|
|
226
225
|
|
|
227
226
|
it('an AssetsList component', () => {
|
|
228
227
|
expect(getModalBody(editImageModal).find('Connect(AssetsList)')).toHaveLength(1);
|
|
229
228
|
});
|
|
230
229
|
|
|
231
|
-
it('
|
|
232
|
-
expect(getModalBody(editImageModal).find('Connect(AssetsSearch)')).toHaveLength(
|
|
230
|
+
it('no AssetsSearch component', () => {
|
|
231
|
+
expect(getModalBody(editImageModal).find('Connect(AssetsSearch)')).toHaveLength(0);
|
|
233
232
|
});
|
|
234
233
|
|
|
235
234
|
it('no AssetsClearSearchButton component', () => {
|
|
236
235
|
expect(getModalBody(editImageModal).find('Connect(AssetsClearSearchButton)')).toHaveLength(0);
|
|
237
236
|
});
|
|
238
237
|
|
|
239
|
-
it('
|
|
240
|
-
expect(getModalBody(editImageModal).find('Connect(AssetsResultsCount)')).toHaveLength(
|
|
238
|
+
it('no AssetsResultsCount component', () => {
|
|
239
|
+
expect(getModalBody(editImageModal).find('Connect(AssetsResultsCount)')).toHaveLength(0);
|
|
241
240
|
});
|
|
242
241
|
|
|
243
|
-
it('
|
|
244
|
-
expect(getModalBody(editImageModal).find('Connect(InjectIntl(Pagination))')).toHaveLength(
|
|
242
|
+
it('no Pagination component', () => {
|
|
243
|
+
expect(getModalBody(editImageModal).find('Connect(InjectIntl(Pagination))')).toHaveLength(0);
|
|
245
244
|
});
|
|
246
245
|
});
|
|
247
246
|
|
|
@@ -263,23 +262,26 @@ describe('EditImageModal', () => {
|
|
|
263
262
|
expect(getModalBody(editImageModal).find('Connect(AssetsDropZone)')).toHaveLength(1);
|
|
264
263
|
});
|
|
265
264
|
|
|
266
|
-
it('
|
|
267
|
-
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
it('no insert header', () => {
|
|
266
|
+
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
267
|
+
message => message.prop('message') === messages.editImageModalInsertHeader,
|
|
268
|
+
);
|
|
269
|
+
expect(header).toHaveLength(0);
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
it('a no results message', () => {
|
|
273
|
-
|
|
274
|
-
.prop('message')
|
|
273
|
+
const noResultsMessage = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
274
|
+
message => message.prop('message') === messages.editImageModalAssetsListNoResultsMessage,
|
|
275
|
+
);
|
|
276
|
+
expect(noResultsMessage).toHaveLength(1);
|
|
275
277
|
});
|
|
276
278
|
|
|
277
279
|
it('no AssetsList component', () => {
|
|
278
280
|
expect(getModalBody(editImageModal).find('Connect(AssetsList)')).toHaveLength(0);
|
|
279
281
|
});
|
|
280
282
|
|
|
281
|
-
it('
|
|
282
|
-
expect(getModalBody(editImageModal).find('Connect(AssetsSearch)')).toHaveLength(
|
|
283
|
+
it('no AssetsSearch component', () => {
|
|
284
|
+
expect(getModalBody(editImageModal).find('Connect(AssetsSearch)')).toHaveLength(0);
|
|
283
285
|
});
|
|
284
286
|
|
|
285
287
|
it('an AssetsClearSearchButton component', () => {
|
|
@@ -314,17 +316,19 @@ describe('EditImageModal', () => {
|
|
|
314
316
|
expect(getModalBody(editImageModal).find('Connect(AssetsDropZone)'));
|
|
315
317
|
});
|
|
316
318
|
|
|
317
|
-
it('
|
|
318
|
-
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
it('no insert header', () => {
|
|
320
|
+
const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
321
|
+
message => message.prop('message') === messages.editImageModalInsertHeader,
|
|
322
|
+
);
|
|
323
|
+
expect(header).toHaveLength(0);
|
|
321
324
|
});
|
|
322
325
|
|
|
323
|
-
it('no
|
|
326
|
+
it('a no assets message', () => {
|
|
324
327
|
const emptyMessage = getModalBody(editImageModal).find(WrappedMessage).filterWhere(
|
|
325
328
|
message => message.prop('message') === messages.editImageModalAssetsListNoAssetsMessage,
|
|
326
329
|
);
|
|
327
|
-
expect(emptyMessage).toHaveLength(
|
|
330
|
+
expect(emptyMessage).toHaveLength(1);
|
|
331
|
+
expect(emptyMessage.prop('tagName')).toEqual('h3');
|
|
328
332
|
});
|
|
329
333
|
|
|
330
334
|
it('no AssetsList component', () => {
|
|
@@ -356,8 +360,7 @@ describe('EditImageModal', () => {
|
|
|
356
360
|
beforeEach(() => {
|
|
357
361
|
editImageModal.setState({
|
|
358
362
|
open: true,
|
|
359
|
-
|
|
360
|
-
shouldShowPreviousButton: true,
|
|
363
|
+
imageSource: sampleText,
|
|
361
364
|
});
|
|
362
365
|
});
|
|
363
366
|
|
|
@@ -369,7 +372,7 @@ describe('EditImageModal', () => {
|
|
|
369
372
|
const modal = getModal(editImageModal);
|
|
370
373
|
|
|
371
374
|
expect(modal.prop('open')).toEqual(false);
|
|
372
|
-
expect(shallowWithIntl(modal.prop('title')).find(WrappedMessage).prop('message')).toEqual(messages.
|
|
375
|
+
expect(shallowWithIntl(modal.prop('title')).find(WrappedMessage).prop('message')).toEqual(messages.editImageModalInsertTitle);
|
|
373
376
|
expect(shallowWithIntl(modal.prop('closeText')).prop('message')).toEqual(messages.editImageModalCancelButton);
|
|
374
377
|
});
|
|
375
378
|
|
|
@@ -390,30 +393,9 @@ describe('EditImageModal', () => {
|
|
|
390
393
|
|
|
391
394
|
it('a StatusAlert component with correct initial props', () => {
|
|
392
395
|
expect(getStatusAlert(editImageModal).prop('alertType')).toEqual('danger');
|
|
393
|
-
const statusAlertDialog = shallowWithIntl(getStatusAlert(editImageModal).prop('dialog')).find(WrappedMessage).at(0);
|
|
394
|
-
expect(statusAlertDialog.prop('message')).toEqual(messages.editImageModalFormErrorMissingFields);
|
|
395
396
|
expect(getStatusAlert(editImageModal).prop('open')).toEqual(false);
|
|
396
397
|
});
|
|
397
398
|
|
|
398
|
-
it('a previous page button when this.state.shouldShowPreviousButton', () => {
|
|
399
|
-
expect(getModalBody(editImageModal).find(Button)).toHaveLength(1);
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it('a previous page button with correct props', () => {
|
|
403
|
-
const previousButton = getModalBody(editImageModal).find(Button);
|
|
404
|
-
expect(previousButton).toHaveLength(1);
|
|
405
|
-
expect(shallowWithIntl(previousButton.prop('label')).prop('message')).toEqual(messages.editImageModalPreviousPageButton);
|
|
406
|
-
expect(previousButton.prop('buttonType')).toEqual('link');
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it('no previous page button when not this.state.shouldShowPreviousButton', () => {
|
|
410
|
-
editImageModal.setState({
|
|
411
|
-
shouldShowPreviousButton: false,
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
expect(getModalBody(editImageModal).find(Button)).toHaveLength(0);
|
|
415
|
-
});
|
|
416
|
-
|
|
417
399
|
describe('a form with', () => {
|
|
418
400
|
it('a form', () => {
|
|
419
401
|
expect(getFormContainer(editImageModal)).toHaveLength(1);
|
|
@@ -466,6 +448,8 @@ describe('EditImageModal', () => {
|
|
|
466
448
|
.toEqual(messages.editImageModalImageDescriptionDescription);
|
|
467
449
|
expect(imageDescriptionInputDescriptionMessages.at(1).prop('message'))
|
|
468
450
|
.toEqual(messages.editImageModalLearnMore);
|
|
451
|
+
expect(imageDescriptionInputDescriptionMessages.at(2).prop('message'))
|
|
452
|
+
.toEqual(messages.editImageModalImageDescriptionDecorative);
|
|
469
453
|
|
|
470
454
|
expect(imageDescriptionInput.prop('id')).toEqual('imageDescription');
|
|
471
455
|
expect(imageDescriptionInput.prop('type')).toEqual('text');
|
|
@@ -594,8 +578,6 @@ describe('EditImageModal', () => {
|
|
|
594
578
|
expect(editImageModal.state('isImageLoading')).toEqual(false);
|
|
595
579
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
596
580
|
expect(editImageModal.state('isModalOpen')).toEqual(false);
|
|
597
|
-
expect(editImageModal.state('pageNumber')).toEqual(1);
|
|
598
|
-
expect(editImageModal.state('shouldShowPreviousButton')).toEqual(false);
|
|
599
581
|
});
|
|
600
582
|
|
|
601
583
|
it('handleOpenModal sets correct state for empty event (inserting an image) with assets', () => {
|
|
@@ -621,8 +603,6 @@ describe('EditImageModal', () => {
|
|
|
621
603
|
expect(editImageModal.state('isImageLoading')).toEqual(false);
|
|
622
604
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
623
605
|
expect(editImageModal.state('isModalOpen')).toEqual(true);
|
|
624
|
-
expect(editImageModal.state('pageNumber')).toEqual(1);
|
|
625
|
-
expect(editImageModal.state('shouldShowPreviousButton')).toEqual(true);
|
|
626
606
|
});
|
|
627
607
|
|
|
628
608
|
it('handleOpenModal sets correct state for empty event (inserting an image) without assets', () => {
|
|
@@ -644,8 +624,6 @@ describe('EditImageModal', () => {
|
|
|
644
624
|
expect(editImageModal.state('isImageLoading')).toEqual(false);
|
|
645
625
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
646
626
|
expect(editImageModal.state('isModalOpen')).toEqual(true);
|
|
647
|
-
expect(editImageModal.state('pageNumber')).toEqual(1);
|
|
648
|
-
expect(editImageModal.state('shouldShowPreviousButton')).toEqual(true);
|
|
649
627
|
});
|
|
650
628
|
|
|
651
629
|
it('handleOpenModal sets correct state for event with data (editing an image)', () => {
|
|
@@ -683,8 +661,7 @@ describe('EditImageModal', () => {
|
|
|
683
661
|
expect(editImageModal.state('isImageLoading')).toEqual(false);
|
|
684
662
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
685
663
|
expect(editImageModal.state('isModalOpen')).toEqual(true);
|
|
686
|
-
expect(editImageModal.state('
|
|
687
|
-
expect(editImageModal.state('shouldShowPreviousButton')).toEqual(false);
|
|
664
|
+
expect(editImageModal.state('editingExisting')).toEqual(true);
|
|
688
665
|
});
|
|
689
666
|
|
|
690
667
|
it('onEditImageModalClose sets this.state.open to false', () => {
|
|
@@ -704,11 +681,6 @@ describe('EditImageModal', () => {
|
|
|
704
681
|
});
|
|
705
682
|
|
|
706
683
|
it('onEditImageModalClose sets this.state.isModalOpen to false', () => {
|
|
707
|
-
editImageModal.setState({
|
|
708
|
-
pageNumber: 2,
|
|
709
|
-
shouldShowPreviousButton: true,
|
|
710
|
-
});
|
|
711
|
-
|
|
712
684
|
const focusSpy = jest.fn();
|
|
713
685
|
editImageModal.instance().setModalWrapperRef({
|
|
714
686
|
dispatchEvent: jest.fn(),
|
|
@@ -790,11 +762,6 @@ describe('EditImageModal', () => {
|
|
|
790
762
|
|
|
791
763
|
editImageModal.instance().setDropZoneButtonRef(refMock);
|
|
792
764
|
editImageModal.instance().setStatusAlertRef(refMock);
|
|
793
|
-
|
|
794
|
-
editImageModal.setState({
|
|
795
|
-
pageNumber: 1,
|
|
796
|
-
shouldShowPreviousButton: true,
|
|
797
|
-
});
|
|
798
765
|
});
|
|
799
766
|
|
|
800
767
|
it('this.state.isStatusAlertOpen is false by default', () => {
|
|
@@ -839,6 +806,27 @@ describe('EditImageModal', () => {
|
|
|
839
806
|
expect(statusAlertDialog.prop('message')).toEqual(messages.editImageModalTooManyFiles);
|
|
840
807
|
});
|
|
841
808
|
|
|
809
|
+
it('displays statusAlert when the uploaded file exceeds the size limit', () => {
|
|
810
|
+
editImageModal.setProps({
|
|
811
|
+
assetsStatus: {
|
|
812
|
+
type: assetActions.upload.UPLOAD_EXCEED_MAX_SIZE_ERROR,
|
|
813
|
+
maxFileSizeMB: 10,
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
const statusAlert = getStatusAlert(editImageModal);
|
|
818
|
+
expect(statusAlert.prop('open')).toEqual(true);
|
|
819
|
+
/*
|
|
820
|
+
Due to Enzyme issue #1213, we must wrap React Fragments in a div in order
|
|
821
|
+
to succesfully shallow them. Once Enzyme introduces support for React Fragments,
|
|
822
|
+
we can remove the extraneous div.
|
|
823
|
+
*/
|
|
824
|
+
const statusAlertDialog =
|
|
825
|
+
shallowWithIntl(<div>{statusAlert.prop('dialog')}</div>).find(WrappedMessage);
|
|
826
|
+
expect(statusAlertDialog.prop('message')).toEqual(messages.editImageModalFileTooLarge);
|
|
827
|
+
expect(statusAlertDialog.prop('values').max_size.props.value).toEqual(10);
|
|
828
|
+
});
|
|
829
|
+
|
|
842
830
|
it('displays statusAlert on invalid file type uploaded', () => {
|
|
843
831
|
editImageModal.setProps({
|
|
844
832
|
assetsStatus: {
|
|
@@ -881,13 +869,7 @@ describe('EditImageModal', () => {
|
|
|
881
869
|
focus: jest.fn(),
|
|
882
870
|
};
|
|
883
871
|
|
|
884
|
-
editImageModal.instance().setPreviousButtonRef(refMock);
|
|
885
872
|
editImageModal.instance().setStatusAlertRef(refMock);
|
|
886
|
-
|
|
887
|
-
editImageModal.setState({
|
|
888
|
-
pageNumber: 2,
|
|
889
|
-
shouldShowPreviousButton: true,
|
|
890
|
-
});
|
|
891
873
|
});
|
|
892
874
|
|
|
893
875
|
it('this.state.isStatusAlertOpen is false by default', () => {
|
|
@@ -895,13 +877,27 @@ describe('EditImageModal', () => {
|
|
|
895
877
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
896
878
|
});
|
|
897
879
|
|
|
898
|
-
it('this.state.isStatusAlertOpen is true if invalid
|
|
880
|
+
it('this.state.isStatusAlertOpen is true if invalid dimensions are submitted', () => {
|
|
881
|
+
editImageModal.setState({
|
|
882
|
+
imageDimensions: {
|
|
883
|
+
height: -1 * sampleImgData.height,
|
|
884
|
+
width: -1 * sampleImgData.width,
|
|
885
|
+
},
|
|
886
|
+
});
|
|
887
|
+
|
|
899
888
|
getInsertImageButton(editImageModal).simulate('click');
|
|
900
889
|
|
|
901
890
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(true);
|
|
902
891
|
});
|
|
903
892
|
|
|
904
|
-
it('status alert is displayed if invalid
|
|
893
|
+
it('status alert is displayed if invalid dimensions are submitted', () => {
|
|
894
|
+
editImageModal.setState({
|
|
895
|
+
imageDimensions: {
|
|
896
|
+
height: -1 * sampleImgData.height,
|
|
897
|
+
width: -1 * sampleImgData.width,
|
|
898
|
+
},
|
|
899
|
+
});
|
|
900
|
+
|
|
905
901
|
getInsertImageButton(editImageModal).simulate('click');
|
|
906
902
|
|
|
907
903
|
editImageModal.update();
|
|
@@ -910,6 +906,13 @@ describe('EditImageModal', () => {
|
|
|
910
906
|
});
|
|
911
907
|
|
|
912
908
|
it('StatusAlert open prop is false when status alert is closed', () => {
|
|
909
|
+
editImageModal.setState({
|
|
910
|
+
imageDimensions: {
|
|
911
|
+
height: -1 * sampleImgData.height,
|
|
912
|
+
width: -1 * sampleImgData.width,
|
|
913
|
+
},
|
|
914
|
+
});
|
|
915
|
+
|
|
913
916
|
getInsertImageButton(editImageModal).simulate('click');
|
|
914
917
|
|
|
915
918
|
getCloseStatusAlertButton(editImageModal).simulate('click');
|
|
@@ -958,6 +961,7 @@ describe('EditImageModal', () => {
|
|
|
958
961
|
|
|
959
962
|
it('status alert has correct validation message when invalid dimensions submitted', () => {
|
|
960
963
|
editImageModal.setState({
|
|
964
|
+
imageDescription: sampleText,
|
|
961
965
|
imageDimensions: {
|
|
962
966
|
height: (-1 * sampleImgData.naturalHeight),
|
|
963
967
|
width: (-1 * sampleImgData.naturalWidth),
|
|
@@ -975,6 +979,7 @@ describe('EditImageModal', () => {
|
|
|
975
979
|
|
|
976
980
|
it('validation messages are hyperlinks that navigate to appropriate form elements', () => {
|
|
977
981
|
editImageModal.setState({
|
|
982
|
+
imageDescription: sampleText,
|
|
978
983
|
imageDimensions: {
|
|
979
984
|
height: (-1 * sampleImgData.naturalHeight),
|
|
980
985
|
width: (-1 * sampleImgData.naturalWidth),
|
|
@@ -1009,13 +1014,20 @@ describe('EditImageModal', () => {
|
|
|
1009
1014
|
expect(statusAlertListItems.at(0).find(WrappedMessage).prop('message')).toEqual(messages.editImageModalFormValidImageDimensions);
|
|
1010
1015
|
});
|
|
1011
1016
|
|
|
1012
|
-
it('
|
|
1017
|
+
it('focuses the image description input when a validation alert is closed', () => {
|
|
1013
1018
|
const focusSpy = jest.fn();
|
|
1014
1019
|
|
|
1015
|
-
editImageModal.instance().
|
|
1020
|
+
editImageModal.instance().setImageDescriptionInputRef({
|
|
1016
1021
|
focus: focusSpy,
|
|
1017
1022
|
});
|
|
1018
1023
|
|
|
1024
|
+
editImageModal.setState({
|
|
1025
|
+
imageDimensions: {
|
|
1026
|
+
height: -1 * sampleImgData.height,
|
|
1027
|
+
width: -1 * sampleImgData.width,
|
|
1028
|
+
},
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1019
1031
|
getInsertImageButton(editImageModal).simulate('click');
|
|
1020
1032
|
|
|
1021
1033
|
getCloseStatusAlertButton(editImageModal).simulate('click');
|
|
@@ -1026,6 +1038,10 @@ describe('EditImageModal', () => {
|
|
|
1026
1038
|
it('focus on page 2 is moved to image description input when status alert is closed and previous button is not shown', () => {
|
|
1027
1039
|
editImageModal.setState({
|
|
1028
1040
|
shouldShowPreviousButton: false,
|
|
1041
|
+
imageDimensions: {
|
|
1042
|
+
height: -1 * sampleImgData.height,
|
|
1043
|
+
width: -1 * sampleImgData.width,
|
|
1044
|
+
},
|
|
1029
1045
|
});
|
|
1030
1046
|
|
|
1031
1047
|
const focusSpy = jest.fn();
|
|
@@ -1050,12 +1066,11 @@ describe('EditImageModal', () => {
|
|
|
1050
1066
|
|
|
1051
1067
|
editImageModal.setState({
|
|
1052
1068
|
open: true,
|
|
1053
|
-
|
|
1054
|
-
shouldShowPreviousButton: true,
|
|
1069
|
+
imageSource: sampleText,
|
|
1055
1070
|
});
|
|
1056
1071
|
});
|
|
1057
1072
|
|
|
1058
|
-
it('
|
|
1073
|
+
it('image description stays valid and image dimensions are invalid if invalid dimensions are submitted', () => {
|
|
1059
1074
|
editImageModal.setState({
|
|
1060
1075
|
imageDimensions: {
|
|
1061
1076
|
height: (-1 * sampleImgData.naturalHeight),
|
|
@@ -1065,7 +1080,7 @@ describe('EditImageModal', () => {
|
|
|
1065
1080
|
|
|
1066
1081
|
getInsertImageButton(editImageModal).simulate('click');
|
|
1067
1082
|
|
|
1068
|
-
expect(editImageModal.state('isImageDescriptionValid')).toEqual(
|
|
1083
|
+
expect(editImageModal.state('isImageDescriptionValid')).toEqual(true);
|
|
1069
1084
|
expect(editImageModal.state('areImageDimensionsValid')).toEqual(false);
|
|
1070
1085
|
});
|
|
1071
1086
|
|
|
@@ -1084,7 +1099,7 @@ describe('EditImageModal', () => {
|
|
|
1084
1099
|
editImageModal.update();
|
|
1085
1100
|
|
|
1086
1101
|
const imageDescriptionFieldset = getImageDescriptionFieldset(editImageModal);
|
|
1087
|
-
expect(imageDescriptionFieldset.prop('isValid')).toEqual(
|
|
1102
|
+
expect(imageDescriptionFieldset.prop('isValid')).toEqual(true);
|
|
1088
1103
|
expect(shallowWithIntl(imageDescriptionFieldset.prop('invalidMessage')).prop('message')).toEqual(messages.editImageModalFormValidImageDescription);
|
|
1089
1104
|
|
|
1090
1105
|
const imageDimensionsFieldset = getImageDimensionsFieldset(editImageModal);
|
|
@@ -1101,13 +1116,7 @@ describe('EditImageModal', () => {
|
|
|
1101
1116
|
};
|
|
1102
1117
|
|
|
1103
1118
|
editImageModal.instance().setDropZoneButtonRef(refMock);
|
|
1104
|
-
editImageModal.instance().setPreviousButtonRef(refMock);
|
|
1105
1119
|
editImageModal.instance().setStatusAlertRef(refMock);
|
|
1106
|
-
|
|
1107
|
-
editImageModal.setState({
|
|
1108
|
-
pageNumber: 1,
|
|
1109
|
-
shouldShowPreviousButton: true,
|
|
1110
|
-
});
|
|
1111
1120
|
});
|
|
1112
1121
|
|
|
1113
1122
|
it('state updated correctly on upload success', () => {
|
|
@@ -1131,7 +1140,7 @@ describe('EditImageModal', () => {
|
|
|
1131
1140
|
expect(selectAssetSpy).toHaveBeenCalledTimes(1);
|
|
1132
1141
|
expect(selectAssetSpy).toHaveBeenCalledWith(assetsStatusMock.response.asset, 0);
|
|
1133
1142
|
expect(clearAssetsStatusSpy).toHaveBeenCalledTimes(1);
|
|
1134
|
-
expect(editImageModal.state('
|
|
1143
|
+
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
1135
1144
|
});
|
|
1136
1145
|
|
|
1137
1146
|
describe('AssetsDropZone', () => {
|
|
@@ -1145,13 +1154,6 @@ describe('EditImageModal', () => {
|
|
|
1145
1154
|
});
|
|
1146
1155
|
|
|
1147
1156
|
describe('Image Preview', () => {
|
|
1148
|
-
beforeEach(() => {
|
|
1149
|
-
editImageModal.setState({
|
|
1150
|
-
pageNumber: 2,
|
|
1151
|
-
shouldShowPreviousButton: true,
|
|
1152
|
-
});
|
|
1153
|
-
});
|
|
1154
|
-
|
|
1155
1157
|
it('correct state is set on image load', () => {
|
|
1156
1158
|
editImageModal.setState({
|
|
1157
1159
|
imageSource: sampleText,
|
|
@@ -1181,57 +1183,6 @@ describe('EditImageModal', () => {
|
|
|
1181
1183
|
expect(editImageModal.state('isImageLoaded')).toEqual(false);
|
|
1182
1184
|
expect(editImageModal.state('isImageLoading')).toEqual(false);
|
|
1183
1185
|
});
|
|
1184
|
-
|
|
1185
|
-
it('with visible image preview image when this.state.isImageLoaded is false (default)', () => {
|
|
1186
|
-
editImageModal.setState({
|
|
1187
|
-
imageSource: sampleText,
|
|
1188
|
-
});
|
|
1189
|
-
|
|
1190
|
-
const img = getModalBody(editImageModal).find('img');
|
|
1191
|
-
|
|
1192
|
-
expect(img.prop('className')).toEqual(expect.stringContaining('invisible'));
|
|
1193
|
-
});
|
|
1194
|
-
|
|
1195
|
-
it('with visible image preview image when this.state.isImageLoaded is true ', () => {
|
|
1196
|
-
editImageModal.setState({
|
|
1197
|
-
imageSource: sampleText,
|
|
1198
|
-
isImageLoaded: true,
|
|
1199
|
-
});
|
|
1200
|
-
|
|
1201
|
-
const img = getModalBody(editImageModal).find('img');
|
|
1202
|
-
|
|
1203
|
-
// TODO: replace this with asymmetric matcher expect.not.stringContaining when released
|
|
1204
|
-
expect(img.prop('className').includes('invisible')).toEqual(false);
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
|
-
it('with visible image preview placeholder text when this.state.isImageLoaded is false (default)', () => {
|
|
1208
|
-
const imagePreviewPlaceholderText = getModalBody(editImageModal).find('.image-preview-placeholder').find(WrappedMessage);
|
|
1209
|
-
|
|
1210
|
-
const imagePreviewPlaceholderTextMessage = imagePreviewPlaceholderText
|
|
1211
|
-
.dive({ context: { store, intl } })
|
|
1212
|
-
.dive({ context: { store, intl } }).find(FormattedMessage)
|
|
1213
|
-
.dive({ context: { store, intl } });
|
|
1214
|
-
|
|
1215
|
-
// TODO: replace this with asymmetric matcher expect.not.stringContaining when released
|
|
1216
|
-
expect(imagePreviewPlaceholderTextMessage.prop('className').includes('invisible')).toEqual(false);
|
|
1217
|
-
});
|
|
1218
|
-
|
|
1219
|
-
it('with invisible image preview placeholder text when this.state.isImageLoaded is true', () => {
|
|
1220
|
-
editImageModal.setState({
|
|
1221
|
-
isImageLoaded: true,
|
|
1222
|
-
pageNumber: 2,
|
|
1223
|
-
shouldShowPreviousButton: true,
|
|
1224
|
-
});
|
|
1225
|
-
|
|
1226
|
-
const imagePreviewPlaceholderText = getModalBody(editImageModal).find('.image-preview-placeholder').find(WrappedMessage);
|
|
1227
|
-
|
|
1228
|
-
const imagePreviewPlaceholderTextMessage = imagePreviewPlaceholderText
|
|
1229
|
-
.dive({ context: { store, intl } })
|
|
1230
|
-
.dive({ context: { store, intl } }).find(FormattedMessage)
|
|
1231
|
-
.dive({ context: { store, intl } });
|
|
1232
|
-
|
|
1233
|
-
expect(imagePreviewPlaceholderTextMessage.prop('className')).toEqual(expect.stringContaining('invisible'));
|
|
1234
|
-
});
|
|
1235
1186
|
});
|
|
1236
1187
|
|
|
1237
1188
|
describe('Image Description Fieldset', () => {
|
|
@@ -1241,12 +1192,10 @@ describe('EditImageModal', () => {
|
|
|
1241
1192
|
};
|
|
1242
1193
|
|
|
1243
1194
|
editImageModal.instance().setImageDescriptionInputRef(refMock);
|
|
1244
|
-
editImageModal.instance().setPreviousButtonRef(refMock);
|
|
1245
1195
|
editImageModal.instance().setStatusAlertRef(refMock);
|
|
1246
1196
|
|
|
1247
1197
|
editImageModal.setState({
|
|
1248
|
-
|
|
1249
|
-
shouldShowPreviousButton: true,
|
|
1198
|
+
imageSource: sampleText,
|
|
1250
1199
|
});
|
|
1251
1200
|
});
|
|
1252
1201
|
|
|
@@ -1268,8 +1217,7 @@ describe('EditImageModal', () => {
|
|
|
1268
1217
|
describe('Image Dimensions Fieldset', () => {
|
|
1269
1218
|
beforeEach(() => {
|
|
1270
1219
|
editImageModal.setState({
|
|
1271
|
-
|
|
1272
|
-
shouldShowPreviousButton: true,
|
|
1220
|
+
imageSource: sampleText,
|
|
1273
1221
|
});
|
|
1274
1222
|
});
|
|
1275
1223
|
|
|
@@ -1348,8 +1296,6 @@ describe('EditImageModal', () => {
|
|
|
1348
1296
|
beforeEach(() => {
|
|
1349
1297
|
editImageModal.setState({
|
|
1350
1298
|
imageSource: sampleText,
|
|
1351
|
-
pageNumber: 2,
|
|
1352
|
-
shouldShowPreviousButton: true,
|
|
1353
1299
|
});
|
|
1354
1300
|
|
|
1355
1301
|
getModalBody(editImageModal).find('img').simulate('load', { target: { ...sampleImgData } });
|
|
@@ -1381,8 +1327,6 @@ describe('EditImageModal', () => {
|
|
|
1381
1327
|
beforeEach(() => {
|
|
1382
1328
|
editImageModal.setState({
|
|
1383
1329
|
imageSource: sampleText,
|
|
1384
|
-
pageNumber: 2,
|
|
1385
|
-
shouldShowPreviousButton: true,
|
|
1386
1330
|
});
|
|
1387
1331
|
|
|
1388
1332
|
getImageDimensionsCheckBox(editImageModal).simulate('change', false);
|
|
@@ -1414,54 +1358,39 @@ describe('EditImageModal', () => {
|
|
|
1414
1358
|
});
|
|
1415
1359
|
});
|
|
1416
1360
|
|
|
1417
|
-
describe('
|
|
1361
|
+
describe('Save button', () => {
|
|
1418
1362
|
beforeEach(() => {
|
|
1419
|
-
editImageModal.setState({
|
|
1420
|
-
pageNumber: 1,
|
|
1421
|
-
shouldShowPreviousButton: true,
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
1363
|
editImageModal.setProps({
|
|
1425
1364
|
selectedAsset: {
|
|
1426
1365
|
portable_url: 'foo',
|
|
1427
1366
|
},
|
|
1428
1367
|
});
|
|
1429
|
-
const refMock = {
|
|
1430
|
-
focus: jest.fn(),
|
|
1431
|
-
};
|
|
1432
1368
|
|
|
1433
|
-
editImageModal.instance().
|
|
1369
|
+
editImageModal.instance().setImageFormRef({
|
|
1370
|
+
dispatchEvent: jest.fn(),
|
|
1371
|
+
});
|
|
1434
1372
|
});
|
|
1435
1373
|
|
|
1436
|
-
it('
|
|
1437
|
-
const
|
|
1438
|
-
editImageModal.
|
|
1439
|
-
|
|
1374
|
+
it('submits when the description is empty', () => {
|
|
1375
|
+
const dispatchEvent = jest.fn();
|
|
1376
|
+
editImageModal.instance().setImageFormRef({
|
|
1377
|
+
dispatchEvent,
|
|
1440
1378
|
});
|
|
1441
1379
|
|
|
1442
1380
|
getNextButton(editImageModal).simulate('click');
|
|
1443
1381
|
editImageModal.update();
|
|
1444
1382
|
|
|
1383
|
+
expect(editImageModal.state('isModalOpen')).toEqual(false);
|
|
1384
|
+
expect(editImageModal.state('isImageDescriptionValid')).toEqual(true);
|
|
1445
1385
|
expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
|
|
1446
|
-
expect(
|
|
1447
|
-
expect(
|
|
1448
|
-
expect(clearAssetsStatusSpy).toHaveBeenCalledTimes(1);
|
|
1386
|
+
expect(dispatchEvent).toHaveBeenCalledTimes(1);
|
|
1387
|
+
expect(dispatchEvent.mock.calls[0][0].detail.alt).toEqual('');
|
|
1449
1388
|
});
|
|
1450
1389
|
|
|
1451
|
-
it('
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
focus: focusSpy,
|
|
1390
|
+
it('closes the status alert when the form is valid', () => {
|
|
1391
|
+
editImageModal.setState({
|
|
1392
|
+
imageDescription: sampleText,
|
|
1455
1393
|
});
|
|
1456
|
-
|
|
1457
|
-
getNextButton(editImageModal).simulate('click');
|
|
1458
|
-
editImageModal.update();
|
|
1459
|
-
|
|
1460
|
-
editImageModal.instance().componentDidUpdate({}, { pageNumber: 1 });
|
|
1461
|
-
expect(focusSpy).toHaveBeenCalledTimes(1);
|
|
1462
|
-
});
|
|
1463
|
-
|
|
1464
|
-
it('closes statusAlert', () => {
|
|
1465
1394
|
editImageModal.setProps({
|
|
1466
1395
|
assetsStatus: {
|
|
1467
1396
|
type: assetActions.upload.UPLOAD_EXCEED_MAX_COUNT_ERROR,
|
|
@@ -1478,52 +1407,19 @@ describe('EditImageModal', () => {
|
|
|
1478
1407
|
});
|
|
1479
1408
|
});
|
|
1480
1409
|
|
|
1481
|
-
describe('Previous/Back button', () => {
|
|
1482
|
-
beforeEach(() => {
|
|
1483
|
-
editImageModal.setState({
|
|
1484
|
-
pageNumber: 2,
|
|
1485
|
-
shouldShowPreviousButton: true,
|
|
1486
|
-
});
|
|
1487
|
-
const refMock = {
|
|
1488
|
-
focus: jest.fn(),
|
|
1489
|
-
};
|
|
1490
|
-
|
|
1491
|
-
editImageModal.instance().setDropZoneButtonRef(refMock);
|
|
1492
|
-
});
|
|
1493
|
-
|
|
1494
|
-
it('goes to page 1', () => {
|
|
1495
|
-
getPreviousButton(editImageModal).simulate('click');
|
|
1496
|
-
editImageModal.update();
|
|
1497
|
-
|
|
1498
|
-
expect(editImageModal.state('pageNumber')).toEqual(1);
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
|
-
it('focuses on Upload button', () => {
|
|
1502
|
-
const focusSpy = jest.fn();
|
|
1503
|
-
editImageModal.instance().setDropZoneButtonRef({
|
|
1504
|
-
focus: focusSpy,
|
|
1505
|
-
});
|
|
1506
|
-
|
|
1507
|
-
getPreviousButton(editImageModal).simulate('click');
|
|
1508
|
-
editImageModal.update();
|
|
1509
|
-
|
|
1510
|
-
editImageModal.instance().componentDidUpdate({}, { isModalOpen: true, pageNumber: 2 });
|
|
1511
|
-
expect(focusSpy).toHaveBeenCalledTimes(1);
|
|
1512
|
-
});
|
|
1513
|
-
});
|
|
1514
|
-
|
|
1515
1410
|
describe('Insert Image button', () => {
|
|
1516
1411
|
let validationMock;
|
|
1517
1412
|
let dispatchEventSpy;
|
|
1518
1413
|
|
|
1519
1414
|
beforeEach(() => {
|
|
1520
|
-
editImageModal.setState({
|
|
1521
|
-
pageNumber: 2,
|
|
1522
|
-
shouldShowPreviousButton: true,
|
|
1523
|
-
});
|
|
1524
|
-
|
|
1525
1415
|
dispatchEventSpy = jest.fn();
|
|
1526
1416
|
|
|
1417
|
+
editImageModal.setProps({
|
|
1418
|
+
selectedAsset: {
|
|
1419
|
+
id: 'selected-image',
|
|
1420
|
+
},
|
|
1421
|
+
});
|
|
1422
|
+
|
|
1527
1423
|
editImageModal.instance().setImageFormRef({
|
|
1528
1424
|
dispatchEvent: dispatchEventSpy,
|
|
1529
1425
|
});
|