1
+ import { ConstantHelper , NotificationConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
2
+
3
+ // Content Name
4
+ const contentName = 'ContentName' ;
5
+
6
+ // Document Type
7
+ const documentTypeName = 'DocumentTypeName' ;
8
+ let documentTypeId = null ;
9
+ const documentTypeGroupName = 'DocumentGroup' ;
10
+
11
+ // Block Grid
12
+ const blockGridName = 'BlockGridName' ;
13
+ let blockGridId = null ;
14
+
15
+ // Element Type
16
+ const blockName = 'BlockName' ;
17
+ let elementTypeId = null ;
18
+ const elementGroupName = 'ElementGroup' ;
19
+
20
+ // Property Editor
21
+ const propertyEditorName = 'ProperyEditorInBlockName' ;
22
+ let propertyEditorId = null ;
23
+ const optionValues = [ 'testOption1' , 'testOption2' ] ;
24
+
25
+ test . afterEach ( async ( { umbracoApi} ) => {
26
+ await umbracoApi . document . ensureNameNotExists ( contentName ) ;
27
+ await umbracoApi . documentType . ensureNameNotExists ( documentTypeName ) ;
28
+ await umbracoApi . documentType . ensureNameNotExists ( blockName ) ;
29
+ await umbracoApi . dataType . ensureNameNotExists ( blockGridName ) ;
30
+ } ) ;
31
+
32
+ test ( 'can not publish a block grid with a mandatory radiobox without a value' , async ( { umbracoApi, umbracoUi} ) => {
33
+ // Arrange
34
+ propertyEditorId = await umbracoApi . dataType . createRadioboxDataType ( propertyEditorName , optionValues ) ;
35
+ elementTypeId = await umbracoApi . documentType . createDefaultElementType ( blockName , elementGroupName , propertyEditorName , propertyEditorId , true ) ;
36
+ blockGridId = await umbracoApi . dataType . createBlockGridWithABlockAndAllowAtRoot ( blockGridName , elementTypeId , true ) ;
37
+ documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , blockGridName , blockGridId , documentTypeGroupName ) ;
38
+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
39
+
40
+ await umbracoUi . goToBackOffice ( ) ;
41
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
42
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
43
+
44
+ // Act
45
+ await umbracoUi . content . clickAddBlockElementButton ( ) ;
46
+ await umbracoUi . content . clickBlockElementWithName ( blockName ) ;
47
+ // Do not select any radiobox values and the validation error appears
48
+ await umbracoUi . content . clickCreateModalButton ( ) ;
49
+ await umbracoUi . content . isValidationMessageVisible ( ConstantHelper . validationMessages . emptyValue ) ;
50
+ // Select a radiobox value and the validation error disappears
51
+ await umbracoUi . content . chooseRadioboxOption ( optionValues [ 0 ] ) ;
52
+ await umbracoUi . content . isValidationMessageVisible ( ConstantHelper . validationMessages . emptyValue , false ) ;
53
+ await umbracoUi . content . clickCreateModalButton ( ) ;
54
+ await umbracoUi . content . clickSaveAndPublishButton ( ) ;
55
+
56
+ // Assert
57
+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
58
+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . published ) ;
59
+ } ) ;
60
+
61
+ test ( 'can not publish a block grid with a mandatory checkbox list without a value' , async ( { umbracoApi, umbracoUi} ) => {
62
+ // Arrange
63
+ propertyEditorId = await umbracoApi . dataType . createCheckboxListDataType ( propertyEditorName , optionValues ) ;
64
+ elementTypeId = await umbracoApi . documentType . createDefaultElementType ( blockName , elementGroupName , propertyEditorName , propertyEditorId , true ) ;
65
+ blockGridId = await umbracoApi . dataType . createBlockGridWithABlockAndAllowAtRoot ( blockGridName , elementTypeId , true ) ;
66
+ documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , blockGridName , blockGridId , documentTypeGroupName ) ;
67
+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
68
+
69
+ await umbracoUi . goToBackOffice ( ) ;
70
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
71
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
72
+
73
+ // Act
74
+ await umbracoUi . content . clickAddBlockElementButton ( ) ;
75
+ await umbracoUi . content . clickBlockElementWithName ( blockName ) ;
76
+ // Do not select any checkbox list values and the validation error appears
77
+ await umbracoUi . content . clickCreateModalButton ( ) ;
78
+ await umbracoUi . content . isValidationMessageVisible ( ConstantHelper . validationMessages . emptyValue ) ;
79
+ // Select a checkbox list value and the validation error disappears
80
+ await umbracoUi . content . chooseCheckboxListOption ( optionValues [ 0 ] ) ;
81
+ await umbracoUi . content . isValidationMessageVisible ( ConstantHelper . validationMessages . emptyValue , false ) ;
82
+ await umbracoUi . content . clickCreateModalButton ( ) ;
83
+ await umbracoUi . content . clickSaveAndPublishButton ( ) ;
84
+
85
+ // Assert
86
+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
87
+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . published ) ;
88
+ } ) ;
89
+
90
+ test ( 'can not publish a block grid with a mandatory dropdown without a value' , async ( { umbracoApi, umbracoUi} ) => {
91
+ // Arrange
92
+ propertyEditorId = await umbracoApi . dataType . createDropdownDataType ( propertyEditorName , false , optionValues ) ;
93
+ elementTypeId = await umbracoApi . documentType . createDefaultElementType ( blockName , elementGroupName , propertyEditorName , propertyEditorId , true ) ;
94
+ blockGridId = await umbracoApi . dataType . createBlockGridWithABlockAndAllowAtRoot ( blockGridName , elementTypeId , true ) ;
95
+ documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , blockGridName , blockGridId , documentTypeGroupName ) ;
96
+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
97
+
98
+ await umbracoUi . goToBackOffice ( ) ;
99
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
100
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
101
+
102
+ // Act
103
+ await umbracoUi . content . clickAddBlockElementButton ( ) ;
104
+ await umbracoUi . content . clickBlockElementWithName ( blockName ) ;
105
+ // Do not select any dropdown values and the validation error appears
106
+ await umbracoUi . content . clickCreateModalButton ( ) ;
107
+ await umbracoUi . content . isValidationMessageVisible ( ConstantHelper . validationMessages . emptyValue ) ;
108
+ // Select a dropdown value and the validation error disappears
109
+ await umbracoUi . content . chooseDropdownOption ( [ optionValues [ 0 ] ] ) ;
110
+ await umbracoUi . content . isValidationMessageVisible ( ConstantHelper . validationMessages . emptyValue , false ) ;
111
+ await umbracoUi . content . clickCreateModalButton ( ) ;
112
+ await umbracoUi . content . clickSaveAndPublishButton ( ) ;
113
+
114
+ // Assert
115
+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
116
+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . published ) ;
117
+ } ) ;
0 commit comments