From 71dd267a5968fc9f787bb49ee109b1c54a7fe9cb Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 12 Jul 2022 16:29:59 +0200 Subject: [PATCH] added flow edit details test (#2950) --- cypress/e2e/authentication_test.spec.ts | 14 ++++++++++++++ .../admin_console/components/ActionToolbarPage.ts | 11 ++++++++++- .../manage/authentication/DuplicateFlowModal.ts | 8 ++++---- .../manage/authentication/FlowDetail.ts | 4 ++-- src/authentication/components/FlowRow.tsx | 2 +- src/authentication/components/FlowTitle.tsx | 4 +++- src/authentication/form/NameDescription.tsx | 2 +- 7 files changed, 35 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/authentication_test.spec.ts b/cypress/e2e/authentication_test.spec.ts index 3ae57a63ff..5db5bf95df 100644 --- a/cypress/e2e/authentication_test.spec.ts +++ b/cypress/e2e/authentication_test.spec.ts @@ -87,6 +87,20 @@ describe("Authentication test", () => { }); }); + it("Should edit flow details", () => { + const name = "Copy of browser"; + listingPage.goToItemDetails(name); + const commonPage = new CommonPage(); + + commonPage + .actionToolbarUtils() + .clickActionToggleButton() + .clickDropdownItem("Edit info"); + + duplicateFlowModal.fill(name, "Other description"); + masthead.checkNotificationMessage("Flow successfully updated"); + }); + it("Should change requirement of cookie", () => { listingPage.goToItemDetails("Copy of browser"); diff --git a/cypress/support/pages/admin_console/components/ActionToolbarPage.ts b/cypress/support/pages/admin_console/components/ActionToolbarPage.ts index 41d8427413..826367d426 100644 --- a/cypress/support/pages/admin_console/components/ActionToolbarPage.ts +++ b/cypress/support/pages/admin_console/components/ActionToolbarPage.ts @@ -20,9 +20,18 @@ export default class ActionToolbarPage extends CommonElements { return this; } + private getDropdownItem(itemName: string) { + return cy.get(this.dropdownMenuItem).contains(itemName); + } + checkActionItemExists(itemName: string, exists: boolean) { const condition = exists ? "exist" : "not.exist"; - cy.get(this.dropdownMenuItem).contains(itemName).should(condition); + this.getDropdownItem(itemName).should(condition); + return this; + } + + clickDropdownItem(itemName: string) { + this.getDropdownItem(itemName).click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts b/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts index 6b91a5b911..b8a0a0f8d2 100644 --- a/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts +++ b/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts @@ -1,14 +1,14 @@ export default class DuplicateFlowModal { - private aliasInput = "alias"; + private nameInput = "name"; private descriptionInput = "description"; private confirmButton = "confirm"; private errorText = ".pf-m-error"; fill(name?: string, description?: string) { - cy.findByTestId(this.aliasInput).clear(); + cy.findByTestId(this.nameInput).clear(); if (name) { - cy.findByTestId(this.aliasInput).type(name); - if (description) cy.get(this.descriptionInput).type(description); + cy.findByTestId(this.nameInput).type(name); + if (description) cy.findByTestId(this.descriptionInput).type(description); } cy.findByTestId(this.confirmButton).click(); diff --git a/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts b/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts index ca8ebfea7a..bdd64a3d1a 100644 --- a/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts +++ b/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts @@ -23,7 +23,7 @@ export default class FlowDetails { expectPriorityChange(execution: string, callback: () => void) { cy.findAllByTestId(execution).then((rowDetails) => { - const executionId = rowDetails.children().attr("id"); + const executionId = rowDetails.children().attr("data-id"); cy.intercept( "POST", `/admin/realms/test/authentication/executions/${executionId}/lower-priority` @@ -101,7 +101,7 @@ export default class FlowDetails { description: string, type: "Basic flow" | "Client flow" ) { - cy.findByTestId("alias").type(name); + cy.findByTestId("name").type(name); cy.findByTestId("description").type(description); cy.get("#flowType").click().parent().contains(type).click(); cy.findByTestId("create").click(); diff --git a/src/authentication/components/FlowRow.tsx b/src/authentication/components/FlowRow.tsx index 30afa3dd86..b3c7c6e28e 100644 --- a/src/authentication/components/FlowRow.tsx +++ b/src/authentication/components/FlowRow.tsx @@ -81,7 +81,7 @@ export const FlowRow = ({ {!execution.authenticationFlow && ( diff --git a/src/authentication/components/FlowTitle.tsx b/src/authentication/components/FlowTitle.tsx index 47bc21d8c9..b887dcf597 100644 --- a/src/authentication/components/FlowTitle.tsx +++ b/src/authentication/components/FlowTitle.tsx @@ -15,7 +15,9 @@ export const FlowTitle = ({ id, title }: FlowTitleProps) => { className="keycloak__authentication__title" isFlat > - {title} + + {title} + ); }; diff --git a/src/authentication/form/NameDescription.tsx b/src/authentication/form/NameDescription.tsx index 7123d27c73..d488ea51b3 100644 --- a/src/authentication/form/NameDescription.tsx +++ b/src/authentication/form/NameDescription.tsx @@ -32,7 +32,7 @@ export const NameDescription = () => { type="text" id="kc-name" name="alias" - data-testid="alias" + data-testid="name" ref={register({ required: true })} validated={ errors.alias ? ValidatedOptions.error : ValidatedOptions.default