2021-08-09 08:47:34 +00:00
|
|
|
type RequirementType = "Required" | "Alternative" | "Disabled" | "Conditional";
|
|
|
|
|
|
|
|
export default class FlowDetails {
|
2022-05-18 09:16:47 +00:00
|
|
|
executionExists(name: string, exist = true) {
|
|
|
|
this.getExecution(name).should((!exist ? "not." : "") + "exist");
|
2021-08-09 08:47:34 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-09-23 15:06:58 +00:00
|
|
|
flowExists(name: string) {
|
|
|
|
cy.findAllByText(name).should("exist");
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-09 08:47:34 +00:00
|
|
|
private getExecution(name: string) {
|
2021-09-17 13:23:34 +00:00
|
|
|
return cy.findByTestId(name);
|
2021-08-09 08:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
moveRowTo(from: string, to: string) {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(from).trigger("dragstart").trigger("dragleave");
|
2021-08-09 08:47:34 +00:00
|
|
|
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(to)
|
2021-08-09 08:47:34 +00:00
|
|
|
.trigger("dragenter")
|
|
|
|
.trigger("dragover")
|
|
|
|
.trigger("drop")
|
|
|
|
.trigger("dragend");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
changeRequirement(execution: string, requirement: RequirementType) {
|
|
|
|
this.getExecution(execution)
|
|
|
|
.parentsUntil(".keycloak__authentication__flow-row")
|
|
|
|
.find(".keycloak__authentication__requirement-dropdown")
|
|
|
|
.click()
|
|
|
|
.contains(requirement)
|
|
|
|
.click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToDiagram() {
|
|
|
|
cy.get("#diagramView").click();
|
|
|
|
return this;
|
|
|
|
}
|
2021-09-06 12:43:36 +00:00
|
|
|
|
|
|
|
private clickEditDropdownForFlow(subFlowName: string, option: string) {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(`${subFlowName}-edit-dropdown`)
|
|
|
|
.click()
|
|
|
|
.contains(option)
|
|
|
|
.click();
|
2021-09-06 12:43:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addExecution(subFlowName: string, executionTestId: string) {
|
|
|
|
this.clickEditDropdownForFlow(subFlowName, "Add step");
|
|
|
|
|
|
|
|
cy.get(".pf-c-pagination").should("exist");
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(executionTestId).click();
|
|
|
|
cy.findByTestId("modal-add").click();
|
2021-09-06 12:43:36 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addCondition(subFlowName: string, executionTestId: string) {
|
|
|
|
this.clickEditDropdownForFlow(subFlowName, "Add condition");
|
|
|
|
|
|
|
|
cy.get(".pf-c-pagination").should("not.exist");
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(executionTestId).click();
|
|
|
|
cy.findByTestId("modal-add").click();
|
2021-09-06 12:43:36 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2021-09-23 15:06:58 +00:00
|
|
|
|
|
|
|
addSubFlow(subFlowName: string, name: string) {
|
|
|
|
this.clickEditDropdownForFlow(subFlowName, "Add sub-flow");
|
|
|
|
this.fillSubFlowModal(subFlowName, name);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-18 09:16:47 +00:00
|
|
|
clickRowDelete(name: string) {
|
|
|
|
cy.findByTestId(`${name}-delete`).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-09-23 15:06:58 +00:00
|
|
|
private fillSubFlowModal(subFlowName: string, name: string) {
|
|
|
|
cy.get(".pf-c-modal-box__title-text").contains(
|
|
|
|
"Add step to " + subFlowName
|
|
|
|
);
|
|
|
|
cy.findByTestId("name").type(name);
|
|
|
|
cy.findByTestId("modal-add").click();
|
|
|
|
}
|
|
|
|
|
|
|
|
fillCreateForm(
|
|
|
|
name: string,
|
|
|
|
description: string,
|
|
|
|
type: "Basic flow" | "Client flow"
|
|
|
|
) {
|
|
|
|
cy.findByTestId("alias").type(name);
|
|
|
|
cy.findByTestId("description").type(description);
|
|
|
|
cy.get("#flowType").click().parent().contains(type).click();
|
|
|
|
cy.findByTestId("create").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addSubFlowToEmpty(subFlowName: string, name: string) {
|
|
|
|
cy.findByTestId("addSubFlow").click();
|
|
|
|
this.fillSubFlowModal(subFlowName, name);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2021-08-09 08:47:34 +00:00
|
|
|
}
|