Skip to content

Commit

Permalink
digiwf-cypress init test example all input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir committed Jun 19, 2024
1 parent ae36155 commit bafb9b2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions digiwf-cypress/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require("dotenv").config({ path: ".env.local" });
module.exports = defineConfig({
viewportHeight: 1200,
viewportWidth: 2000,
scrollBehavior: "center",
videosFolder: "output/videos",
reporter: "cypress-multi-reporters",
reporterOptions: {
Expand Down
26 changes: 25 additions & 1 deletion digiwf-cypress/cypress/components/form.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
class Form {
formElements = {
form: () => cy.get(".container form .vjsf-property-allOf-0"),
inputElement: (inputId) =>
cy.get(
'.container form .vjsf-property[class*="' +
inputId +
' "] input[type!="hidden"]'
),
textareaElement: (inputId) =>
cy.get(
'.container form .vjsf-property[class*="' +
inputId +
' "] textarea[type!="hidden"]'
),
checkboxElement: (inputId) =>
cy.get(
'.container form .vjsf-property[class*="' +
inputId +
' "] .v-input--selection-controls__input'
),
selectDropdown: (index) =>
cy.get(`[role="listbox"]:visible .v-list-item:nth-child(${index + 1})`),
};

waitFormVisible() {
this.formElements.form().should("be.visible");
}

setSingleUserInput(input, user) {
input.type(user);
cy.wait("@dataUserSearch").its("response.statusCode").should("equal", 200);
input.type("{enter}");
this.formElements.selectDropdown(0).click();
}

setSelect(input, indexes) {
input.click();
if (indexes instanceof Number) {
this.formElements.selectDropdown(Number(indexes)).click();
} else if (indexes instanceof Array) {
for (const i in indexes) {
this.formElements.selectDropdown(Number(i)).click();
}
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion digiwf-cypress/cypress/e2e/3-example-all-input-fields.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ describe("Example Usertask", () => {

cy.log("First task");
let myTasks = nav.openMyTasks();
myTasks.itemContainsText(0, "User Task");
myTasks.itemContainsText(0, exampleAllInputFields.headline1);
myTasks.itemContainsText(0, exampleAllInputFieldsStart.headline);
myTasks.clickItem(0);
exampleAllInputFields.checkHeadline1();
exampleAllInputFields.waitFormVisible();
exampleAllInputFields.clickComplete();
exampleAllInputFields.hasValidationAlert();
exampleAllInputFields.fillDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ExampleAllInputFields extends Task {
textfield: (suffix = "") =>
this.formElements.inputElement(`FormField_text${suffix}`),
textarea: (suffix = "") =>
this.formElements.inputElement(`FormField_textarea${suffix}`),
this.formElements.textareaElement(`FormField_textarea${suffix}`),
integer: (suffix = "") =>
this.formElements.inputElement(`FormField_integer${suffix}`),
number: (suffix = "") =>
Expand Down Expand Up @@ -37,10 +37,11 @@ class ExampleAllInputFields extends Task {
this.elements.integer().type("123");
this.elements.number().type("123,123");
this.elements.checkbox().click();
this.elements.date().type("30.01.2024");
this.elements.date().type("2024-01-30");
this.elements.time().type("13:45");
this.elements.select().select("1");
this.elements.multiselect().select(["1", "2"]);
this.setSelect(this.elements.select(), 0);
this.elements.textfield().click();
this.setSelect(this.elements.multiselect(), [0, 1]);
}
}

Expand Down

0 comments on commit bafb9b2

Please sign in to comment.