25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

89 lines
2.0 KiB

  1. context("Control Currency", () => {
  2. const fieldname = "currency_field";
  3. before(() => {
  4. cy.login();
  5. cy.visit("/app/website");
  6. });
  7. function get_dialog_with_currency(df_options = {}) {
  8. return cy.dialog({
  9. title: "Currency Check",
  10. animate: false,
  11. fields: [
  12. {
  13. fieldname: fieldname,
  14. fieldtype: "Currency",
  15. Label: "Currency",
  16. ...df_options,
  17. },
  18. ],
  19. });
  20. }
  21. it("check value changes", () => {
  22. const TEST_CASES = [
  23. {
  24. input: "10.101",
  25. df_options: { precision: 1 },
  26. blur_expected: "10.1",
  27. },
  28. {
  29. input: "10.101",
  30. df_options: { precision: "3" },
  31. blur_expected: "10.101",
  32. },
  33. {
  34. input: "10.101",
  35. df_options: { precision: "" }, // default assumed to be 2;
  36. blur_expected: "10.10",
  37. },
  38. {
  39. input: "10.101",
  40. df_options: { precision: "0" },
  41. blur_expected: "10",
  42. },
  43. {
  44. input: "10.101",
  45. df_options: { precision: 0 },
  46. blur_expected: "10",
  47. },
  48. {
  49. input: "10.000",
  50. number_format: "#.###,##",
  51. df_options: { precision: 0 },
  52. blur_expected: "10.000",
  53. },
  54. {
  55. input: "10.000",
  56. number_format: "#.###,##",
  57. blur_expected: "10.000,00",
  58. },
  59. {
  60. input: "10.101",
  61. df_options: { precision: "" },
  62. blur_expected: "10.1",
  63. default_precision: 1,
  64. },
  65. ];
  66. TEST_CASES.forEach((test_case) => {
  67. cy.window()
  68. .its("xhiveframework")
  69. .then((xhiveframework) => {
  70. xhiveframework.boot.sysdefaults.currency = test_case.currency;
  71. xhiveframework.boot.sysdefaults.currency_precision = test_case.default_precision ?? 2;
  72. xhiveframework.boot.sysdefaults.number_format = test_case.number_format ?? "#,###.##";
  73. });
  74. get_dialog_with_currency(test_case.df_options).as("dialog");
  75. cy.wait(300);
  76. cy.get_field(fieldname, "Currency").clear();
  77. cy.wait(300);
  78. cy.fill_field(fieldname, test_case.input, "Currency").blur();
  79. cy.get_field(fieldname, "Currency").should("have.value", test_case.blur_expected);
  80. cy.hide_dialog();
  81. });
  82. });
  83. });