You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 lines
2.4 KiB

  1. context("Date Control", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app");
  5. });
  6. function get_dialog(date_field_options) {
  7. return cy.dialog({
  8. title: "Date",
  9. fields: [
  10. {
  11. label: "Date",
  12. fieldname: "date",
  13. fieldtype: "Date",
  14. in_list_view: 1,
  15. ...date_field_options,
  16. },
  17. ],
  18. });
  19. }
  20. it("Selecting a date from the datepicker & check prev & next button", () => {
  21. cy.clear_dialogs();
  22. cy.clear_datepickers();
  23. get_dialog().as("dialog");
  24. cy.get_field("date", "Date").click();
  25. cy.get(".datepicker--nav-title").click();
  26. cy.get(".datepicker--nav-title").click({ force: true });
  27. //Inputing values in the date field
  28. cy.get(
  29. ".datepicker--years > .datepicker--cells > .datepicker--cell[data-year=2020]"
  30. ).click();
  31. cy.get(
  32. ".datepicker--months > .datepicker--cells > .datepicker--cell[data-month=0]"
  33. ).click();
  34. cy.get(".datepicker--days > .datepicker--cells > .datepicker--cell[data-date=15]").click();
  35. // Verify if the selected date is set the date field
  36. cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-01-15");
  37. cy.get_field("date", "Date").click();
  38. //Clicking on the next button in the datepicker
  39. cy.get(".datepicker--nav-action[data-action=next]").click();
  40. //Selecting a date from the datepicker
  41. cy.get(".datepicker--cell[data-date=15]").click({ force: true });
  42. //Verifying if the selected date has been displayed in the date field
  43. cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-02-15");
  44. cy.wait(500);
  45. cy.get_field("date", "Date").click();
  46. //Clicking on the previous button in the datepicker
  47. cy.get(".datepicker--nav-action[data-action=prev]").click();
  48. //Selecting a date from the datepicker
  49. cy.get(".datepicker--cell[data-date=15]").click({ force: true });
  50. //Verifying if the selected date has been displayed in the date field
  51. cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-01-15");
  52. });
  53. it('Clicking on "Today" button gives todays date', () => {
  54. cy.clear_dialogs();
  55. cy.clear_datepickers();
  56. get_dialog().as("dialog");
  57. cy.get_field("date", "Date").click();
  58. //Clicking on "Today" button
  59. cy.get(".datepicker--button").click();
  60. //Verifying if clicking on "Today" button matches today's date
  61. cy.window().then((win) => {
  62. expect(win.cur_dialog.fields_dict.date.value).to.be.equal(
  63. win.xhiveframework.datetime.get_today()
  64. );
  65. });
  66. });
  67. });