1
+ import { ConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
2
+ import { expect } from "@playwright/test" ;
3
+
4
+ let collectionId = '' ;
5
+ const contentName = 'TestContent' ;
6
+ const documentTypeName = 'TestDocumentTypeForContent' ;
7
+ const childDocumentTypeName = 'TestChildDocumentType' ;
8
+ const firstChildContentName = 'First Child Content' ;
9
+ const secondChildContentName = 'Second Child Content' ;
10
+ const collectionDataTypeName = 'List View - Content' ;
11
+ const referenceHeadline = ConstantHelper . trashDeleteDialogMessage . bulkReferenceHeadline ;
12
+ const documentPickerName = [ 'TestPicker' , 'DocumentTypeForPicker' ] ;
13
+
14
+ test . beforeEach ( async ( { umbracoApi} ) => {
15
+ await umbracoApi . documentType . ensureNameNotExists ( documentTypeName ) ;
16
+ await umbracoApi . document . ensureNameNotExists ( contentName ) ;
17
+ const collectionDataTypeData = await umbracoApi . dataType . getByName ( collectionDataTypeName ) ;
18
+ collectionId = collectionDataTypeData . id ;
19
+ } ) ;
20
+
21
+ test . afterEach ( async ( { umbracoApi} ) => {
22
+ await umbracoApi . document . ensureNameNotExists ( contentName ) ;
23
+ await umbracoApi . documentType . ensureNameNotExists ( documentTypeName ) ;
24
+ await umbracoApi . documentType . ensureNameNotExists ( childDocumentTypeName ) ;
25
+ await umbracoApi . document . emptyRecycleBin ( ) ;
26
+ } ) ;
27
+
28
+ test ( 'can bulk trash content nodes without a relation' , async ( { umbracoApi, umbracoUi} ) => {
29
+ // Arrange
30
+ const childDocumentTypeId = await umbracoApi . documentType . createDefaultDocumentType ( childDocumentTypeName ) ;
31
+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithAllowedChildNodeAndCollectionId ( documentTypeName , childDocumentTypeId , collectionId ) ;
32
+ const contentId = await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
33
+ await umbracoApi . document . createDefaultDocumentWithParent ( firstChildContentName , childDocumentTypeId , contentId ) ;
34
+ await umbracoApi . document . createDefaultDocumentWithParent ( secondChildContentName , childDocumentTypeId , contentId ) ;
35
+ await umbracoUi . goToBackOffice ( ) ;
36
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
37
+
38
+ // Act
39
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
40
+ await umbracoUi . content . selectContentWithNameInListView ( firstChildContentName ) ;
41
+ await umbracoUi . content . selectContentWithNameInListView ( secondChildContentName ) ;
42
+ await umbracoUi . content . clickTrashSelectedListItems ( ) ;
43
+ // Verify the references list not displayed
44
+ await umbracoUi . content . isReferenceHeadlineVisible ( false ) ;
45
+ await umbracoUi . content . clickConfirmTrashButton ( ) ;
46
+
47
+ // // Assert
48
+ await umbracoUi . content . isSuccessNotificationVisible ( ) ;
49
+ expect ( await umbracoApi . document . doesNameExist ( firstChildContentName ) ) . toBeFalsy ( ) ;
50
+ expect ( await umbracoApi . document . doesNameExist ( secondChildContentName ) ) . toBeFalsy ( ) ;
51
+ await umbracoUi . content . isItemVisibleInRecycleBin ( firstChildContentName ) ;
52
+ await umbracoUi . content . isItemVisibleInRecycleBin ( secondChildContentName ) ;
53
+ expect ( await umbracoApi . document . doesItemExistInRecycleBin ( firstChildContentName ) ) . toBeTruthy ( ) ;
54
+ expect ( await umbracoApi . document . doesItemExistInRecycleBin ( secondChildContentName ) ) . toBeTruthy ( ) ;
55
+ } ) ;
56
+
57
+ test ( 'can bulk trash content nodes with a relation' , async ( { umbracoApi, umbracoUi} ) => {
58
+ // Arrange
59
+ const childDocumentTypeId = await umbracoApi . documentType . createDefaultDocumentType ( childDocumentTypeName ) ;
60
+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithAllowedChildNodeAndCollectionId ( documentTypeName , childDocumentTypeId , collectionId ) ;
61
+ const contentId = await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
62
+ await umbracoApi . document . publish ( contentId ) ;
63
+ const firstChildContentId = await umbracoApi . document . createDefaultDocumentWithParent ( firstChildContentName , childDocumentTypeId , contentId ) ;
64
+ await umbracoApi . document . publish ( firstChildContentId ) ;
65
+ await umbracoApi . document . createDefaultDocumentWithParent ( secondChildContentName , childDocumentTypeId , contentId ) ;
66
+ // Create a document that has a document picker with firstChildContentName
67
+ await umbracoApi . document . createDefaultDocumentWithOneDocumentLink ( documentPickerName [ 0 ] , firstChildContentName , firstChildContentId , documentPickerName [ 1 ] ) ;
68
+ await umbracoUi . goToBackOffice ( ) ;
69
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
70
+
71
+ // Act
72
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
73
+ await umbracoUi . content . selectContentWithNameInListView ( firstChildContentName ) ;
74
+ await umbracoUi . content . selectContentWithNameInListView ( secondChildContentName ) ;
75
+ await umbracoUi . content . clickTrashSelectedListItems ( ) ;
76
+ // Verify the references list
77
+ await umbracoUi . content . doesReferenceHeadlineHaveText ( referenceHeadline ) ;
78
+ await umbracoUi . content . doesReferenceItemsHaveCount ( 1 ) ;
79
+ await umbracoUi . content . isReferenceItemNameVisible ( firstChildContentName ) ;
80
+ await umbracoUi . content . clickConfirmTrashButton ( ) ;
81
+
82
+ // // Assert
83
+ await umbracoUi . content . isSuccessNotificationVisible ( ) ;
84
+ expect ( await umbracoApi . document . doesNameExist ( firstChildContentName ) ) . toBeFalsy ( ) ;
85
+ expect ( await umbracoApi . document . doesNameExist ( secondChildContentName ) ) . toBeFalsy ( ) ;
86
+ await umbracoUi . content . isItemVisibleInRecycleBin ( firstChildContentName ) ;
87
+ await umbracoUi . content . isItemVisibleInRecycleBin ( secondChildContentName ) ;
88
+ expect ( await umbracoApi . document . doesItemExistInRecycleBin ( firstChildContentName ) ) . toBeTruthy ( ) ;
89
+ expect ( await umbracoApi . document . doesItemExistInRecycleBin ( secondChildContentName ) ) . toBeTruthy ( ) ;
90
+
91
+ // Clean
92
+ await umbracoApi . documentType . ensureNameNotExists ( documentPickerName [ 1 ] ) ;
93
+ } ) ;
0 commit comments