How can I validate empty fields with cypress

Asked

Viewed 110 times

1

I already have a method that validates when they have some information about him, but when there is nothing he does not find the element of the list.

Cypress.Commands.add('selectedFilterPlan', (filterId, idComponentList) => {
  cy.get(filterId).should('be.visible');
  cy.get(filterId).should('have.value', '');
  cy.get(filterId)
  .then((selects) => {
    let select = selects[0];
    cy.wrap(select).click();
      if(cy.get(idComponentList).should("be.visible")){
        cy.get(idComponentList)
        .get("nz-option-item")
        .then(function(item) {
        cy.wrap(item[0]).click();
        cy.wait(500);
        cy.get("[data-cy=result-filter-list]").should("be.visible");
        });
      }
 });
});

it('select dropdown plan filters', () => {
  cy.selectedFilterPlan('[data-cy=id-filter-1]', "#cdk-overlay-1");
  cy.selectedFilterPlan('[data-cy=id-filter-2]', "#cdk-overlay-2");
  cy.selectedFilterPlan('[data-cy=id-filter-3]', "#cdk-overlay-3");
  cy.selectedFilterPlan('[data-cy=id-filter-4]', "#cdk-overlay-4");
  cy.selectedFilterPlan('[data-cy=id-filter-5]', "#cdk-overlay-5");
});

The filter when empty is displayed an Empty from Ant Design of Angular, as shown in the image below: inserir a descrição da imagem aqui

I am unable to validate when open the dropdown is displayed the list with its respective content or if Empety is displayed.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.