select.spec.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // form.spec.js created with Cypress
  2. //
  3. // Start writing your Cypress tests below!
  4. // If you're unfamiliar with how Cypress works,
  5. // check out the link below and learn how to write your first test:
  6. // https://on.cypress.io/writing-first-test
  7. /**
  8. * why use `.then`?
  9. * @see https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Return-Values
  10. */
  11. describe('Select', () => {
  12. it('option hover, change active', () => {
  13. cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/select--select-filter-single');
  14. cy.get('.semi-select').eq(0).click();
  15. // hover can change active index
  16. cy.get('.semi-select-option').eq(5).trigger('mouseover');
  17. cy.get('.semi-select-option-focused .semi-select-option-text').eq(0).should('have.text', 'wym');
  18. // press downArrow to test it
  19. cy.get('input').eq(0).type('{downArrow}');
  20. cy.get('.semi-select-option-focused .semi-select-option-text').eq(0).should('have.text', 'opts');
  21. });
  22. it('keyboard-enter, select choose option', { keystrokeDelay: 0 }, () => {
  23. cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/select--select-filter-single');
  24. cy.get('.semi-select').eq(0).click();
  25. cy.get('input').eq(0).type('o');
  26. cy.get('input').eq(0).type('{downArrow}');
  27. cy.get('input').eq(0).type('{downArrow}');
  28. cy.get('input').eq(0).type('{enter}');
  29. cy.get('.semi-select-selection-text').eq(0).should('have.text', 'opts');
  30. });
  31. it('clickOutSide, should hide', () => {
  32. cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/select--select-filter-single');
  33. cy.get('.semi-select').eq(0).click();
  34. // should show now
  35. cy.get('.semi-select-option-list').should('exist');
  36. // should hide after click empty area
  37. cy.get('h5').eq(0).click();
  38. cy.get('.semi-select-option-list').should('not.exist');
  39. });
  40. // it('should trigger onSearch when click x icon', () => {
  41. // cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/select--select-filter-single');
  42. // cy.get('.semi-select').eq(0).click();
  43. // cy.get('.semi-select-option').eq(0).click();
  44. // cy.get('.semi-select').eq(0).click();
  45. // cy.get('.semi-select-clear').eq(0).click();
  46. // cy.get('.semi-select-input .semi-input').should('have.value', '');
  47. // });
  48. // it('should trigger onBlur and onSearch', () => {
  49. // cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/form--use-form-api-set-value-update-array');
  50. // });
  51. // it('keyboard-skip disabled option when press up/down', () => {
  52. // });
  53. // it('optionList scroll, should trigger onListScroll', () => {
  54. // cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/form--use-form-api-set-value-update-array');
  55. // });
  56. });