diff --git a/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIf.ts b/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIf.ts index 0bbf039755..73519d912e 100644 --- a/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIf.ts +++ b/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIf.ts @@ -42,7 +42,7 @@ export function describeWhatIf( ) { describeWhatIfCommonFunctionalities(datasetShape); describeAxisFlyouts(datasetShape); - describeWhatIfCreate(datasetShape); + describeWhatIfCreate(datasetShape, name); } }); } diff --git a/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIfCreate.ts b/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIfCreate.ts index 4ca95d00df..96f9c1d4d4 100644 --- a/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIfCreate.ts +++ b/libs/e2e/src/lib/describer/modelAssessment/whatIfCounterfactuals/describeWhatIfCreate.ts @@ -4,8 +4,12 @@ import { getSpan } from "../../../../util/getSpan"; import { Locators } from "../Constants"; import { IModelAssessmentData } from "../IModelAssessmentData"; +import { modelAssessmentDatasets } from "../modelAssessmentDatasets"; -export function describeWhatIfCreate(dataShape: IModelAssessmentData): void { +export function describeWhatIfCreate( + dataShape: IModelAssessmentData, + name?: keyof typeof modelAssessmentDatasets +): void { describe("What if Create counterfactual", () => { before(() => { cy.get(Locators.WICDatapointDropbox).click(); @@ -50,40 +54,42 @@ export function describeWhatIfCreate(dataShape: IModelAssessmentData): void { dataShape.whatIfCounterfactualsData?.columnHeaderAfterSort || "" ); }); + // AML do not need to execute below tests, as these options are not available for static view + if (name) { + it("Should have 'Create your own counterfactual' section and it should be editable", () => { + cy.get(Locators.CreateYourOwnCounterfactualInputField) + .eq(2) + .clear() + .type( + dataShape.whatIfCounterfactualsData + ?.createYourOwnCounterfactualInputFieldUpdated || "25" + ); + cy.get(Locators.CreateYourOwnCounterfactualInputField).eq(2).focus(); + cy.focused() + .should("have.attr", "value") + .and( + "contain", + dataShape.whatIfCounterfactualsData + ?.createYourOwnCounterfactualInputFieldUpdated || "25" + ); + }); - it("Should have 'Create your own counterfactual' section and it should be editable", () => { - cy.get(Locators.CreateYourOwnCounterfactualInputField) - .eq(2) - .clear() - .type( - dataShape.whatIfCounterfactualsData - ?.createYourOwnCounterfactualInputFieldUpdated || "25" - ); - cy.get(Locators.CreateYourOwnCounterfactualInputField).eq(2).focus(); - cy.focused() - .should("have.attr", "value") - .and( - "contain", - dataShape.whatIfCounterfactualsData - ?.createYourOwnCounterfactualInputFieldUpdated || "25" - ); - }); - - it("Should have what-if counterfactual name as 'Copy of row ' by default and should be editable", () => { - cy.get(Locators.WhatIfNameLabel) - .should("have.attr", "value") - .and("contain", dataShape.whatIfCounterfactualsData?.whatIfNameLabel); - cy.get(Locators.WhatIfNameLabel).type( - dataShape.whatIfCounterfactualsData?.whatIfNameLabelUpdated || - "New Copy of row 1" - ); - cy.get(Locators.WhatIfNameLabel) - .should("have.attr", "value") - .and( - "contain", - dataShape.whatIfCounterfactualsData?.whatIfNameLabelUpdated + it("Should have what-if counterfactual name as 'Copy of row ' by default and should be editable", () => { + cy.get(Locators.WhatIfNameLabel) + .should("have.attr", "value") + .and("contain", dataShape.whatIfCounterfactualsData?.whatIfNameLabel); + cy.get(Locators.WhatIfNameLabel).type( + dataShape.whatIfCounterfactualsData?.whatIfNameLabelUpdated || + "New Copy of row 1" ); - }); + cy.get(Locators.WhatIfNameLabel) + .should("have.attr", "value") + .and( + "contain", + dataShape.whatIfCounterfactualsData?.whatIfNameLabelUpdated + ); + }); + } }); describe.skip("What-If save scenario", () => { diff --git a/libs/e2e/src/util/createCohort.ts b/libs/e2e/src/util/createCohort.ts index 67885259a5..08ae1ee178 100644 --- a/libs/e2e/src/util/createCohort.ts +++ b/libs/e2e/src/util/createCohort.ts @@ -3,10 +3,13 @@ import { Locators } from "../lib/describer/modelAssessment/Constants"; +import { generateId } from "./generateId"; + export function createCohort(): void { + const cohortName = `CohortCreateE2E-${generateId(4)}`; cy.get(Locators.CreateNewCohortButton).click(); cy.get("#cohortEditPanel").should("exist"); - cy.get(Locators.CohortNameInput).clear().type("CohortCreateE2E"); + cy.get(Locators.CohortNameInput).clear().type(cohortName); cy.get(Locators.CohortFilterSelection).eq(1).check(); // select Dataset cy.get(Locators.CohortAddFilterButton).click(); cy.get(Locators.CohortSaveAndSwitchButton).eq(0).click({ force: true }); diff --git a/libs/e2e/src/util/generateId.ts b/libs/e2e/src/util/generateId.ts new file mode 100644 index 0000000000..125a67a598 --- /dev/null +++ b/libs/e2e/src/util/generateId.ts @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export function generateId(length?: number): string { + const len = length === undefined ? 4 : length; + // tslint:disable-next-line: insecure-random + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, "") + .slice(0, Math.max(0, len)); +}