@@ -85,6 +85,31 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r
8585 } )
8686
8787 it ( 'Filter view remove row when it no longer matches filter' , ( ) => {
88+ const waitForRowPresenceCheck = ( alias , rowId , expectedPresent , retries = 20 ) => {
89+ cy . wait ( alias , { timeout : 20000 } ) . then ( ( { request, response } ) => {
90+ if ( request . url . includes ( `/row/${ rowId } /present` ) ) {
91+ if ( response . body . present === expectedPresent ) {
92+ return
93+ }
94+
95+ if ( retries <= 0 ) {
96+ expect ( response . body . present ) . to . equal ( expectedPresent )
97+ }
98+
99+ waitForRowPresenceCheck ( alias , rowId , expectedPresent , retries - 1 )
100+ return
101+ }
102+
103+ if ( retries <= 0 ) {
104+ throw new Error ( `Did not receive /present check for row ${ rowId } ` )
105+ }
106+
107+ waitForRowPresenceCheck ( alias , rowId , expectedPresent , retries - 1 )
108+ } )
109+ }
110+
111+ let checkedRowId = null
112+
88113 // # create view with filter
89114 // ## create view and set title
90115 const title = 'Filter for check enabled'
@@ -110,30 +135,32 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r
110135 cy . contains ( '.app-navigation-entry-link span' , title ) . should ( 'exist' )
111136
112137 // # insert a checked row
138+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/api/2/views/*/rows' } ) . as ( 'insertRowInView' )
139+ cy . intercept ( { method : 'GET' , url : '**/apps/tables/view/*/row/*/present' } ) . as ( 'isRowInViewPresentChecked' )
113140 cy . get ( '[data-cy="createRowBtn"]' ) . click ( )
114141 cy . fillInValueTextLine ( 'title' , 'checked row' )
115142 cy . fillInValueSelectionCheck ( 'check' )
116- cy . intercept ( { method : 'GET' , url : '**/apps/tables/view/*/row/*/present' } ) . as ( 'isRowInViewPresent' )
117143 cy . get ( '[data-cy="createRowSaveButton"]' ) . click ( )
118144
119- // ## check server response for /view/{viewId}/row/{id}/present
120- cy . wait ( '@isRowInViewPresent' ) . then ( ( { response : { body : { present } } } ) => {
121- expect ( present ) . to . equal ( true )
145+ cy . wait ( '@insertRowInView' ) . then ( ( { response } ) => {
146+ checkedRowId = response . body . ocs . data . id
147+ waitForRowPresenceCheck ( '@isRowInViewPresentChecked' , checkedRowId , true )
122148 } )
123149
124150 // ## check if row is visible
125151 cy . contains ( '[data-cy="ncTable"] [data-cy="customTableRow"]' , 'checked row' ) . should ( 'be.visible' )
126152 cy . get ( '[data-cy="createRowModal"]' ) . should ( 'not.exist' )
127153
128154 // # insert a unchecked row
155+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/api/2/views/*/rows' } ) . as ( 'insertUncheckedRowInView' )
156+ cy . intercept ( { method : 'GET' , url : '**/apps/tables/view/*/row/*/present' } ) . as ( 'isRowInViewPresentUnchecked' )
129157 cy . get ( '[data-cy="createRowBtn"]' ) . click ( )
130158 cy . fillInValueTextLine ( 'title' , 'unchecked row' )
131- cy . intercept ( { method : 'GET' , url : '**/apps/tables/view/*/row/*/present' } ) . as ( 'isRowInViewPresent' )
132159 cy . get ( '[data-cy="createRowSaveButton"]' ) . click ( )
133160
134- // ## check server response for /view/{viewId}/row/{id}/present
135- cy . wait ( '@isRowInViewPresent' ) . then ( ( { response : { body : { present } } } ) => {
136- expect ( present ) . to . equal ( false )
161+ cy . wait ( '@insertUncheckedRowInView' ) . then ( ( { response } ) => {
162+ const uncheckedRowId = response . body . ocs . data . id
163+ waitForRowPresenceCheck ( '@isRowInViewPresentUnchecked' , uncheckedRowId , false )
137164 } )
138165
139166 // ## check if row does not exist
@@ -142,29 +169,23 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r
142169
143170 // # edit checked row
144171 // ## uncheck
172+ cy . intercept ( { method : 'PUT' , url : '**/apps/tables/row/*' } ) . as ( 'updateCheckedRow' )
145173 cy . contains ( '[data-cy="ncTable"] [data-cy="customTableRow"]' , 'checked row' ) . closest ( '[data-cy="customTableRow"]' ) . find ( '[data-cy="editRowBtn"]' ) . click ( )
146174 cy . get ( '[data-cy="editRowModal"] .checkbox-radio-switch' ) . click ( )
147- cy . intercept ( { method : 'GET' , url : '**/apps/tables/view/*/row/*/present' } ) . as ( 'isRowInViewPresent' )
148175 cy . get ( '[data-cy="editRowSaveButton"]' ) . click ( )
149176
150- // ## check server response for /view/{viewId}/row/{id}/present
151- cy . wait ( '@isRowInViewPresent' ) . then ( ( { response : { body : { present } } } ) => {
152- expect ( present ) . to . equal ( false )
153- } )
177+ cy . wait ( '@updateCheckedRow' )
154178
155179 // ## check if row does not exist
156180 cy . contains ( '[data-cy="ncTable"] [data-cy="customTableRow"]' , 'checked row' ) . should ( 'not.exist' )
157181 cy . get ( '[data-cy="editRowModal"]' ) . should ( 'not.exist' )
158182
159183 // # inline edit row
160184 // ## uncheck row
161- cy . intercept ( { method : 'GET ' , url : '**/apps/tables/view/*/ row/*/present ' } ) . as ( 'isRowInViewPresent ' )
185+ cy . intercept ( { method : 'PUT ' , url : '**/apps/tables/row/*' } ) . as ( 'inlineUpdateRow ' )
162186 cy . contains ( '[data-cy="ncTable"] [data-cy="customTableRow"]' , 'first row' ) . closest ( '[data-cy="customTableRow"]' ) . find ( '.inline-editing-container input' ) . click ( { force : true } )
163187
164- // ## check server response for /view/{viewId}/row/{id}/present
165- cy . wait ( '@isRowInViewPresent' ) . then ( ( { response : { body : { present } } } ) => {
166- expect ( present ) . to . equal ( false )
167- } )
188+ cy . wait ( '@inlineUpdateRow' )
168189
169190 // ## check if row does not exist
170191 cy . contains ( '[data-cy="ncTable"] [data-cy="customTableRow"]' , 'first row' ) . should ( 'not.exist' )
0 commit comments