@@ -264,3 +264,134 @@ test('can edit the URL picker in the content', async ({umbracoApi, umbracoUi}) =
264
264
expect ( contentData . values [ 0 ] . value [ 0 ] . name ) . toEqual ( updatedLinkTitle ) ;
265
265
expect ( contentData . values [ 0 ] . value [ 0 ] . url ) . toEqual ( link ) ;
266
266
} ) ;
267
+
268
+ test ( 'cannot submit an empty link' , async ( { umbracoApi, umbracoUi} ) => {
269
+ // Arrange
270
+ const dataTypeData = await umbracoApi . dataType . getByName ( dataTypeName ) ;
271
+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , dataTypeName , dataTypeData . id ) ;
272
+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
273
+ await umbracoUi . goToBackOffice ( ) ;
274
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
275
+
276
+ // Act
277
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
278
+ await umbracoUi . content . clickAddMultiURLPickerButton ( ) ;
279
+ await umbracoUi . content . clickManualLinkButton ( ) ;
280
+ await umbracoUi . content . enterLink ( '' ) ;
281
+ await umbracoUi . content . enterAnchorOrQuerystring ( '' ) ;
282
+ await umbracoUi . content . enterLinkTitle ( '' ) ;
283
+ await umbracoUi . content . clickAddButton ( ) ;
284
+
285
+ // Assert
286
+ await umbracoUi . content . isTextWithMessageVisible ( ConstantHelper . validationMessages . emptyLinkPicker ) ;
287
+ } ) ;
288
+
289
+ test ( 'cannot update the URL picker with an empty link' , async ( { umbracoApi, umbracoUi} ) => {
290
+ // Arrange
291
+ const dataTypeData = await umbracoApi . dataType . getByName ( dataTypeName ) ;
292
+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , dataTypeName , dataTypeData . id ) ;
293
+ await umbracoApi . document . createDocumentWithExternalLinkURLPicker ( contentName , documentTypeId , link , linkTitle ) ;
294
+ await umbracoUi . goToBackOffice ( ) ;
295
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
296
+
297
+ // Act
298
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
299
+ await umbracoUi . content . clickLinkWithName ( linkTitle ) ;
300
+ await umbracoUi . content . enterLink ( '' ) ;
301
+ await umbracoUi . content . enterAnchorOrQuerystring ( '' ) ;
302
+ await umbracoUi . content . enterLinkTitle ( '' ) ;
303
+ await umbracoUi . content . clickUpdateButton ( ) ;
304
+
305
+ // Assert
306
+ await umbracoUi . content . isTextWithMessageVisible ( ConstantHelper . validationMessages . emptyLinkPicker ) ;
307
+ } ) ;
308
+
309
+ // TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
310
+ // Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
311
+ test . skip ( 'cannot submit an empty URL with an anchor or query' , async ( { umbracoApi, umbracoUi} ) => {
312
+ // Arrange
313
+ const dataTypeData = await umbracoApi . dataType . getByName ( dataTypeName ) ;
314
+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , dataTypeName , dataTypeData . id ) ;
315
+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
316
+ await umbracoUi . goToBackOffice ( ) ;
317
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
318
+
319
+ // Act
320
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
321
+ await umbracoUi . content . clickAddMultiURLPickerButton ( ) ;
322
+ await umbracoUi . content . clickManualLinkButton ( ) ;
323
+ await umbracoUi . content . enterLink ( '' ) ;
324
+ await umbracoUi . content . enterAnchorOrQuerystring ( '#value' ) ;
325
+ await umbracoUi . content . clickAddButton ( ) ;
326
+
327
+ // Assert
328
+ await umbracoUi . content . isTextWithMessageVisible ( ConstantHelper . validationMessages . emptyLinkPicker ) ;
329
+ } ) ;
330
+
331
+ // TODO: Remove skip when the front-end ready. Currently it still accept the empty link using spacebar
332
+ // Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
333
+ test . skip ( 'cannot submit an empty link using spacebar' , async ( { umbracoApi, umbracoUi} ) => {
334
+ // Arrange
335
+ const dataTypeData = await umbracoApi . dataType . getByName ( dataTypeName ) ;
336
+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , dataTypeName , dataTypeData . id ) ;
337
+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
338
+ await umbracoUi . goToBackOffice ( ) ;
339
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
340
+
341
+ // Act
342
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
343
+ await umbracoUi . content . clickAddMultiURLPickerButton ( ) ;
344
+ await umbracoUi . content . clickManualLinkButton ( ) ;
345
+ await umbracoUi . content . enterLink ( 'Space' , true ) ;
346
+ await umbracoUi . content . enterAnchorOrQuerystring ( 'Space' , true ) ;
347
+ await umbracoUi . content . enterLinkTitle ( 'Space' , true ) ;
348
+ await umbracoUi . content . clickAddButton ( ) ;
349
+
350
+ // Assert
351
+ await umbracoUi . content . isTextWithMessageVisible ( ConstantHelper . validationMessages . emptyLinkPicker ) ;
352
+ } ) ;
353
+
354
+ // TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
355
+ // Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
356
+ test . skip ( 'can create content with the link to an unpublished document' , async ( { umbracoApi, umbracoUi} ) => {
357
+ // Arrange
358
+ const expectedState = 'Draft' ;
359
+ const dataTypeData = await umbracoApi . dataType . getByName ( dataTypeName ) ;
360
+ await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , dataTypeName , dataTypeData . id ) ;
361
+ // Create a document to link
362
+ const documentTypeForLinkedDocumentName = 'TestDocumentType' ;
363
+ const documentTypeForLinkedDocumentId = await umbracoApi . documentType . createDefaultDocumentTypeWithAllowAsRoot ( documentTypeForLinkedDocumentName ) ;
364
+ const linkedDocumentName = 'LinkedDocument' ;
365
+ const linkedDocumentId = await umbracoApi . document . createDefaultDocument ( linkedDocumentName , documentTypeForLinkedDocumentId ) ;
366
+ await umbracoUi . goToBackOffice ( ) ;
367
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
368
+
369
+ // Act
370
+ await umbracoUi . content . clickActionsMenuAtRoot ( ) ;
371
+ await umbracoUi . content . clickCreateButton ( ) ;
372
+ await umbracoUi . content . chooseDocumentType ( documentTypeName ) ;
373
+ await umbracoUi . content . enterContentName ( contentName ) ;
374
+ await umbracoUi . content . clickAddMultiURLPickerButton ( ) ;
375
+ await umbracoUi . content . clickDocumentLinkButton ( ) ;
376
+ await umbracoUi . content . selectLinkByName ( linkedDocumentName ) ;
377
+ await umbracoUi . content . clickButtonWithName ( 'Choose' ) ;
378
+ await umbracoUi . content . clickAddButton ( ) ;
379
+ await umbracoUi . content . clickSaveButton ( ) ;
380
+
381
+ // Assert
382
+ await umbracoUi . content . isSuccessNotificationVisible ( ) ;
383
+ expect ( await umbracoApi . document . doesNameExist ( contentName ) ) . toBeTruthy ( ) ;
384
+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
385
+ expect ( contentData . variants [ 0 ] . state ) . toBe ( expectedState ) ;
386
+ expect ( contentData . values [ 0 ] . alias ) . toEqual ( AliasHelper . toAlias ( dataTypeName ) ) ;
387
+ expect ( contentData . values [ 0 ] . value . length ) . toBe ( 1 ) ;
388
+ expect ( contentData . values [ 0 ] . value [ 0 ] . type ) . toEqual ( 'document' ) ;
389
+ expect ( contentData . values [ 0 ] . value [ 0 ] . icon ) . toEqual ( 'icon-document' ) ;
390
+ expect ( contentData . values [ 0 ] . value [ 0 ] . target ) . toBeNull ( ) ;
391
+ expect ( contentData . values [ 0 ] . value [ 0 ] . unique ) . toEqual ( linkedDocumentId ) ;
392
+ expect ( contentData . values [ 0 ] . value [ 0 ] . name ) . toEqual ( linkedDocumentName ) ;
393
+
394
+ // Clean
395
+ await umbracoApi . documentType . ensureNameNotExists ( documentTypeForLinkedDocumentName ) ;
396
+ await umbracoApi . document . ensureNameNotExists ( linkedDocumentName ) ;
397
+ } ) ;
0 commit comments