No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

65 líneas
1.9 KiB

  1. context("Control Autocomplete", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app/website");
  5. });
  6. function get_dialog_with_autocomplete(options) {
  7. cy.visit("/app/website");
  8. return cy.dialog({
  9. title: "Autocomplete",
  10. fields: [
  11. {
  12. label: "Select an option",
  13. fieldname: "autocomplete",
  14. fieldtype: "Autocomplete",
  15. options: options || ["Option 1", "Option 2", "Option 3"],
  16. },
  17. ],
  18. });
  19. }
  20. it("should set the valid value", () => {
  21. get_dialog_with_autocomplete().as("dialog");
  22. cy.get(".xhiveframework-control[data-fieldname=autocomplete] input").focus().as("input");
  23. cy.wait(1000);
  24. cy.get("@input").type("2", { delay: 300 });
  25. cy.get(".xhiveframework-control[data-fieldname=autocomplete]")
  26. .findByRole("listbox")
  27. .should("be.visible");
  28. cy.get(".xhiveframework-control[data-fieldname=autocomplete] input").type("{enter}", {
  29. delay: 300,
  30. });
  31. cy.get(".xhiveframework-control[data-fieldname=autocomplete] input").blur();
  32. cy.get("@dialog").then((dialog) => {
  33. let value = dialog.get_value("autocomplete");
  34. expect(value).to.eq("Option 2");
  35. dialog.clear();
  36. });
  37. });
  38. it("should set the valid value with different label", () => {
  39. const options_with_label = [
  40. { label: "Option 1", value: "option_1" },
  41. { label: "Option 2", value: "option_2" },
  42. ];
  43. get_dialog_with_autocomplete(options_with_label).as("dialog");
  44. cy.get(".xhiveframework-control[data-fieldname=autocomplete] input").focus().as("input");
  45. cy.get(".xhiveframework-control[data-fieldname=autocomplete]")
  46. .findByRole("listbox")
  47. .should("be.visible");
  48. cy.get("@input").type("2", { delay: 300 });
  49. cy.get(".xhiveframework-control[data-fieldname=autocomplete] input").type("{enter}", {
  50. delay: 300,
  51. });
  52. cy.get(".xhiveframework-control[data-fieldname=autocomplete] input").blur();
  53. cy.get("@dialog").then((dialog) => {
  54. let value = dialog.get_value("autocomplete");
  55. expect(value).to.eq("option_2");
  56. dialog.clear();
  57. });
  58. });
  59. });