Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

control_float.js 1.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. fields: [
  10. {
  11. fieldname: "float_number",
  12. fieldtype: "Float",
  13. Label: "Float"
  14. }
  15. ]
  16. });
  17. }
  18. it("check value changes", () => {
  19. get_dialog_with_float().as("dialog");
  20. let data = get_data();
  21. data.forEach(x => {
  22. cy.window()
  23. .its("frappe")
  24. .then(frappe => {
  25. frappe.boot.sysdefaults.number_format = x.number_format;
  26. });
  27. x.values.forEach(d => {
  28. cy.get_field("float_number", "Float").clear();
  29. cy.fill_field("float_number", d.input, "Float").blur();
  30. cy.get_field("float_number", "Float").should(
  31. "have.value",
  32. d.blur_expected
  33. );
  34. cy.get_field("float_number", "Float").focus();
  35. cy.get_field("float_number", "Float").blur();
  36. cy.get_field("float_number", "Float").focus();
  37. cy.get_field("float_number", "Float").should(
  38. "have.value",
  39. d.focus_expected
  40. );
  41. });
  42. });
  43. });
  44. function get_data() {
  45. return [
  46. {
  47. number_format: "#.###,##",
  48. values: [
  49. {
  50. input: "364.87,334",
  51. blur_expected: "36.487,334",
  52. focus_expected: "36487.334"
  53. },
  54. {
  55. input: "36487,334",
  56. blur_expected: "36.487,334",
  57. focus_expected: "36487.334"
  58. },
  59. {
  60. input: "100",
  61. blur_expected: "100,000",
  62. focus_expected: "100"
  63. }
  64. ]
  65. },
  66. {
  67. number_format: "#,###.##",
  68. values: [
  69. {
  70. input: "364,87.334",
  71. blur_expected: "36,487.334",
  72. focus_expected: "36487.334"
  73. },
  74. {
  75. input: "36487.334",
  76. blur_expected: "36,487.334",
  77. focus_expected: "36487.334"
  78. },
  79. {
  80. input: "100",
  81. blur_expected: "100.000",
  82. focus_expected: "100"
  83. }
  84. ]
  85. }
  86. ];
  87. }
  88. });