@@ -45,81 +45,4 @@ context('Post Meta', () => {
4545 cy . get ( '.wp-block-example-post-meta .components-form-toggle__input' ) . should ( 'be.checked' ) ;
4646 cy . get ( '.wp-block-example-post-meta .components-form-toggle' ) . should ( 'have.class' , 'is-checked' ) ;
4747 } )
48-
49- it ( 'Saves the data into post meta' , ( ) => {
50- // Author
51- cy . get ( '.wp-block-example-post-meta .block-editor-block-variation-picker__variation' ) . first ( ) . click ( ) ;
52- cy . get ( '.wp-block-example-post-meta .block-editor-rich-text__editable' ) . focus ( ) . clear ( ) . type ( 'This is a test' ) ;
53-
54- // Reset
55- cy . get ( '.block-editor-block-breadcrumb__button' ) . contains ( 'Book' ) . click ( ) ;
56-
57- // Price
58- cy . insertBlock ( 'Post Meta' ) ;
59- cy . get ( '.wp-block-example-post-meta .block-editor-block-variation-picker__variation' ) . eq ( 2 ) . click ( ) ;
60- cy . get ( '.wp-block-example-post-meta .components-input-control__input' ) . focus ( ) . clear ( ) . type ( '10' ) ;
61-
62- // Reset
63- cy . get ( '.block-editor-block-breadcrumb__button' ) . contains ( 'Book' ) . click ( ) ;
64-
65- // Is featured
66- cy . insertBlock ( 'Post Meta' ) ;
67- cy . get ( '.wp-block-example-post-meta .block-editor-block-variation-picker__variation' ) . eq ( 3 ) . click ( ) ;
68- cy . get ( '.wp-block-example-post-meta .components-form-toggle__input' ) . check ( ) ;
69-
70- // Reset
71- cy . get ( '.block-editor-block-breadcrumb__button' ) . contains ( 'Book' ) . click ( ) ;
72-
73- // Intercept the network request related to publishing the post
74- cy . intercept ( {
75- method : 'POST' ,
76- url : '/index.php?rest_route=%2Fwp%2Fv2%2Fbooks%2F*' ,
77- } ) . as ( 'publishPost' ) ;
78-
79- cy . savePost ( ) ;
80-
81- // Wait for the intercepted request to complete
82- cy . wait ( '@publishPost' ) ;
83-
84- cy . reload ( ) ;
85-
86- cy . get ( '.components-dropdown-menu__toggle[aria-label="Options"]' ) . click ( ) ;
87- cy . get ( '.components-menu-item__button' ) . contains ( 'Preferences' ) . click ( ) ;
88- cy . get ( '.components-toggle-control__label' ) . contains ( 'Custom fields' ) . then ( ( $label ) => {
89- const attrFor = $label . attr ( 'for' ) ;
90-
91- cy . get ( `#${ attrFor } ` ) . then ( $input => {
92- if ( ! $input . is ( ':checked' ) ) {
93- cy . get ( `#${ attrFor } ` ) . check ( ) ;
94- cy . get ( '.edit-post-preferences-modal__custom-fields-confirmation-button' ) . contains ( 'Show & Reload Page' ) . click ( ) ;
95- } else {
96- cy . get ( '.components-button[aria-label="Close"]' ) . click ( ) ;
97- }
98- } )
99-
100- cy . get ( 'button' ) . contains ( 'Toggle panel: Custom Fields' ) . then ( $button => {
101- if ( $button . attr ( 'aria-expanded' ) === 'false' ) {
102- cy . get ( 'button' ) . contains ( 'Toggle panel: Custom Fields' ) . click ( ) ;
103- }
104- } )
105-
106- cy . get ( 'input[value="author"]' ) . should ( 'exist' ) . then ( $input => {
107- const id = $input . attr ( 'id' ) ;
108-
109- cy . get ( `#${ id . replace ( 'key' , 'value' ) } ` ) . should ( 'have.value' , 'This is a test' ) ;
110- } )
111-
112- cy . get ( 'input[value="is_featured"]' ) . should ( 'exist' ) . then ( $input => {
113- const id = $input . attr ( 'id' ) ;
114-
115- cy . get ( `#${ id . replace ( 'key' , 'value' ) } ` ) . should ( 'have.value' , '1' ) ;
116- } )
117-
118- cy . get ( 'input[value="price"]' ) . should ( 'exist' ) . then ( $input => {
119- const id = $input . attr ( 'id' ) ;
120-
121- cy . get ( `#${ id . replace ( 'key' , 'value' ) } ` ) . should ( 'have.value' , '10' ) ;
122- } )
123- } )
124- } )
12548} )
0 commit comments