Make sure the element is attached when testing
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2021-01-23 18:13:53 +01:00
parent 28cfdef12d
commit 2d306dbadc
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 19 additions and 2 deletions

View File

@ -361,9 +361,8 @@ describe('Lists', () => {
})
cy.visit('/lists/1/kanban')
cy.get('.kanban .bucket .tasks .task')
cy.getAttached('.kanban .bucket .tasks .task')
.contains(tasks[0].title)
.should('exist')
.click()
cy.url()

View File

@ -0,0 +1,17 @@
/**
* getAttached(selector)
* getAttached(selectorFn)
*
* Waits until the selector finds an attached element, then yields it (wrapped).
* selectorFn, if provided, is passed $(document). Don't use cy methods inside selectorFn.
*
* Source: https://github.com/cypress-io/cypress/issues/5743#issuecomment-650421731
*/
Cypress.Commands.add('getAttached', selector => {
const getElement = typeof selector === 'function' ? selector : $d => $d.find(selector);
let $el = null;
return cy.document().should($d => {
$el = getElement(Cypress.$($d));
expect(Cypress.dom.isDetached($el)).to.be.false;
}).then(() => cy.wrap($el));
});

View File

@ -1,2 +1,3 @@
import './commands'
import 'cypress-file-upload'