Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

111 рядки
2.4 KiB

  1. context("Control Float", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app/website");
  5. });
  6. function get_dialog_with_float() {
  7. return cy.dialog({
  8. title: "Float Check",
  9. animate: false,
  10. fields: [
  11. {
  12. fieldname: "float_number",
  13. fieldtype: "Float",
  14. Label: "Float",
  15. },
  16. ],
  17. });
  18. }
  19. it("check value changes", () => {
  20. get_dialog_with_float().as("dialog");
  21. cy.wait(300);
  22. let data = get_data();
  23. data.forEach((x) => {
  24. cy.window()
  25. .its("xhiveframework")
  26. .then((xhiveframework) => {
  27. xhiveframework.boot.sysdefaults.number_format = x.number_format;
  28. });
  29. x.values.forEach((d) => {
  30. cy.get_field("float_number", "Float").clear();
  31. cy.wait(200);
  32. cy.fill_field("float_number", d.input, "Float").blur();
  33. cy.get_field("float_number", "Float").should("have.value", d.blur_expected);
  34. cy.wait(100);
  35. cy.get_field("float_number", "Float").focus();
  36. cy.wait(100);
  37. cy.get_field("float_number", "Float").blur();
  38. cy.wait(100);
  39. cy.get_field("float_number", "Float").focus();
  40. cy.wait(100);
  41. cy.get_field("float_number", "Float").should("have.value", d.focus_expected);
  42. });
  43. });
  44. });
  45. function get_data() {
  46. return [
  47. {
  48. number_format: "#.###,##",
  49. values: [
  50. {
  51. input: "364.87,334",
  52. blur_expected: "36.487,334",
  53. focus_expected: "36.487,334",
  54. },
  55. {
  56. input: "36487,335",
  57. blur_expected: "36.487,335",
  58. focus_expected: "36.487,335",
  59. },
  60. {
  61. input: "2*(2+47)+1,5+1",
  62. blur_expected: "100,500",
  63. focus_expected: "100,500",
  64. },
  65. ],
  66. },
  67. {
  68. number_format: "#,###.##",
  69. values: [
  70. {
  71. input: "464,87.334",
  72. blur_expected: "46,487.334",
  73. focus_expected: "46,487.334",
  74. },
  75. {
  76. input: "46487.335",
  77. blur_expected: "46,487.335",
  78. focus_expected: "46,487.335",
  79. },
  80. {
  81. input: "3*(2+47)+1.5+1",
  82. blur_expected: "149.500",
  83. focus_expected: "149.500",
  84. },
  85. ],
  86. },
  87. {
  88. // '.' is the parseFloat's decimal separator
  89. number_format: "#.###,##",
  90. values: [
  91. {
  92. input: "12.345",
  93. blur_expected: "12.345,000",
  94. focus_expected: "12.345,000",
  95. },
  96. {
  97. // parseFloat would reduce 12,340 to 12,34 if this string was ever to be parsed
  98. input: "12.340",
  99. blur_expected: "12.340,000",
  100. focus_expected: "12.340,000",
  101. },
  102. ],
  103. },
  104. ];
  105. }
  106. });