1
+ /// <reference types="Cypress" />
2
+ import {
3
+ AliasHelper ,
4
+ ApprovedColorPickerDataTypeBuilder ,
5
+ } from 'umbraco-cypress-testhelpers' ;
6
+
7
+ context ( 'DataTypes' , ( ) => {
8
+
9
+ beforeEach ( ( ) => {
10
+ cy . umbracoLogin ( Cypress . env ( 'username' ) , Cypress . env ( 'password' ) , false ) ;
11
+ } ) ;
12
+
13
+ it ( 'Tests Approved Colors' , ( ) => {
14
+ cy . deleteAllContent ( ) ;
15
+ const name = 'Approved Colour Test' ;
16
+ const alias = AliasHelper . toAlias ( name ) ;
17
+
18
+ cy . umbracoEnsureDocumentTypeNameNotExists ( name ) ;
19
+ cy . umbracoEnsureDataTypeNameNotExists ( name ) ;
20
+
21
+ const pickerDataType = new ApprovedColorPickerDataTypeBuilder ( )
22
+ . withName ( name )
23
+ . withPrevalues ( [ '000000' , 'FF0000' ] )
24
+ . build ( )
25
+
26
+ //umbracoMakeDocTypeWithDataTypeAndContent(name, alias, pickerDataType);
27
+ cy . umbracoCreateDocTypeWithContent ( name , alias , pickerDataType ) ;
28
+
29
+ // Act
30
+ // Enter content
31
+ cy . umbracoRefreshContentTree ( ) ;
32
+ cy . umbracoTreeItem ( "content" , [ name ] ) . click ( ) ;
33
+ //Pick a colour
34
+ cy . get ( '.btn-000000' ) . click ( ) ;
35
+ //Save
36
+ cy . umbracoButtonByLabelKey ( 'buttons_saveAndPublish' ) . click ( ) ;
37
+ cy . umbracoSuccessNotification ( ) . should ( 'be.visible' ) ;
38
+ //Editing template with some content
39
+ cy . editTemplate ( name , '@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.ApprovedColourTest>' +
40
+ '\n@using ContentModels = Umbraco.Web.PublishedModels;' +
41
+ '\n@{' +
42
+ '\n Layout = null;' +
43
+ '\n}' +
44
+ '\n<p style="color:@Model.UmbracoTest">Lorem ipsum dolor sit amet</p>' ) ;
45
+
46
+ //Assert
47
+ const expected = `<p style="color:000000" > Lorem ipsum dolor sit amet </p>` ;
48
+ cy . umbracoVerifyRenderedViewContent ( '/' , expected , true ) . should ( 'be.true' ) ;
49
+
50
+ //Pick another colour to verify both work
51
+ cy . get ( '.btn-FF0000' ) . click ( ) ;
52
+ //Save
53
+ cy . umbracoButtonByLabelKey ( 'buttons_saveAndPublish' ) . click ( ) ;
54
+ cy . umbracoSuccessNotification ( ) . should ( 'be.visible' ) ;
55
+ //Assert
56
+ const expected2 = '<p style="color:FF0000">Lorem ipsum dolor sit amet</p>' ;
57
+ cy . umbracoVerifyRenderedViewContent ( '/' , expected2 , true ) . should ( 'be.true' ) ;
58
+
59
+ //Clean
60
+ cy . umbracoEnsureDataTypeNameNotExists ( name ) ;
61
+ cy . umbracoEnsureDocumentTypeNameNotExists ( name ) ;
62
+ cy . umbracoEnsureTemplateNameNotExists ( name ) ;
63
+ } ) ;
64
+
65
+ // it('Tests Checkbox List', () => {
66
+ // const name = 'CheckBox List';
67
+ // const alias = AliasHelper.toAlias(name);
68
+
69
+ // cy.umbracoEnsureDocumentTypeNameNotExists(name);
70
+ // cy.umbracoEnsureDataTypeNameNotExists(name);
71
+
72
+ // const pickerDataType = new CheckBoxListDataTypeBuilder()
73
+ // .withName(name)
74
+ // .withPrevalues(['Choice 1', 'Choice 2'])
75
+ // .build()
76
+
77
+ // cy.umbracoCreateDocTypeWithContent(name, alias, pickerDataType);
78
+ // // Act
79
+ // // Enter content
80
+ // cy.umbracoRefreshContentTree();
81
+ // cy.umbracoTreeItem("content", [name]).click();
82
+ // //Check box 1
83
+ // cy.get(':nth-child(1) > umb-checkbox.ng-isolate-scope > .checkbox > .umb-form-check__symbol > .umb-form-check__state > .umb-form-check__check')
84
+ // .click();
85
+ // //Save
86
+ // cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
87
+ // cy.umbracoSuccessNotification().should('be.visible');
88
+
89
+ // //Edit template with content
90
+ // cy.editTemplate(name, '@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.CheckboxList>' +
91
+ // '\n@using ContentModels = Umbraco.Web.PublishedModels;' +
92
+ // '\n@{' +
93
+ // '\n Layout = null;' +
94
+ // '\n}' +
95
+ // '\n<p>@Model.UmbracoTest</p>');
96
+ // });
97
+ } ) ;
0 commit comments