inputNumber.spec.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // inputNumber.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. describe('inputNumber', () => {
  8. it('fix precision delete bug', () => {
  9. cy.visit('http://localhost:6006/iframe.html?id=inputnumber--fix-precision-786&viewMode=story');
  10. cy.get('[data-cy=fix-precision-786] .semi-input').click().clear();
  11. cy.get('[data-cy=fix-precision-786] .semi-input').type('aaa');
  12. cy.get('[data-cy=fix-precision-786] .semi-input').blur();
  13. cy.get('[data-cy=fix-precision-786] .semi-input').should('have.value', '');
  14. });
  15. it('a11y', () => {
  16. cy.visit('http://localhost:6006/iframe.html?id=inputnumber--input-number-a-11-y&args=&viewMode=story');
  17. cy.get('input[data-cy=default]').click();
  18. cy.get('input[data-cy=default]').type('{upArrow}');
  19. cy.get('input[data-cy=default]').should('have.value', '1');
  20. cy.get('input[data-cy=default]').trigger('keydown', { eventConstructor: 'KeyboardEvent', key: 'upArrow', keyCode: 38, shiftKey: true });
  21. cy.get('input[data-cy=default]').should('have.value', '11');
  22. cy.get('input[data-cy=default]').type('{downArrow}');
  23. cy.get('input[data-cy=default]').should('have.value', '10');
  24. cy.get('input[data-cy=step]').click();
  25. cy.get('input[data-cy=step]').type('{upArrow}');
  26. cy.get('input[data-cy=step]').should('have.value', '5');
  27. cy.get('input[data-cy=step]').trigger('keydown', { eventConstructor: 'KeyboardEvent', key: 'upArrow', keyCode: 38, shiftKey: true });
  28. cy.get('input[data-cy=step]').should('have.value', '105');
  29. cy.get('input[data-cy=step]').trigger('keydown', { eventConstructor: 'KeyboardEvent', key: 'downArrow', keyCode: 40, shiftKey: true });
  30. cy.get('input[data-cy=step]').should('have.value', '5');
  31. });
  32. it('click prefix/suffix to focus', () => {
  33. cy.visit('http://localhost:6006/iframe.html?id=inputnumber--prefix-suffix&args=&viewMode=story');
  34. cy.get('.semi-input-wrapper').eq(0).children('.semi-input-prefix').click();
  35. cy.get('.semi-input-wrapper').eq(0).children('input').should('be.focused');
  36. cy.get('body').click();
  37. cy.get('.semi-input-wrapper').eq(0).children('input').should('not.be.focused');
  38. cy.get('.semi-input-wrapper').eq(0).children('.semi-input-suffix').click();
  39. cy.get('.semi-input-wrapper').eq(0).children('input').should('be.focused');
  40. cy.get('body').click();
  41. cy.get('.semi-input-wrapper').eq(0).children('input').should('not.be.focused');
  42. });
  43. });