Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

47 rader
1.4 KiB

  1. context("Control Duration", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app/website");
  5. });
  6. function get_dialog_with_duration(hide_days = 0, hide_seconds = 0) {
  7. return cy.dialog({
  8. title: "Duration",
  9. fields: [
  10. {
  11. fieldname: "duration",
  12. fieldtype: "Duration",
  13. hide_days: hide_days,
  14. hide_seconds: hide_seconds,
  15. },
  16. ],
  17. });
  18. }
  19. it("should set duration", () => {
  20. get_dialog_with_duration().as("dialog");
  21. cy.get(".xhiveframework-control[data-fieldname=duration] input").first().click();
  22. cy.get(".duration-input[data-duration=days]")
  23. .type(45, { force: true })
  24. .blur({ force: true });
  25. cy.get(".duration-input[data-duration=minutes]").type(30).blur({ force: true });
  26. cy.get(".xhiveframework-control[data-fieldname=duration] input")
  27. .first()
  28. .should("have.value", "45d 30m");
  29. cy.get(".xhiveframework-control[data-fieldname=duration] input").first().blur();
  30. cy.get(".duration-picker").should("not.be.visible");
  31. cy.get("@dialog").then((dialog) => {
  32. let value = dialog.get_value("duration");
  33. expect(value).to.equal(3889800);
  34. cy.hide_dialog();
  35. });
  36. });
  37. it("should hide days or seconds according to duration options", () => {
  38. get_dialog_with_duration(1, 1).as("dialog");
  39. cy.get(".xhiveframework-control[data-fieldname=duration] input").first();
  40. cy.get(".duration-input[data-duration=days]").should("not.be.visible");
  41. cy.get(".duration-input[data-duration=seconds]").should("not.be.visible");
  42. });
  43. });