learningtribes-studio-frontend 1.4.2-alpha.4 → 1.4.2-alpha.5

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.
@@ -1,5 +1,5 @@
1
1
  import { Button, CheckBox, Fieldset, Modal, InputText, StatusAlert, Variant } from '@edx/paragon';
2
- import { IntlProvider, FormattedMessage } from 'react-intl';
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('a header', () => {
163
- const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('tagName') === 'h3');
164
- expect(header).toHaveLength(1);
165
- expect(header.prop('message')).toEqual(messages.editImageModalInsertHeader);
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('a header', () => {
222
- const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('tagName') === 'h3');
223
- expect(header).toHaveLength(1);
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('an AssetsSearch component', () => {
232
- expect(getModalBody(editImageModal).find('Connect(AssetsSearch)')).toHaveLength(1);
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('a AssetsResultsCount component', () => {
240
- expect(getModalBody(editImageModal).find('Connect(AssetsResultsCount)')).toHaveLength(1);
238
+ it('no AssetsResultsCount component', () => {
239
+ expect(getModalBody(editImageModal).find('Connect(AssetsResultsCount)')).toHaveLength(0);
241
240
  });
242
241
 
243
- it('a Pagination component', () => {
244
- expect(getModalBody(editImageModal).find('Connect(InjectIntl(Pagination))')).toHaveLength(1);
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('a header', () => {
267
- const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('tagName') === 'h3').at(0);
268
- expect(header).toHaveLength(1);
269
- expect(header.prop('message')).toEqual(messages.editImageModalInsertHeader);
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
- expect(getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('tagName') === 'h3').at(1)
274
- .prop('message')).toEqual(messages.editImageModalAssetsListNoResultsMessage);
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('an AssetsSearch component', () => {
282
- expect(getModalBody(editImageModal).find('Connect(AssetsSearch)')).toHaveLength(1);
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,10 +316,11 @@ describe('EditImageModal', () => {
314
316
  expect(getModalBody(editImageModal).find('Connect(AssetsDropZone)'));
315
317
  });
316
318
 
317
- it('a header', () => {
318
- const header = getModalBody(editImageModal).find(WrappedMessage).filterWhere(message => message.prop('tagName') === 'h3').at(0);
319
- expect(header).toHaveLength(1);
320
- expect(header.prop('message')).toEqual(messages.editImageModalInsertHeader);
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
326
  it('no empty-state message', () => {
@@ -356,8 +359,7 @@ describe('EditImageModal', () => {
356
359
  beforeEach(() => {
357
360
  editImageModal.setState({
358
361
  open: true,
359
- pageNumber: 2,
360
- shouldShowPreviousButton: true,
362
+ imageSource: sampleText,
361
363
  });
362
364
  });
363
365
 
@@ -369,7 +371,7 @@ describe('EditImageModal', () => {
369
371
  const modal = getModal(editImageModal);
370
372
 
371
373
  expect(modal.prop('open')).toEqual(false);
372
- expect(shallowWithIntl(modal.prop('title')).find(WrappedMessage).prop('message')).toEqual(messages.editImageModalEditTitle);
374
+ expect(shallowWithIntl(modal.prop('title')).find(WrappedMessage).prop('message')).toEqual(messages.editImageModalInsertTitle);
373
375
  expect(shallowWithIntl(modal.prop('closeText')).prop('message')).toEqual(messages.editImageModalCancelButton);
374
376
  });
375
377
 
@@ -390,30 +392,9 @@ describe('EditImageModal', () => {
390
392
 
391
393
  it('a StatusAlert component with correct initial props', () => {
392
394
  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
395
  expect(getStatusAlert(editImageModal).prop('open')).toEqual(false);
396
396
  });
397
397
 
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
398
  describe('a form with', () => {
418
399
  it('a form', () => {
419
400
  expect(getFormContainer(editImageModal)).toHaveLength(1);
@@ -594,8 +575,6 @@ describe('EditImageModal', () => {
594
575
  expect(editImageModal.state('isImageLoading')).toEqual(false);
595
576
  expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
596
577
  expect(editImageModal.state('isModalOpen')).toEqual(false);
597
- expect(editImageModal.state('pageNumber')).toEqual(1);
598
- expect(editImageModal.state('shouldShowPreviousButton')).toEqual(false);
599
578
  });
600
579
 
601
580
  it('handleOpenModal sets correct state for empty event (inserting an image) with assets', () => {
@@ -621,8 +600,6 @@ describe('EditImageModal', () => {
621
600
  expect(editImageModal.state('isImageLoading')).toEqual(false);
622
601
  expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
623
602
  expect(editImageModal.state('isModalOpen')).toEqual(true);
624
- expect(editImageModal.state('pageNumber')).toEqual(1);
625
- expect(editImageModal.state('shouldShowPreviousButton')).toEqual(true);
626
603
  });
627
604
 
628
605
  it('handleOpenModal sets correct state for empty event (inserting an image) without assets', () => {
@@ -644,8 +621,6 @@ describe('EditImageModal', () => {
644
621
  expect(editImageModal.state('isImageLoading')).toEqual(false);
645
622
  expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
646
623
  expect(editImageModal.state('isModalOpen')).toEqual(true);
647
- expect(editImageModal.state('pageNumber')).toEqual(1);
648
- expect(editImageModal.state('shouldShowPreviousButton')).toEqual(true);
649
624
  });
650
625
 
651
626
  it('handleOpenModal sets correct state for event with data (editing an image)', () => {
@@ -683,8 +658,7 @@ describe('EditImageModal', () => {
683
658
  expect(editImageModal.state('isImageLoading')).toEqual(false);
684
659
  expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
685
660
  expect(editImageModal.state('isModalOpen')).toEqual(true);
686
- expect(editImageModal.state('pageNumber')).toEqual(2);
687
- expect(editImageModal.state('shouldShowPreviousButton')).toEqual(false);
661
+ expect(editImageModal.state('editingExisting')).toEqual(true);
688
662
  });
689
663
 
690
664
  it('onEditImageModalClose sets this.state.open to false', () => {
@@ -704,11 +678,6 @@ describe('EditImageModal', () => {
704
678
  });
705
679
 
706
680
  it('onEditImageModalClose sets this.state.isModalOpen to false', () => {
707
- editImageModal.setState({
708
- pageNumber: 2,
709
- shouldShowPreviousButton: true,
710
- });
711
-
712
681
  const focusSpy = jest.fn();
713
682
  editImageModal.instance().setModalWrapperRef({
714
683
  dispatchEvent: jest.fn(),
@@ -790,11 +759,6 @@ describe('EditImageModal', () => {
790
759
 
791
760
  editImageModal.instance().setDropZoneButtonRef(refMock);
792
761
  editImageModal.instance().setStatusAlertRef(refMock);
793
-
794
- editImageModal.setState({
795
- pageNumber: 1,
796
- shouldShowPreviousButton: true,
797
- });
798
762
  });
799
763
 
800
764
  it('this.state.isStatusAlertOpen is false by default', () => {
@@ -881,13 +845,7 @@ describe('EditImageModal', () => {
881
845
  focus: jest.fn(),
882
846
  };
883
847
 
884
- editImageModal.instance().setPreviousButtonRef(refMock);
885
848
  editImageModal.instance().setStatusAlertRef(refMock);
886
-
887
- editImageModal.setState({
888
- pageNumber: 2,
889
- shouldShowPreviousButton: true,
890
- });
891
849
  });
892
850
 
893
851
  it('this.state.isStatusAlertOpen is false by default', () => {
@@ -895,13 +853,27 @@ describe('EditImageModal', () => {
895
853
  expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
896
854
  });
897
855
 
898
- it('this.state.isStatusAlertOpen is true if invalid form submitted', () => {
856
+ it('this.state.isStatusAlertOpen is true if invalid dimensions are submitted', () => {
857
+ editImageModal.setState({
858
+ imageDimensions: {
859
+ height: -1 * sampleImgData.height,
860
+ width: -1 * sampleImgData.width,
861
+ },
862
+ });
863
+
899
864
  getInsertImageButton(editImageModal).simulate('click');
900
865
 
901
866
  expect(editImageModal.state('isStatusAlertOpen')).toEqual(true);
902
867
  });
903
868
 
904
- it('status alert is displayed if invalid form submitted', () => {
869
+ it('status alert is displayed if invalid dimensions are submitted', () => {
870
+ editImageModal.setState({
871
+ imageDimensions: {
872
+ height: -1 * sampleImgData.height,
873
+ width: -1 * sampleImgData.width,
874
+ },
875
+ });
876
+
905
877
  getInsertImageButton(editImageModal).simulate('click');
906
878
 
907
879
  editImageModal.update();
@@ -910,6 +882,13 @@ describe('EditImageModal', () => {
910
882
  });
911
883
 
912
884
  it('StatusAlert open prop is false when status alert is closed', () => {
885
+ editImageModal.setState({
886
+ imageDimensions: {
887
+ height: -1 * sampleImgData.height,
888
+ width: -1 * sampleImgData.width,
889
+ },
890
+ });
891
+
913
892
  getInsertImageButton(editImageModal).simulate('click');
914
893
 
915
894
  getCloseStatusAlertButton(editImageModal).simulate('click');
@@ -958,6 +937,7 @@ describe('EditImageModal', () => {
958
937
 
959
938
  it('status alert has correct validation message when invalid dimensions submitted', () => {
960
939
  editImageModal.setState({
940
+ imageDescription: sampleText,
961
941
  imageDimensions: {
962
942
  height: (-1 * sampleImgData.naturalHeight),
963
943
  width: (-1 * sampleImgData.naturalWidth),
@@ -975,6 +955,7 @@ describe('EditImageModal', () => {
975
955
 
976
956
  it('validation messages are hyperlinks that navigate to appropriate form elements', () => {
977
957
  editImageModal.setState({
958
+ imageDescription: sampleText,
978
959
  imageDimensions: {
979
960
  height: (-1 * sampleImgData.naturalHeight),
980
961
  width: (-1 * sampleImgData.naturalWidth),
@@ -1009,13 +990,20 @@ describe('EditImageModal', () => {
1009
990
  expect(statusAlertListItems.at(0).find(WrappedMessage).prop('message')).toEqual(messages.editImageModalFormValidImageDimensions);
1010
991
  });
1011
992
 
1012
- it('focus on page 2 is moved to previous button when status alert is closed', () => {
993
+ it('focuses the image description input when a validation alert is closed', () => {
1013
994
  const focusSpy = jest.fn();
1014
995
 
1015
- editImageModal.instance().setPreviousButtonRef({
996
+ editImageModal.instance().setImageDescriptionInputRef({
1016
997
  focus: focusSpy,
1017
998
  });
1018
999
 
1000
+ editImageModal.setState({
1001
+ imageDimensions: {
1002
+ height: -1 * sampleImgData.height,
1003
+ width: -1 * sampleImgData.width,
1004
+ },
1005
+ });
1006
+
1019
1007
  getInsertImageButton(editImageModal).simulate('click');
1020
1008
 
1021
1009
  getCloseStatusAlertButton(editImageModal).simulate('click');
@@ -1026,6 +1014,10 @@ describe('EditImageModal', () => {
1026
1014
  it('focus on page 2 is moved to image description input when status alert is closed and previous button is not shown', () => {
1027
1015
  editImageModal.setState({
1028
1016
  shouldShowPreviousButton: false,
1017
+ imageDimensions: {
1018
+ height: -1 * sampleImgData.height,
1019
+ width: -1 * sampleImgData.width,
1020
+ },
1029
1021
  });
1030
1022
 
1031
1023
  const focusSpy = jest.fn();
@@ -1050,8 +1042,7 @@ describe('EditImageModal', () => {
1050
1042
 
1051
1043
  editImageModal.setState({
1052
1044
  open: true,
1053
- pageNumber: 2,
1054
- shouldShowPreviousButton: true,
1045
+ imageSource: sampleText,
1055
1046
  });
1056
1047
  });
1057
1048
 
@@ -1101,13 +1092,7 @@ describe('EditImageModal', () => {
1101
1092
  };
1102
1093
 
1103
1094
  editImageModal.instance().setDropZoneButtonRef(refMock);
1104
- editImageModal.instance().setPreviousButtonRef(refMock);
1105
1095
  editImageModal.instance().setStatusAlertRef(refMock);
1106
-
1107
- editImageModal.setState({
1108
- pageNumber: 1,
1109
- shouldShowPreviousButton: true,
1110
- });
1111
1096
  });
1112
1097
 
1113
1098
  it('state updated correctly on upload success', () => {
@@ -1131,7 +1116,7 @@ describe('EditImageModal', () => {
1131
1116
  expect(selectAssetSpy).toHaveBeenCalledTimes(1);
1132
1117
  expect(selectAssetSpy).toHaveBeenCalledWith(assetsStatusMock.response.asset, 0);
1133
1118
  expect(clearAssetsStatusSpy).toHaveBeenCalledTimes(1);
1134
- expect(editImageModal.state('pageNumber')).toEqual(2);
1119
+ expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
1135
1120
  });
1136
1121
 
1137
1122
  describe('AssetsDropZone', () => {
@@ -1145,13 +1130,6 @@ describe('EditImageModal', () => {
1145
1130
  });
1146
1131
 
1147
1132
  describe('Image Preview', () => {
1148
- beforeEach(() => {
1149
- editImageModal.setState({
1150
- pageNumber: 2,
1151
- shouldShowPreviousButton: true,
1152
- });
1153
- });
1154
-
1155
1133
  it('correct state is set on image load', () => {
1156
1134
  editImageModal.setState({
1157
1135
  imageSource: sampleText,
@@ -1181,57 +1159,6 @@ describe('EditImageModal', () => {
1181
1159
  expect(editImageModal.state('isImageLoaded')).toEqual(false);
1182
1160
  expect(editImageModal.state('isImageLoading')).toEqual(false);
1183
1161
  });
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
1162
  });
1236
1163
 
1237
1164
  describe('Image Description Fieldset', () => {
@@ -1241,12 +1168,10 @@ describe('EditImageModal', () => {
1241
1168
  };
1242
1169
 
1243
1170
  editImageModal.instance().setImageDescriptionInputRef(refMock);
1244
- editImageModal.instance().setPreviousButtonRef(refMock);
1245
1171
  editImageModal.instance().setStatusAlertRef(refMock);
1246
1172
 
1247
1173
  editImageModal.setState({
1248
- pageNumber: 2,
1249
- shouldShowPreviousButton: true,
1174
+ imageSource: sampleText,
1250
1175
  });
1251
1176
  });
1252
1177
 
@@ -1268,8 +1193,7 @@ describe('EditImageModal', () => {
1268
1193
  describe('Image Dimensions Fieldset', () => {
1269
1194
  beforeEach(() => {
1270
1195
  editImageModal.setState({
1271
- pageNumber: 2,
1272
- shouldShowPreviousButton: true,
1196
+ imageSource: sampleText,
1273
1197
  });
1274
1198
  });
1275
1199
 
@@ -1348,8 +1272,6 @@ describe('EditImageModal', () => {
1348
1272
  beforeEach(() => {
1349
1273
  editImageModal.setState({
1350
1274
  imageSource: sampleText,
1351
- pageNumber: 2,
1352
- shouldShowPreviousButton: true,
1353
1275
  });
1354
1276
 
1355
1277
  getModalBody(editImageModal).find('img').simulate('load', { target: { ...sampleImgData } });
@@ -1381,8 +1303,6 @@ describe('EditImageModal', () => {
1381
1303
  beforeEach(() => {
1382
1304
  editImageModal.setState({
1383
1305
  imageSource: sampleText,
1384
- pageNumber: 2,
1385
- shouldShowPreviousButton: true,
1386
1306
  });
1387
1307
 
1388
1308
  getImageDimensionsCheckBox(editImageModal).simulate('change', false);
@@ -1414,54 +1334,32 @@ describe('EditImageModal', () => {
1414
1334
  });
1415
1335
  });
1416
1336
 
1417
- describe('Next button', () => {
1337
+ describe('Save button', () => {
1418
1338
  beforeEach(() => {
1419
- editImageModal.setState({
1420
- pageNumber: 1,
1421
- shouldShowPreviousButton: true,
1422
- });
1423
-
1424
1339
  editImageModal.setProps({
1425
1340
  selectedAsset: {
1426
1341
  portable_url: 'foo',
1427
1342
  },
1428
1343
  });
1429
- const refMock = {
1430
- focus: jest.fn(),
1431
- };
1432
-
1433
- editImageModal.instance().setPreviousButtonRef(refMock);
1434
- });
1435
1344
 
1436
- it('goes to page 2', () => {
1437
- const clearAssetsStatusSpy = jest.fn();
1438
- editImageModal.setProps({
1439
- clearAssetsStatus: clearAssetsStatusSpy,
1345
+ editImageModal.instance().setImageFormRef({
1346
+ dispatchEvent: jest.fn(),
1440
1347
  });
1441
-
1442
- getNextButton(editImageModal).simulate('click');
1443
- editImageModal.update();
1444
-
1445
- expect(editImageModal.state('isStatusAlertOpen')).toEqual(false);
1446
- expect(editImageModal.state('pageNumber')).toEqual(2);
1447
- expect(editImageModal.state('uploadErrorMessageBody')).toBeUndefined();
1448
- expect(clearAssetsStatusSpy).toHaveBeenCalledTimes(1);
1449
1348
  });
1450
1349
 
1451
- it('focuses on Previous/Back button', () => {
1452
- const focusSpy = jest.fn();
1453
- editImageModal.instance().setPreviousButtonRef({
1454
- focus: focusSpy,
1455
- });
1456
-
1350
+ it('does not submit when the description is empty', () => {
1457
1351
  getNextButton(editImageModal).simulate('click');
1458
1352
  editImageModal.update();
1459
1353
 
1460
- editImageModal.instance().componentDidUpdate({}, { pageNumber: 1 });
1461
- expect(focusSpy).toHaveBeenCalledTimes(1);
1354
+ expect(editImageModal.state('isModalOpen')).toEqual(false);
1355
+ expect(editImageModal.state('isImageDescriptionValid')).toEqual(false);
1356
+ expect(editImageModal.state('isStatusAlertOpen')).toEqual(true);
1462
1357
  });
1463
1358
 
1464
- it('closes statusAlert', () => {
1359
+ it('closes the status alert when the form is valid', () => {
1360
+ editImageModal.setState({
1361
+ imageDescription: sampleText,
1362
+ });
1465
1363
  editImageModal.setProps({
1466
1364
  assetsStatus: {
1467
1365
  type: assetActions.upload.UPLOAD_EXCEED_MAX_COUNT_ERROR,
@@ -1478,52 +1376,19 @@ describe('EditImageModal', () => {
1478
1376
  });
1479
1377
  });
1480
1378
 
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
1379
  describe('Insert Image button', () => {
1516
1380
  let validationMock;
1517
1381
  let dispatchEventSpy;
1518
1382
 
1519
1383
  beforeEach(() => {
1520
- editImageModal.setState({
1521
- pageNumber: 2,
1522
- shouldShowPreviousButton: true,
1523
- });
1524
-
1525
1384
  dispatchEventSpy = jest.fn();
1526
1385
 
1386
+ editImageModal.setProps({
1387
+ selectedAsset: {
1388
+ id: 'selected-image',
1389
+ },
1390
+ });
1391
+
1527
1392
  editImageModal.instance().setImageFormRef({
1528
1393
  dispatchEvent: dispatchEventSpy,
1529
1394
  });
@@ -33,7 +33,7 @@ const messages = defineMessages({
33
33
  },
34
34
  editImageModalFormValidImageDescription: {
35
35
  id: 'editImageModalFormValidImageDescription',
36
- defaultMessage: 'Add an image description or specify that the image is decorative only.',
36
+ defaultMessage: 'Add an image description.',
37
37
  description: 'Error message for when an invalid image description is entered into the form',
38
38
  },
39
39
  editImageModalFormValidImageDimensions: {
@@ -51,11 +51,6 @@ const messages = defineMessages({
51
51
  defaultMessage: 'Image Description',
52
52
  description: 'Label for the text input box for an image\'s description',
53
53
  },
54
- editImageModalImageDecorativeDescription: {
55
- id: 'editImageModalImageDecorativeDescription',
56
- defaultMessage: 'If this image is purely decorative, it does not require alternative text.',
57
- description: 'Help text shown under the image description when alternative text is optional',
58
- },
59
54
  editImageModalImageDescriptionLegend: {
60
55
  id: 'editImageModalImageDescriptionLegend',
61
56
  defaultMessage: 'Image Description',