autoComplete.spec.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.wait(400);
  5. cy.realPress("Tab");
  6. cy.get('input').type('123');
  7. // open panel
  8. cy.get('input').type('{enter}');
  9. cy.get('.semi-popover');
  10. // close panel
  11. cy.get('input').type('{enter}');
  12. cy.get('.semi-popover').should('not.exist');
  13. cy.get('input').should('have.value', '123');
  14. // test downArrow and upArrow
  15. cy.get('input').type('{enter}');
  16. cy.get('input').type('{downArrow}');
  17. cy.get('input').type('{downArrow}');
  18. cy.get('input').type('{downArrow}');
  19. cy.get('input').type('{downArrow}');
  20. cy.get('input').type('{upArrow}');
  21. cy.get('input').type('{esc}');
  22. cy.get('input').should('have.value', '123');
  23. // test downArrow when panel hidden
  24. cy.get('input').type('{downArrow}');
  25. cy.get('input').type('{downArrow}');
  26. cy.get('input').type('{enter}');
  27. cy.get('input').should('have.value', '[email protected]');
  28. // test upArrow when panel hidden
  29. cy.get('input').type('{upArrow}');
  30. cy.get('input').type('{upArrow}');
  31. cy.get('input').type('{enter}');
  32. cy.get('input').should('have.value', '[email protected]');
  33. cy.get('input').trigger('mouseover');
  34. cy.get('.semi-input-clearbtn').click();
  35. cy.root().click('right');
  36. cy.get('input').should('have.value', '');
  37. // // test enter
  38. // cy.get('input').click();
  39. // cy.get('input').type('456');
  40. // cy.get('input').type('{downArrow}');
  41. // cy.get('input').type('{enter}');
  42. // cy.get('#root').click('right');
  43. // cy.get('input').should('have.value', '[email protected]');
  44. });
  45. it('mouse over option ', () => {
  46. cy.visit('http://127.0.0.1:6006/iframe.html?id=autocomplete--basic-usage&args=&viewMode=story');
  47. cy.get('input').type('123');
  48. cy.get('.semi-portal').contains('[email protected]').trigger('mouseover');
  49. cy.get('input').type('{downArrow}');
  50. cy.get('input').type('{enter}');
  51. cy.get('input').should('have.value', '[email protected]');
  52. });
  53. it('click outer side handler', () => {
  54. cy.visit('http://127.0.0.1:6006/iframe.html?id=autocomplete--basic-usage&args=&viewMode=story');
  55. cy.get('input').type('123');
  56. cy.get('.semi-portal').contains('[email protected]');
  57. cy.get('body').click();
  58. cy.get('.semi-portal').should('not.exist');
  59. });
  60. });