This is not how I would expect cypress to behave: I have a button which is only enabled when to checkboxes are checked in the table below. Before the checking of the 2 rows, the button is greyed out with:
button[data-e2e-button][disabled=true]
Now cypress checks the 2 rows and the button becomes enabled. i.e. the "[disabled=true]" disappears. My code looks like this:
Non Working Code:
cy.contains(`[data-e2e-button]`, buttonLabel, BUTTON_OPTS).should('not.be.disabled').should('be.visible').click...
When it clicks on this element, it seems like it did not wait until the button is enabled.
Only if I have a separate wait for the disabled=true to disappear it works:
Working Code:
cy.contains('[data-e2e-button][aria-disabled="true"]', buttonLabel, BUTTON_OPTS).should('not.exist');
cy.contains(`[data-e2e-button]`, buttonLabel, BUTTON_OPTS).should('not.be.disabled').should('be.visible').click...
This seems kind of ugly to me, as it ensures twice for disabled to disappear.
Here is the html code: ENABLED:
<span role="tooltip">
<a class="MuiMenuItem-root MuiMenuItem-dense MuiMenuItem-gutters MuiButtonBase-root css-brjsa3" tabindex="-1" role="menuitem"><span>
<span class="MuiBox-root css-1jjwf1f">Two Checkbox button</span>
</span>
<span class="MuiTouchRipple-root css-w0pj6f"></span>
</a>
</span>
DISABLED
<span role="tooltip">
<a class="MuiMenuItem-root MuiMenuItem-dense Mui-disabled MuiMenuItem-gutters MuiButtonBase-root Mui-disabled css-brjsa3" tabindex="-1" aria-disabled="true" role="menuitem"><span>
<span class="MuiBox-root css-1jjwf1f">Two Checkbox button</span>
</span></a></span>