treeSelect.spec.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. describe('treeSelect', () => {
  2. it('searchPosition is trigger', () => {
  3. cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--search-position&args=&viewMode=story');
  4. // test trigger focus
  5. cy.get('input').eq(0).click();
  6. cy.get('.semi-tree-select-focus').should('exist');
  7. // test trigger blur
  8. cy.get('body').click('right');
  9. cy.get('.semi-tree-select-focus').should('not.exist');
  10. });
  11. it('load data', () => {
  12. cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--load-data&args=&viewMode=story');
  13. cy.get('.semi-tree-select-selection').click();
  14. cy.wait(200);
  15. cy.get('.semi-tree-option-list .semi-icon-tree_triangle_down').eq(0).click();
  16. cy.wait(1000);
  17. // assert data had load success
  18. cy.get('.semi-tree-option-list').contains('Child Node');
  19. });
  20. it('clear and close', () => {
  21. cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--check-relation-demo&args=&viewMode=story');
  22. cy.viewport(1000, 1000);
  23. // test remove tag
  24. cy.get('.semi-tag-close').eq(3).click();
  25. cy.get('.semi-tag-content').contains('Japan').should('not.exist');
  26. cy.get('.semi-tree-select-selection').eq(8).contains('China');
  27. cy.get('.semi-tree-select-selection').eq(8).trigger('mouseover');
  28. cy.get('.semi-tree-select-clearbtn').click();
  29. cy.get('.semi-tagInput-wrapper .semi-tag').should('not.exist');
  30. // multiple When triggerSearch, clicking the clear button will trigger to clear Input
  31. cy.get('input').eq(1).type('dddd');
  32. cy.get('.semi-tree-select-selection').eq(8).trigger('mouseover');
  33. cy.get('.semi-tree-select-clearbtn').click();
  34. cy.get('.semi-tree-select-selection').eq(8).get('input').should('have.value', '');
  35. cy.get('body').click('right');
  36. // wait for the panel close
  37. cy.wait(500);
  38. // single selection When triggerSearch, clicking the clear button will trigger to clear Input
  39. cy.get('input').eq(2).type('dddd');
  40. cy.get('.semi-tree-select-selection').eq(9).trigger('mouseover');
  41. cy.get('.semi-tree-select-clearbtn').click();
  42. cy.get('.semi-tree-select-selection').eq(9).get('input').should('have.value', '');
  43. });
  44. it('clear by key press', () => {
  45. cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--check-relation-demo&args=&viewMode=story');
  46. cy.get('.semi-tree-select-selection').eq(8).contains('China');
  47. cy.get('.semi-tree-select-selection').eq(8).trigger('mouseover');
  48. cy.get('.semi-tree-select-clearbtn').focus();
  49. cy.get('.semi-tree-select-clearbtn').type('{enter}');
  50. cy.get('.semi-tagInput-wrapper .semi-tag').should('not.exist');
  51. });
  52. });