autoComplete.spec.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. describe('autoComplete', () => {
  2. it('key press', () => {
  3. cy.visit('http://127.0.0.1:6006/iframe.html?id=autocomplete--basic-usage&args=&viewMode=story');
  4. cy.get('body').tab();
  5. cy.get('input').type('123');
  6. // open panel
  7. cy.get('input').type('{enter}');
  8. cy.get('.semi-popover');
  9. // close panel
  10. cy.get('input').type('{enter}');
  11. cy.get('.semi-popover').not('.exit');
  12. cy.get('input').should('have.value', '123');
  13. // test downArrow and upArrow
  14. cy.get('input').type('{enter}');
  15. cy.get('input').type('{downArrow}');
  16. cy.get('input').type('{downArrow}');
  17. cy.get('input').type('{downArrow}');
  18. cy.get('input').type('{downArrow}');
  19. cy.get('input').type('{upArrow}');
  20. cy.get('input').type('{esc}');
  21. cy.get('input').should('have.value', '123');
  22. // test downArrow when panel hidden
  23. cy.get('input').type('{downArrow}');
  24. cy.get('input').type('{downArrow}');
  25. cy.get('input').type('{enter}');
  26. cy.get('input').should('have.value', '[email protected]');
  27. // test upArrow when panel hidden
  28. cy.get('input').type('{upArrow}');
  29. cy.get('input').type('{upArrow}');
  30. cy.get('input').type('{enter}');
  31. cy.get('input').should('have.value', '[email protected]');
  32. cy.get('input').trigger('mouseover');
  33. cy.get('.semi-input-clearbtn').click();
  34. cy.get('#root').click('right');
  35. cy.get('input').should('have.value', '');
  36. // test enter
  37. // cy.get('input').click();
  38. // cy.get('input').type('456');
  39. // cy.get('input').type('{downArrow}');
  40. // cy.get('input').type('{enter}');
  41. // cy.get('#root').click('right');
  42. // cy.get('input').should('have.value', '[email protected]');
  43. });
  44. it('mouse over option ', () => {
  45. cy.visit('http://127.0.0.1:6006/iframe.html?id=autocomplete--basic-usage&args=&viewMode=story');
  46. cy.get('input').type('123');
  47. cy.get('.semi-portal').contains('[email protected]').trigger('mouseover');
  48. cy.get('input').type('{downArrow}');
  49. cy.get('input').type('{enter}');
  50. cy.get('input').should('have.value', '[email protected]');
  51. });
  52. });