Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cypress all inputs test #1783

Merged
merged 48 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
633b514
digiwf-cypress refactor and cleanup classes
simonhir Jun 17, 2024
85cfa70
digiwf-cypress refactor and cleanup classes
simonhir Jun 17, 2024
33f355b
digiwf-cypress refactor and cleanup classes
simonhir Jun 17, 2024
fd60b41
digiwf-cypress refactor input selector
simonhir Jun 17, 2024
2d894ce
digiwf-cypress refactor input selector
simonhir Jun 17, 2024
60ca7dd
digiwf-cypress delay request to have minimal duration
simonhir Jun 17, 2024
ce918d7
digiwf-cypress env group name
simonhir Jun 17, 2024
00c270f
digiwf-cypress increase timeout for loading btn
simonhir Jun 17, 2024
9a34517
digiwf-cypress update dependencies
simonhir Jun 17, 2024
31cb0b1
digiwf-cypress add prettier
simonhir Jun 17, 2024
aadf1fe
digiwf-cypress refactor env usage
simonhir Jun 17, 2024
c9b321f
digiwf-cypress refactor task count compare and process start
simonhir Jun 18, 2024
1b9e02b
digiwf-cypress increase load btn timeout to 30s
simonhir Jun 18, 2024
2a8b0ac
digiwf-cypress fix nav btns
simonhir Jun 18, 2024
a744598
digiwf-cypress init grouptask test
simonhir Jun 18, 2024
157e8ae
Merge branch 'refs/heads/dev' into feature/cypress-grouptask
simonhir Jun 18, 2024
c718620
digiwf-cypress fix package-lock.json
simonhir Jun 18, 2024
38e83b8
digiwf-cypress refactor start waiting
simonhir Jun 18, 2024
56b2e48
digiwf-cypress update grouptask test
simonhir Jun 18, 2024
ac445dd
digiwf-cypress add code comments
simonhir Jun 18, 2024
764c4b7
digiwf-cypress refactor loading timeout
simonhir Jun 19, 2024
0d47c66
digiwf-cypress form extract task elements
simonhir Jun 19, 2024
dd6276e
digiwf-cypress tests use headline instead of inline string
simonhir Jun 19, 2024
2e6276b
digiwf-cypress form add single user input
simonhir Jun 19, 2024
ae36155
digiwf-cypress init test example all input fields
simonhir Jun 19, 2024
bafb9b2
digiwf-cypress init test example all input fields
simonhir Jun 19, 2024
2c88cc2
digiwf-cypress update test example all input fields
simonhir Jun 19, 2024
0197f72
digiwf-cypress update test example all input fields
simonhir Jun 20, 2024
ae3cd5a
digiwf-cypress fix pagination goToLastPage
simonhir Jun 20, 2024
1657e5e
digiwf-cypress update js docs
simonhir Jun 21, 2024
316b823
digiwf-cypress update test example all input fields
simonhir Jun 21, 2024
ebc312f
digiwf-cypress update test example all input fields
simonhir Jun 21, 2024
83be2fa
digiwf-cypress update test example all input fields
simonhir Jun 21, 2024
7083cf4
digiwf-cypress update test example all input fields
simonhir Jun 21, 2024
fd77335
digiwf-cypress update test example all input fields
simonhir Jun 21, 2024
ce77560
Merge branch 'refs/heads/dev' into feature/cypress-all-inputs
simonhir Jun 24, 2024
eb486be
digiwf-cypress refactor reporter setup
simonhir Jun 24, 2024
804263b
digiwf-cypress fix typo
simonhir Jun 24, 2024
0317d00
digiwf-cypress fix example grouptask test
simonhir Jun 24, 2024
aec8b00
digiwf-cypress update npm commands
simonhir Jun 24, 2024
c4daa20
digiwf-cypress increase default timeout
simonhir Jun 24, 2024
8434d02
Revert "digiwf-cypress increase default timeout"
simonhir Jun 24, 2024
b75d9ba
digiwf-cypress all inputs update number check
simonhir Jun 24, 2024
1a5450d
digiwf-cypress all inputs optional container selector workaround
simonhir Jun 24, 2024
56e0c54
digiwf-cypress all inputs add readonly page support
simonhir Jun 24, 2024
2f4441e
Merge branch 'refs/heads/dev' into feature/cypress-all-inputs
simonhir Jun 27, 2024
968cba2
cypress increase default timeout
simonhir Jun 28, 2024
df9d55d
cypress update README.md
simonhir Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions digiwf-cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ cd digiwf-cypress
# set proxy (remote env) or unset proxy (local) via env variables if needed
export HTTP_PROXY=; export HTTPS_PROXY=; export NO_PROXY=
# setup .env file or needed env variables
npx cypress run # a) to run all the tests
npx cypress open # b) to open the cypress app and run each test separate
npm test # a) to run all the tests
npm start # b) to open the cypress app and run each test separate
```

a) There will be a test summary in the end in the bash and the produced videos and test reports in the
Expand Down
14 changes: 5 additions & 9 deletions digiwf-cypress/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ require("dotenv").config({ path: ".env.local" });
module.exports = defineConfig({
viewportHeight: 1200,
viewportWidth: 2000,
defaultCommandTimeout: 10000,
scrollBehavior: "center",
videosFolder: "output/videos",
reporter: "cypress-multi-reporters",
reporter: "junit",
reporterOptions: {
reporterEnabled: "mochawesome",
mochawesomeReporterOptions: {
reportDir: "output/reports/mocha",
quite: true,
overwrite: false,
html: false,
json: true,
},
mochaFile: "output/reports/junit-[hash].xml",
toConsole: true,
},
env: {
sso_url: process.env.SSO_URL,
Expand Down
125 changes: 119 additions & 6 deletions digiwf-cypress/cypress/components/form.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,131 @@
class Form {
formElements = {
form: () => cy.get(".container form .vjsf-property-allOf-0"),
tab: (index) =>
cy.get(
`.container form .v-tabs [role="tablist"] .v-tab:nth-of-type(${index + 1})`
),
loadingInput: () => cy.get(".container form .v-input--is-loading"),
inputElement: (inputId) =>
cy.get(
'.container form .vjsf-property[class*="' +
inputId +
' "] input[type!="hidden"]'
`.container form .vjsf-property[class*="${inputId} "] input[type!="hidden"]`
),
textareaElement: (inputId) =>
cy.get(
`.container form .vjsf-property[class*="${inputId} "] textarea[type!="hidden"]:visible`
),
markdownReadonly: (inputId) =>
cy.get(`.container form .vjsf-property[class*="${inputId} "] .v-card`),
checkboxElement: (inputId) =>
cy.get(
'.container form .vjsf-property[class*="' +
inputId +
' "] .v-input--selection-controls__input'
`.container form .vjsf-property[class*="${inputId} "] .v-input--selection-controls__input`
),
switchElement: (inputId) =>
cy.get(
`.container form .vjsf-property[class*="${inputId} "] .v-input--selection-controls__ripple`
),
selectDropdown: (index) =>
cy.get(`[role="listbox"]:visible .v-list-item:nth-child(${index + 1})`),
comboboxValues: (input) => input.parent().find("span span"),
multiFileValues: (input) =>
input
.closest(".vjsf-property")
.find(".listWrapper .doc-card .v-card__title div"),
};

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

waitLoadingFinished() {
this.formElements.loadingInput().should("not.exist");
}

setUserInput(input, user) {
input.type(user, { force: true });
cy.wait("@dataUserSearch").its("response.statusCode").should("equal", 200);
this.formElements
.selectDropdown(0)
.contains("Benutzer werden gesucht")
.should("not.exist");
this.formElements.selectDropdown(0).click();
}

setSelect(input, indexes) {
input.click();
for (const i of indexes) {
this.formElements.selectDropdown(i).click();
}
}

selectHasValue(input, items) {
let res = [];
input
.parent()
.find(".v-select__selection span")
.each((i) => {
cy.wrap(i)
.invoke("text")
.then((text) => {
res.push(text.trim().replace(",", ""));
});
});
cy.wrap(res).then((i) => {
expect(i.sort()).to.deep.eq(items.sort());
});
}

multiFileInputHasValues(input, values) {
let res = [];
this.formElements.multiFileValues(input).each((i) => {
cy.wrap(i)
.invoke("text")
.then((text) => {
res.push(text.trim());
});
});
cy.wrap(res).then((i) => {
expect(i.sort()).to.deep.eq(values.sort());
});
}

userInputHasValue(input, user) {
input
.siblings("div")
.invoke("text")
.then((text) => text.trim())
.should("eq", user);
}

comboboxHasValues(input, values) {
let res = [];
this.formElements.comboboxValues(input).each((i) => {
cy.wrap(i)
.invoke("text")
.then((text) => {
res.push(text.trim());
});
});
cy.wrap(res).then((i) => {
expect(i.sort()).to.deep.eq(values.sort());
});
}

markdownHasValue(input, value) {
input
.closest(".vjsf-property")
.find('div.EasyMDEContainer [role="presentation"] pre:visible')
.invoke("text")
.then((text) => {
cy.wrap(text).should("eq", value);
});
}

markdownHasValueReadonly(input, value) {
input.invoke("text").then((text) => {
cy.wrap(text).should("eq", value);
});
}
}

export default Form;
1 change: 1 addition & 0 deletions digiwf-cypress/cypress/components/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Nav {

/**
* Compares two via {@link gatherTaskMetrics} collected task counts.
* Uses difference calculation to use values via Cypress aliases and support existing tasks.
* @param prefix1 Prefix used for the first collection.
* @param prefix2 Prefix used for the second collection.
* @param differences Map of differences between first and second collections.
Expand Down
6 changes: 3 additions & 3 deletions digiwf-cypress/cypress/components/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ class Pagination {

goToLastPage() {
let iteration = 1;
this.isLast(iteration);
this.#isLast(iteration);
}

isLast(iteration) {
#isLast(iteration) {
const maxIterations = 1000;
cy.log(iteration.toString());
if (iteration > maxIterations) {
Expand All @@ -133,7 +133,7 @@ class Pagination {
.then((last) => {
if (!last) {
iteration = iteration + 1;
this.isLast(iteration++);
this.#isLast(iteration);
}
});
}
Expand Down
12 changes: 11 additions & 1 deletion digiwf-cypress/cypress/components/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Task extends Form {
taskElements = {
completeButton: () => cy.get(`.container form .form-submit-button`),
headline: () => cy.get(".container h1"),
errorAlert: () => cy.get(".container .v-alert.error"),
};
groupTaskElements = {
assignSelfBtn: () => cy.get("button").contains("Bearbeiten"),
Expand All @@ -28,23 +29,32 @@ class Task extends Form {
cy.wait("@dataGetMyTasks").its("response.statusCode").should("equal", 200);
}

_hasAlertMessage(message) {
this.taskElements.errorAlert().contains(message).should("be.visible");
}

assignGroupTaskSelf() {
this.groupTaskElements.assignSelfBtn().click();
}

assignGroupTask(userRealname) {
this.groupTaskElements.assignBtn().click();
this.groupTaskElements.assignInput().should("be.visible");
this.groupTaskElements.assignInput().type(userRealname);
// workaround as input already searches after 3 chars and interrupts input
this.groupTaskElements.assignInput().type(userRealname.substring(0, 3));
cy.wait("@dataUserSearch").its("response.statusCode").should("equal", 200);
this.groupTaskElements.assignInput().type(userRealname.substring(3));
this.groupTaskElements.assignInput().should("have.value", userRealname);
this.groupTaskElements.assignInput().type("{enter}");
this.groupTaskElements.assignSubmit().click();
cy.wait("@dataAssignTask").its("response.statusCode").should("equal", 204);
openGroupTasks.waitLoadingFinished();
}

assignGroupTaskSelfOverride() {
this.groupTaskElements.assignSelfBtn().click();
this.groupTaskElements.assignSelfSubmit().click();
cy.wait("@dataAssignTask").its("response.statusCode").should("equal", 204);
this.taskElements.headline().should("be.visible");
}
}
Expand Down
3 changes: 2 additions & 1 deletion digiwf-cypress/cypress/e2e/1-example-usertask.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe("Example Usertask", () => {

cy.log("Test task exists");
let myTasks = nav.openMyTasks();
myTasks.itemContainsText(0, "User Task");
myTasks.itemContainsText(0, exampleUserTask.headline);
myTasks.itemContainsText(0, exampleUserTaskStart.headline);
nav.gatherTaskMetrics("created", ["myTasks"]);
nav.compareTaskMetrics("initial", "created", { myTasks: 1 });

Expand Down
55 changes: 55 additions & 0 deletions digiwf-cypress/cypress/e2e/3-example-all-input-fields.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import nav from "../components/nav";
import { USER_REALNAME } from "../constants/env";
import exampleAllInputFields from "../pages/processes/exampleAllInputFields";
import exampleAllInputFieldsStart from "../pages/processes/exampleAllInputFieldsStart";

beforeEach(() => {
cy.loginDefault();
});

describe("Example All Input Fields", () => {
it("passes", () => {
cy.visit("/");

cy.log("Start process");
let startProcess = nav.openStartProcess();
startProcess.startProcess(exampleAllInputFieldsStart.headline);
exampleAllInputFieldsStart.checkHeadline();
exampleAllInputFieldsStart.setUser(USER_REALNAME);
exampleAllInputFieldsStart.clickComplete();

cy.log("Fill out first task");
let myTasks = nav.openMyTasks();
myTasks.itemContainsText(0, exampleAllInputFields.headline1);
myTasks.itemContainsText(0, exampleAllInputFieldsStart.headline);
myTasks.clickItem(0);
exampleAllInputFields.checkHeadline1();
exampleAllInputFields.waitFormVisible();
exampleAllInputFields.clickComplete();
exampleAllInputFields.hasValidationAlert();
exampleAllInputFields.fillDefault();
exampleAllInputFields.clickComplete();

cy.log("Validate second task");
myTasks.waitNoUncompletedTasks();
myTasks.itemContainsText(0, exampleAllInputFields.headline2);
myTasks.itemContainsText(0, exampleAllInputFieldsStart.headline);
myTasks.clickItem(0);
exampleAllInputFields.checkHeadline2();
exampleAllInputFields.waitFormVisible();
exampleAllInputFields.validateDefault();
exampleAllInputFields.clickComplete();
myTasks.waitNoUncompletedTasks();

cy.log("Readonly task");
myTasks.waitNoUncompletedTasks();
myTasks.itemContainsText(0, exampleAllInputFields.headlineReadonly);
myTasks.itemContainsText(0, exampleAllInputFieldsStart.headline);
myTasks.clickItem(0);
exampleAllInputFields.checkHeadlineReadonly();
exampleAllInputFields.waitFormVisible();
exampleAllInputFields.validateDefault(true);
exampleAllInputFields.clickComplete();
myTasks.waitNoUncompletedTasks();
});
});
Loading