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

Fix cohort name conflict and not run few tests for AML #1442

Merged
merged 3 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function describeWhatIf(
) {
describeWhatIfCommonFunctionalities(datasetShape);
describeAxisFlyouts(datasetShape);
describeWhatIfCreate(datasetShape);
describeWhatIfCreate(datasetShape, name);
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 <index selected>' 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 <index selected>' 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", () => {
Expand Down
5 changes: 4 additions & 1 deletion libs/e2e/src/util/createCohort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
11 changes: 11 additions & 0 deletions libs/e2e/src/util/generateId.ts
Original file line number Diff line number Diff line change
@@ -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));
}