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

Vision Data Explorer Flyout tests #2208

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
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
ffaf951
ckpt
Advitya17 Jul 20, 2023
2efd461
test ckpt
Advitya17 Jul 20, 2023
345d3bb
constant button test ckpt
Advitya17 Jul 21, 2023
c326fb6
merge conflict fixes
Advitya17 Jul 21, 2023
4ba30d6
test ckpt
Advitya17 Jul 24, 2023
0bd2f1e
image explorer test ckpt
Advitya17 Jul 24, 2023
66f5fb2
merge conflict fix
Advitya17 Jul 24, 2023
ec3815a
readding constants
Advitya17 Jul 24, 2023
530c630
test fixes
Advitya17 Jul 24, 2023
88282ac
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Jul 24, 2023
594835f
line limit fix
Advitya17 Jul 25, 2023
f83688c
python lint fixes
Advitya17 Jul 25, 2023
c657628
added flyout constants
Advitya17 Jul 25, 2023
2dd58e2
reverted flyout test
Advitya17 Jul 25, 2023
2960f82
auto lint fixes
Advitya17 Jul 25, 2023
cdcf3d7
image click ckpt
Advitya17 Jul 26, 2023
24cc135
flyout test ckpt
Advitya17 Jul 26, 2023
2520b60
Flyout working test ckpt
Advitya17 Jul 27, 2023
8a95dcf
removed non-flyout tests/logic
Advitya17 Aug 2, 2023
9602285
merge conflict fix
Advitya17 Aug 2, 2023
13f11b1
reverted refactor
Advitya17 Aug 2, 2023
7d449c7
lint fixes + cy wait
Advitya17 Aug 3, 2023
8dea6b0
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Aug 3, 2023
213a2f0
flyout test tweak
Advitya17 Aug 18, 2023
2972b36
merge conflict fixes
Advitya17 Aug 18, 2023
60a489a
typo fix
Advitya17 Aug 18, 2023
b5a6a8d
auto lint fixes
Advitya17 Aug 18, 2023
e999763
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Aug 21, 2023
a234d0d
testing ckpt
Advitya17 Aug 21, 2023
e2ac173
notebook example tweak for EA on ubuntu
Advitya17 Aug 21, 2023
ce0268c
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Aug 21, 2023
d57893e
simplified od test
Advitya17 Aug 22, 2023
f0bb62c
trying with wait inside and
Advitya17 Aug 29, 2023
71f42e0
syntax fix
Advitya17 Aug 29, 2023
6af68aa
added timeout
Advitya17 Aug 29, 2023
e0c2d17
wait until logic
Advitya17 Aug 29, 2023
bc32b25
tests without image loading
Advitya17 Aug 29, 2023
b416db4
waitUntil refactor
Advitya17 Aug 29, 2023
173c46b
build fix
Advitya17 Aug 29, 2023
7c52d29
condition tweak
Advitya17 Aug 30, 2023
c41d0e1
test case tweak
Advitya17 Aug 30, 2023
8e42a85
latest dependency update
Advitya17 Sep 6, 2023
c3e86a9
added import
Advitya17 Sep 6, 2023
d821b24
test tweak with waitUntil
Advitya17 Sep 6, 2023
d46b4a0
Merge branch 'main' into agemawat/vision_flyout_tests
Advitya17 Sep 6, 2023
f6ce2d2
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
Advitya17 Sep 14, 2023
270e512
Merge branch 'agemawat/vision_flyout_tests' of https://github.com/mic…
Advitya17 Sep 19, 2023
c76bf88
get chained after waitUntil
Advitya17 Sep 19, 2023
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
13 changes: 13 additions & 0 deletions libs/e2e/src/lib/describer/modelAssessment/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export enum Locators {
AggregateBalanceMeasuresTable = "#aggregateBalanceMeasures .ms-DetailsList",
AggregateBalanceMeasuresTableColumns = "#aggregateBalanceMeasures .ms-DetailsList-headerWrapper div[aria-label]",
AggregateBalanceMeasuresTableRows = "#aggregateBalanceMeasures .ms-DetailsRow",
VisionDataAnalysisPivot = "#visionDataAnalysisPivot",
VisionDataAnalysisTab = "#visionDataAnalysisPivot .ms-Pivot-link",
VisionDataBalancePivotItem = "#visionDataAnalysisPivot button[name='Data balance']",
ForecastingDashboard = "#ModelAssessmentDashboard #ForecastingDashboard",
ForecastingTimeSeriesDropdown = "#ForecastingDashboard #ForecastingTimeSeriesDropdown",
ForecastingTimeSeriesDropdownOptions = "#ForecastingDashboard button[role='option']",
Expand All @@ -197,6 +200,16 @@ export enum Locators {
ForecastingScenarioChartCurves = "#ForecastingDashboard .highcharts-series-group .highcharts-series",
ForecastingScenarioChartLegendItems = "#ForecastingDashboard .highcharts-a11y-proxy-button",
VisionDataExplorer = "#VisionDataExplorer",
VisionDataExplorerImageExplorerViewSuccessImage = "#VisionDataExplorer #visionImage_0",
VisionDataExplorerFlyoutPredictionTitle = "#flyoutPredictionTitle",
VisionDataExplorerFlyoutPredictionLabel = "#flyoutPredLabel",
VisionDataExplorerFlyoutGroundTruthLabel = "#flyoutGtLabel",
VisionDataExplorerFlyoutImage = "#flyoutImage_0",
VisionDataExplorerFlyoutExplanationImage = "#flyoutExplanationImage_0",
VisionDataExplorerFlyoutMetadata = "#flyoutMetadata",
VisionDataExplorerFlyoutCloseButton = "button[aria-label='Close']",
VisionDataExplorerFlyoutCanvasToolsImageContainer = "#canvasToolsDiv #selectionDiv #editorDiv",
VisionDataExplorerFlyoutObjectSelection = "#Object Selection",
VisionDataExplorerCohortDropDown = "#VisionDataExplorer #dataExplorerCohortDropdown",
VisionDataExplorerSearchBox = "#VisionDataExplorer #dataExplorerSearchBox",
VisionDataExplorerThumbnailSize = "#VisionDataExplorer #dataExplorerThumbnailSize",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IModelAssessmentData } from "../IModelAssessmentData";

import { ensureAllVisionDataExplorerBasicElementsArePresent } from "./ensureAllVisionDataExplorerBasicElementsArePresent";
import { ensureAllVisionDataExplorerClassViewElementsAfterSelectionArePresent } from "./ensureAllVisionDataExplorerClassViewElementsAfterSelectionArePresent";
import { ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent } from "./ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent";
import { ensureAllVisionDataExplorerImageExplorerViewElementsAfterSelectionArePresent } from "./ensureAllVisionDataExplorerImageExplorerViewElementsAfterSelectionArePresent";
import { ensureAllVisionDataExplorerTableViewElementsAfterSelectionArePresent } from "./ensureAllVisionDataExplorerTableViewElementsAfterSelectionArePresent";
import {
Expand Down Expand Up @@ -35,6 +36,11 @@ export function describeVisionDataExplorer(
}

if (datasetShape.visionDataExplorerData?.hasVisionDataExplorerComponent) {
it("should Flyout view components when selected", () => {
ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent(
datasetShape
);
});
it("should have basic components in the initial state", () => {
ensureAllVisionDataExplorerBasicElementsArePresent();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { expect } from "chai";

import { Locators } from "../Constants";
import { IModelAssessmentData } from "../IModelAssessmentData";

import "cypress-wait-until";


export function ensureAllVisionDataExplorerFlyoutElementsAfterSelectionArePresent(
datasetShape: IModelAssessmentData
): void {
cy.get(Locators.VisionDataExplorerImageExplorerViewButton).click();

cy.waitUntil(() => {
return Cypress.$(Locators.VisionDataExplorerImageExplorerViewSuccessImage).length > 0
&& (Cypress.$(Locators.VisionDataExplorerImageExplorerViewSuccessImage)[0] as HTMLImageElement).naturalWidth > 0
&& (Cypress.$(Locators.VisionDataExplorerImageExplorerViewSuccessImage)[0] as HTMLImageElement).naturalHeight > 0;
}).get(Locators.VisionDataExplorerImageExplorerViewSuccessImage).click();

// cy.get(Locators.VisionDataExplorerImageExplorerViewSuccessImage, { timeout: 30000 })
// .should("be.visible")
// .and(($image) => {
// cy.wait(10000);
// // verifies the image is loaded
// expect(($image[0] as HTMLImageElement).naturalWidth).to.be.greaterThan(0);
// expect(($image[0] as HTMLImageElement).naturalHeight).to.be.greaterThan(
// 0
// );
// });

// cy.get(Locators.VisionDataExplorerImageExplorerViewSuccessImage).click();

cy.get(Locators.VisionDataExplorerFlyoutPredictionTitle).should("exist");

cy.get(Locators.VisionDataExplorerFlyoutPredictionLabel)
.invoke("text")
.then((predLabel) => {
cy.get(Locators.VisionDataExplorerFlyoutGroundTruthLabel)
.invoke("text")
.should((gtLabel) => {
expect(predLabel.split(": ")[1]).to.equal(gtLabel.split(": ")[1]);
});
});

cy.waitUntil(() => {
cy.reload()
return Cypress.$(Locators.VisionDataExplorerFlyoutImage).length > 0
&& (Cypress.$(Locators.VisionDataExplorerFlyoutImage)[0] as HTMLImageElement).naturalWidth > 0
&& (Cypress.$(Locators.VisionDataExplorerFlyoutImage)[0] as HTMLImageElement).naturalHeight > 0;
});

// cy.get(Locators.VisionDataExplorerFlyoutImage, { timeout: 10000 })
// .should("be.visible")
// .and(($image) => {
// cy.wait(10000);
// // verifies the image is loaded
// expect(($image[0] as HTMLImageElement).naturalWidth).to.be.greaterThan(0);
// expect(($image[0] as HTMLImageElement).naturalHeight).to.be.greaterThan(
// 0
// );
// });

if (datasetShape.isObjectDetection) {
cy.get(Locators.VisionDataExplorerFlyoutObjectSelection).should("exist");
} else {
cy.get(Locators.VisionDataExplorerFlyoutExplanationImage).should("exist");
}
cy.get(Locators.VisionDataExplorerFlyoutMetadata).should("exist");

cy.get(Locators.VisionDataExplorerFlyoutCloseButton).click();
}
2 changes: 1 addition & 1 deletion libs/e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"],
"types": ["cypress", "cypress-wait-until", "node"],
"isolatedModules": false
},
"include": ["src/**/*.ts", "src/**/*.js"]
Expand Down
2 changes: 1 addition & 1 deletion libs/e2e/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["cypress", "node"]
"types": ["cypress", "cypress-wait-until", "node"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
}
/>
</Stack.Item>
<Stack.Item id="predictionTitle">
<Stack.Item id="flyoutPredictionTitle">
{predictedY !== trueY ? (
<Text
variant="large"
Expand Down Expand Up @@ -179,13 +179,13 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
{item?.index}
</Text>
</Stack.Item>
<Stack.Item id="predLabel">
<Stack.Item id="flyoutPredLabel">
<Text variant="large">
{localization.InterpretVision.Dashboard.predictedY}
{predictedY}
</Text>
</Stack.Item>
<Stack.Item id="gtLabel">
<Stack.Item id="flyoutGtLabel">
<Text variant="large">
{localization.InterpretVision.Dashboard.trueY}
{trueY}
Expand Down Expand Up @@ -218,6 +218,7 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
{!this.props.loadingExplanation[0][index] ? (
<Stack.Item>
<Image
id={`flyoutExplanationImage_${item?.index}`}
src={`data:image/jpg;base64,${this.props.explanations
.get(0)
?.get(index)}`}
Expand Down Expand Up @@ -245,7 +246,10 @@ export class Flyout extends React.Component<IFlyoutProps, IFlyoutState> {
{localization.InterpretVision.Dashboard.panelInformation}
</Text>
</Stack.Item>
<Stack.Item className={classNames.featureListContainer}>
<Stack.Item
id="flyoutMetadata"
className={classNames.featureListContainer}
>
<List
items={this.state.metadata}
onRenderCell={this.onRenderCell}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class FlyoutObjectDetection extends React.Component<
}
/>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item>
<FluentUI.Stack.Item id="flyoutPredictionTitle">
{predictedY !== trueY ? (
<FluentUI.Text
variant="large"
Expand Down Expand Up @@ -158,13 +158,13 @@ export class FlyoutObjectDetection extends React.Component<
{item?.index}
</FluentUI.Text>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item>
<FluentUI.Stack.Item id="flyoutPredLabel">
<FluentUI.Text variant="large">
{localization.InterpretVision.Dashboard.predictedY}
{predictedY}
</FluentUI.Text>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item>
<FluentUI.Stack.Item id="flyoutGtLabel">
<FluentUI.Text variant="large">
{localization.InterpretVision.Dashboard.trueY}
{trueY}
Expand Down Expand Up @@ -194,6 +194,7 @@ export class FlyoutObjectDetection extends React.Component<
</FluentUI.Text>
</FluentUI.Stack.Item>
<FluentUI.Stack.Item
id="flyoutMetadata"
className={classNames.featureListContainer}
>
<FluentUI.List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"metadata": {},
"outputs": [],
"source": [
"rai_insights = RAIVisionInsights(model, test_data.sample(10, random_state=42),\n",
"rai_insights = RAIVisionInsights(model, test_data.sample(3, random_state=42),\n",
" \"label\",\n",
" task_type=ModelTask.IMAGE_CLASSIFICATION,\n",
" classes=class_names)\n",
Expand Down Expand Up @@ -263,7 +263,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.8.17"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
"metadata": {},
"outputs": [],
"source": [
"rai_insights = RAIVisionInsights(model, test_data.sample(10, random_state=42),\n",
"rai_insights = RAIVisionInsights(model, test_data.sample(2, random_state=42),\n",
" target_columns,\n",
" ModelTask.MULTILABEL_IMAGE_CLASSIFICATION)\n",
"\n",
Expand Down Expand Up @@ -397,7 +397,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.8.17"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,13 @@
"metadata": {},
"outputs": [],
"source": [
"rai_insights = RAIVisionInsights(model, test_data.sample(5, random_state=42),\n",
"rai_insights = RAIVisionInsights(model, test_data.head(2),\n",
" \"label\",\n",
" task_type=ModelTask.OBJECT_DETECTION,\n",
" classes=class_names)\n",
" classes=class_names,\n",
" max_evals=1,\n",
" num_masks=1,\n",
" mask_res=1)\n",
"\n",
"rai_insights"
]
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"dependencies": {
"@fluentui/react": "8.58.0",
"canvas": "^2.11.2",
"chai": "^4.3.5",
"core-js": "^3.6.5",
"d3-array": "^2.8.0",
"d3-color": "^2.0.0",
Expand Down Expand Up @@ -118,6 +119,7 @@
"commander": "^7.1.0",
"cross-env": "7.0.2",
"cypress": "^4.12.1",
"cypress-wait-until": "^2.0.1",
"dotenv": "8.2.0",
"enzyme": "3.11.0",
"enzyme-to-json": "3.5.0",
Expand Down
Loading
Loading