test: awesomplete
This commit is contained in:
parent
0b95b28bfe
commit
c31cd09040
1 changed files with 19 additions and 27 deletions
|
|
@ -2,60 +2,52 @@ context("Control Autocomplete", () => {
|
|||
before(() => {
|
||||
cy.login();
|
||||
cy.visit("/app");
|
||||
cy.wait(4000);
|
||||
});
|
||||
|
||||
function get_dialog_with_autocomplete(options) {
|
||||
cy.visit("/app");
|
||||
cy.wait(1000); // wait for the workspace to load
|
||||
|
||||
const get_dialog_with_autocomplete = (fieldname, options) => {
|
||||
return cy.dialog({
|
||||
title: "Autocomplete",
|
||||
fields: [
|
||||
{
|
||||
label: "Select an option",
|
||||
fieldname: "autocomplete",
|
||||
fieldname: fieldname,
|
||||
fieldtype: "Autocomplete",
|
||||
options: options || ["Option 1", "Option 2", "Option 3"],
|
||||
options: options,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
it("should set the valid value", () => {
|
||||
get_dialog_with_autocomplete().as("dialog");
|
||||
|
||||
cy.get(".frappe-control[data-fieldname=autocomplete] input").as("input");
|
||||
cy.get("@input").focus();
|
||||
cy.get(".frappe-control[data-fieldname=autocomplete]")
|
||||
.findByRole("listbox")
|
||||
.should("be.visible");
|
||||
cy.get("@input").type("2", { delay: 300 }).type("{enter}", { delay: 300 });
|
||||
const fieldname = "autocomplete_1";
|
||||
get_dialog_with_autocomplete(fieldname, ["Option 1", "Option 2", "Option 3"]).as("dialog");
|
||||
cy.get(`.control-input > .awesomplete > input[data-fieldname=${fieldname}]`).as("input");
|
||||
cy.wait(500);
|
||||
cy.get("@input").blur();
|
||||
cy.get("@input").type("2{enter}", { delay: 300 });
|
||||
cy.get("@dialog").then((dialog) => {
|
||||
let value = dialog.get_value("autocomplete");
|
||||
let value = dialog.get_value(fieldname);
|
||||
expect(value).to.eq("Option 2");
|
||||
dialog.clear();
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
|
||||
it("should set the valid value with different label", () => {
|
||||
const options_with_label = [
|
||||
const fieldname = "autocomplete_2";
|
||||
get_dialog_with_autocomplete(fieldname, [
|
||||
{ label: "Option 1", value: "option_1" },
|
||||
{ label: "Option 2", value: "option_2" },
|
||||
];
|
||||
get_dialog_with_autocomplete(options_with_label).as("dialog");
|
||||
]).as("dialog");
|
||||
|
||||
cy.get(".frappe-control[data-fieldname=autocomplete] input").as("input");
|
||||
cy.get("@input").focus();
|
||||
cy.get(".frappe-control[data-fieldname=autocomplete]")
|
||||
.findByRole("listbox")
|
||||
.should("be.visible");
|
||||
cy.get("@input").type("2{enter}", { delay: 300 }).blur();
|
||||
cy.get(`.control-input > .awesomplete > input[data-fieldname=${fieldname}]`).as("input");
|
||||
cy.wait(500);
|
||||
cy.get("@input").type("2{enter}", { delay: 300 });
|
||||
cy.get("@dialog").then((dialog) => {
|
||||
let value = dialog.get_value("autocomplete");
|
||||
let value = dialog.get_value(fieldname);
|
||||
expect(value).to.eq("option_2");
|
||||
dialog.clear();
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue