-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathservices.cypress.js
131 lines (97 loc) · 4.41 KB
/
services.cypress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Include our constants
*/
import * as helpers from '../../../../.dev/tests/cypress/helpers';
describe( 'Test CoBlocks Services Block', function() {
/**
* Test that we can add a services block to the content, not alter
* any settings, and are able to successfully save the block without errors.
*/
it( 'Test services block saves with empty values.', function() {
helpers.addBlockToPost( 'coblocks/services', true );
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
} );
/**
* Test that we can add a services block to the content, change
* column count and are able to successfully save the block without errors.
*/
it( 'Test services block saves with columns attribute.', function() {
helpers.addBlockToPost( 'coblocks/services', true );
// Select parent block
helpers.selectBlock( 'services' );
cy.get( '.edit-post-visual-editor [data-type="coblocks/service"]' ).should( 'have.length', 2 );
helpers.setInputValue( 'Services settings', 'Columns', '{downarrow}', false );
cy.get( '.wp-block-coblocks-service' ).should( 'have.length', 1 ); // should only have one placeholder on one column.
helpers.setInputValue( 'Services settings', 'Columns', '{uparrow}{uparrow}', false );
cy.get( '.wp-block-coblocks-service' ).should( 'have.length', 3 );
helpers.setInputValue( 'Services settings', 'Columns', '{uparrow}', false );
cy.get( '.wp-block-coblocks-service' ).should( 'have.length', 4 );
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
} );
/**
* Test that we can add a services block to the content, change
* heading level and are able to successfully save the block without errors.
*
* This function has an extended timeout because settings
* propagate down to children slowly
*/
it( 'Test services block saves with heading level set.', function() {
helpers.addBlockToPost( 'coblocks/services', true );
// Select parent block
helpers.selectBlock( 'services' );
helpers.openHeadingToolbarAndSelect( 2 );
cy.get( '.edit-post-visual-editor [data-type="coblocks/services"] h2' ).should( 'exist' );
helpers.openHeadingToolbarAndSelect( 3 );
cy.get( '.edit-post-visual-editor [data-type="coblocks/services"] h3' ).should( 'exist' );
helpers.openHeadingToolbarAndSelect( 4 );
cy.get( '.edit-post-visual-editor [data-type="coblocks/services"] h4' ).should( 'exist' );
helpers.openHeadingToolbarAndSelect( 5 );
cy.get( '.edit-post-visual-editor [data-type="coblocks/services"] h5' ).should( 'exist' );
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
} );
/**
* Test that the service block move arrow orientation is correct
*/
it( 'Test service block has the proper arrow orientation.', function() {
helpers.addBlockToPost( 'coblocks/services', true );
cy.get( '.edit-post-visual-editor [data-type="coblocks/service"]:first-child' ).click();
cy.get( 'div.block-editor-block-mover' ).should( 'have.class', 'is-horizontal' );
// Select parent block
helpers.selectBlock( 'services' );
helpers.setInputValue( 'Services settings', 'Columns', 1, false );
cy.get( '.edit-post-visual-editor [data-type="coblocks/service"]:first-child' ).click();
cy.get( 'div.block-editor-block-mover' ).should( 'not.have.class', 'is-horizontal' );
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
} );
/**
* Test that we can add a services block to the content, enable
* action buttons and are able to successfully save the block without errors.
*/
it( 'Test services block saves with action buttons enabled.', function() {
helpers.addBlockToPost( 'coblocks/services', true );
cy.get( 'div.wp-block-button' ).should( 'not.exist' );
helpers.toggleSettingCheckbox( /display buttons/i );
cy.get( '.wp-block-buttons' ).should( 'have.length', 2 );
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
} );
/**
* Test the services block saves with custom classes
*/
it( 'Test the services block custom classes.', function() {
helpers.addBlockToPost( 'coblocks/services', true );
helpers.addCustomBlockClass( 'my-custom-class', 'services' );
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
cy.get( '.wp-block-coblocks-services' )
.should( 'have.class', 'my-custom-class' );
helpers.viewPage();
cy.get( '.wp-block-coblocks-services' )
.should( 'have.class', 'my-custom-class' );
helpers.editPage();
} );
} );