mstdmstd's avatar

How to make cypress different test depending on if there are rows

Hello, In @vue/cli 4.0.5 app making cypress for a bloc like

            <fieldset class="blocks m-1 p-1">
                <legend class="blocks block-wrapper-for-data-listing">Events&nbsp;</legend>
                <div class="table-responsive table-wrapper-for-data-listing" v-if="taskRow.events.length">

                    <table class="table table-striped table-data-listing">
                        ... <!--- DATA TABLE -->
                    </table>

                </div>

                <p class="alert alert-info m-1 p-1 wrapper-for-no-rows-data-listing" role="alert" v-if="!taskRow.events.length">
                    This task has no events yet!
                </p>

            </fieldset>

I want to make different conditions deending on if there are taskRow.events rows. I made rules when there are taskRow.eventsL :

        var view_event_details_found= false
        cy.get('.block-wrapper-for-data-listing')
            .get('.table-wrapper-for-data-listing')
            .then(listing => {
                alert( '::-1' )
                cy.get('.tr_view_event_details').find('.view_event_details').first().click()
                cy.contains('.modal-title', 'Event Details')
                view_event_details_found= true
            })

        alert( 'view_event_details_found::' + view_event_details_found )
        if (!view_event_details_found) {

        }

I tried when view_event_details_found = false to make other test on search “This task has no events yet!” text.

But I got error :

CypressError: Timed out retrying: Expected to find element: '.table-wrapper-for-data-listing', but never found it.
as without div with “.table-wrapper-for-data-listing” defined.

Which is valid way to make this test ?

Thanks!

0 likes
0 replies

Please or to participate in this conversation.