您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

control_duration.js 1.4 KiB

5 年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. context('Control Duration', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app/website');
  5. });
  6. function get_dialog_with_duration(hide_days = 0, hide_seconds = 0) {
  7. return cy.dialog({
  8. title: 'Duration',
  9. fields: [{
  10. 'fieldname': 'duration',
  11. 'fieldtype': 'Duration',
  12. 'hide_days': hide_days,
  13. 'hide_seconds': hide_seconds
  14. }]
  15. });
  16. }
  17. it('should set duration', () => {
  18. get_dialog_with_duration().as('dialog');
  19. cy.get('.frappe-control[data-fieldname=duration] input')
  20. .first()
  21. .click();
  22. cy.get('.duration-input[data-duration=days]')
  23. .type(45, { force: true })
  24. .blur({ force: true });
  25. cy.get('.duration-input[data-duration=minutes]')
  26. .type(30)
  27. .blur({ force: true });
  28. cy.get('.frappe-control[data-fieldname=duration] input').first().should('have.value', '45d 30m');
  29. cy.get('.frappe-control[data-fieldname=duration] input').first().blur();
  30. cy.get('.duration-picker').should('not.be.visible');
  31. cy.get('@dialog').then(dialog => {
  32. let value = dialog.get_value('duration');
  33. expect(value).to.equal(3889800);
  34. cy.hide_dialog();
  35. });
  36. });
  37. it('should hide days or seconds according to duration options', () => {
  38. get_dialog_with_duration(1, 1).as('dialog');
  39. cy.get('.frappe-control[data-fieldname=duration] input').first();
  40. cy.get('.duration-input[data-duration=days]').should('not.be.visible');
  41. cy.get('.duration-input[data-duration=seconds]').should('not.be.visible');
  42. });
  43. });