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.
 
 
 
 
 
 

90 line
2.5 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", () => {
  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. });
  38. it("Checking next and previous button", () => {
  39. cy.clear_dialogs();
  40. cy.clear_datepickers();
  41. get_dialog({ default: "2020-01-15" }).as("dialog");
  42. cy.get_field("date", "Date").click();
  43. //Clicking on the next button in the datepicker
  44. cy.get(".datepicker--nav-action[data-action=next]").click();
  45. //Selecting a date from the datepicker
  46. cy.get(".datepicker--cell[data-date=15]").click({ force: true });
  47. //Verifying if the selected date has been displayed in the date field
  48. cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-02-15");
  49. cy.wait(500);
  50. cy.get_field("date", "Date").click();
  51. //Clicking on the previous button in the datepicker
  52. cy.get(".datepicker--nav-action[data-action=prev]").click();
  53. //Selecting a date from the datepicker
  54. cy.get(".datepicker--cell[data-date=15]").click({ force: true });
  55. //Verifying if the selected date has been displayed in the date field
  56. cy.window().its("cur_dialog.fields_dict.date.value").should("be.equal", "2020-01-15");
  57. });
  58. it('Clicking on "Today" button gives todays date', () => {
  59. cy.clear_dialogs();
  60. cy.clear_datepickers();
  61. get_dialog().as("dialog");
  62. cy.get_field("date", "Date").click();
  63. //Clicking on "Today" button
  64. cy.get(".datepicker--button").click();
  65. //Verifying if clicking on "Today" button matches today's date
  66. cy.window().then((win) => {
  67. expect(win.cur_dialog.fields_dict.date.value).to.be.equal(
  68. win.influxframework.datetime.get_today()
  69. );
  70. });
  71. });
  72. });