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: revert 63145e4 to fix stuck assessment > automated checks scanning #2698

Merged
merged 1 commit into from
May 15, 2020
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
1 change: 1 addition & 0 deletions src/DetailsView/components/assessment-test-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const AssessmentTestView = NamedFC<AssessmentTestViewProps>(
currentTarget={currentTarget}
prevTarget={prevTarget}
assessmentTestResult={assessmentTestResult}
selectedRequirementIsEnabled={selectedRequirementIsEnabled}
/>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/DetailsView/components/assessment-view-update-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface AssessmentViewUpdateHandlerProps {
deps: AssessmentViewUpdateHandlerDeps;
assessmentNavState: AssessmentNavState;
assessmentData: AssessmentData;
isRequirementEnabled: boolean;
selectedRequirementIsEnabled: boolean;
currentTarget: Tab;
prevTarget: PersistedTabInfo;
}
Expand Down Expand Up @@ -65,12 +65,12 @@ export class AssessmentViewUpdateHandler {
return;
}

const isRequirementNotScanned = !props.assessmentData.testStepStatus[step].isStepScanned;
if (props.isRequirementEnabled === false || isRequirementNotScanned) {
const isStepNotScanned = !props.assessmentData.testStepStatus[step].isStepScanned;
if (props.selectedRequirementIsEnabled === false || isStepNotScanned) {
props.deps.detailsViewActionMessageCreator.enableVisualHelper(
test,
step,
isRequirementNotScanned,
isStepNotScanned,
sendTelemetry,
);
}
Expand Down
13 changes: 10 additions & 3 deletions src/DetailsView/components/assessment-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,23 @@ export class AssessmentView extends React.Component<AssessmentViewProps> {
);
}

public componentDidMount(): void {
this.deps.assessmentViewUpdateHandler.onMount(this.props);
}

public componentDidUpdate(prevProps: AssessmentViewProps): void {
this.deps.assessmentViewUpdateHandler.update(prevProps, this.props);

const { assessmentTestResult } = this.props;
this.deps.detailsViewExtensionPoint
.apply(assessmentTestResult.definition.extensions)
.onAssessmentViewUpdate(prevProps, this.props);
}

public componentWillUnmount(): void {
this.deps.assessmentViewUpdateHandler.onUnmount(this.props);
}

private renderTargetChangeDialog(): JSX.Element {
return (
<TargetChangeDialog
Expand Down Expand Up @@ -174,9 +184,6 @@ export class AssessmentView extends React.Component<AssessmentViewProps> {
}
featureFlagStoreData={this.props.featureFlagStoreData}
pathSnippetStoreData={this.props.pathSnippetStoreData}
assessmentData={this.props.assessmentData}
currentTarget={this.props.currentTarget}
prevTarget={this.props.prevTarget}
/>
</div>
</div>
Expand Down
15 changes: 14 additions & 1 deletion src/DetailsView/components/reflow-assessment-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from 'react';
import {
AssessmentViewUpdateHandler,
AssessmentViewUpdateHandlerDeps,
AssessmentViewUpdateHandlerProps,
} from 'DetailsView/components/assessment-view-update-handler';
import { AssessmentTestResult } from '../../common/assessment/assessment-test-result';
import { Tab } from '../../common/itab';
Expand All @@ -28,7 +29,7 @@ export type ReflowAssessmentViewProps = {
currentTarget: Tab;
prevTarget: PersistedTabInfo;
assessmentTestResult: AssessmentTestResult;
};
} & AssessmentViewUpdateHandlerProps;

export class ReflowAssessmentView extends React.Component<ReflowAssessmentViewProps> {
public render(): JSX.Element {
Expand All @@ -46,6 +47,18 @@ export class ReflowAssessmentView extends React.Component<ReflowAssessmentViewPr
return null;
}

public componentDidMount(): void {
this.props.deps.assessmentViewUpdateHandler.onMount(this.props);
}

public componentDidUpdate(prevProps: ReflowAssessmentViewProps): void {
this.props.deps.assessmentViewUpdateHandler.update(prevProps, this.props);
}

public componentWillUnmount(): void {
this.props.deps.assessmentViewUpdateHandler.onUnmount(this.props);
}

private renderTargetChangeDialog(): JSX.Element {
return (
<TargetChangeDialog
Expand Down
47 changes: 3 additions & 44 deletions src/DetailsView/components/test-step-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import { Requirement, VisualHelperToggleConfig } from 'assessments/types/require
import { CollapsibleComponent } from 'common/components/collapsible-component';
import { GuidanceTags, GuidanceTagsDeps } from 'common/components/guidance-tags';
import {
AssessmentData,
AssessmentNavState,
GeneratedAssessmentInstance,
ManualTestStepResult,
PersistedTabInfo,
} from 'common/types/store-data/assessment-result-data';
import { FeatureFlagStoreData } from 'common/types/store-data/feature-flag-store-data';
import { PathSnippetStoreData } from 'common/types/store-data/path-snippet-store-data';
Expand All @@ -19,12 +17,6 @@ import * as React from 'react';
import { DictionaryStringTo } from 'types/common-types';
import { ContentPanelButton, ContentPanelButtonDeps } from 'views/content/content-panel-button';

import { Tab } from 'common/itab';
import {
AssessmentViewUpdateHandler,
AssessmentViewUpdateHandlerDeps,
AssessmentViewUpdateHandlerProps,
} from 'DetailsView/components/assessment-view-update-handler';
import { DetailsViewActionMessageCreator } from '../actions/details-view-action-message-creator';
import { AssessmentInstanceTableHandler } from '../handlers/assessment-instance-table-handler';
import { AssessmentInstanceTable } from './assessment-instance-table';
Expand All @@ -33,12 +25,10 @@ import * as styles from './test-step-view.scss';

export type TestStepViewDeps = {
detailsViewActionMessageCreator: DetailsViewActionMessageCreator;
assessmentViewUpdateHandler: AssessmentViewUpdateHandler;
} & ContentPanelButtonDeps &
GuidanceTagsDeps &
AssessmentViewUpdateHandlerDeps;
GuidanceTagsDeps;

export type TestStepViewProps = {
export interface TestStepViewProps {
deps: TestStepViewDeps;
isStepEnabled: boolean;
isStepScanned: boolean;
Expand All @@ -53,10 +43,7 @@ export type TestStepViewProps = {
assessmentDefaultMessageGenerator: AssessmentDefaultMessageGenerator;
featureFlagStoreData: FeatureFlagStoreData;
pathSnippetStoreData: PathSnippetStoreData;
assessmentData: AssessmentData;
currentTarget: Tab;
prevTarget: PersistedTabInfo;
};
}

export class TestStepView extends React.Component<TestStepViewProps> {
public render(): JSX.Element {
Expand Down Expand Up @@ -90,34 +77,6 @@ export class TestStepView extends React.Component<TestStepViewProps> {
);
}

public componentDidMount(): void {
this.props.deps.assessmentViewUpdateHandler.onMount(this.getUpdateHandlerProps(this.props));
}

public componentDidUpdate(prevProps: TestStepViewProps): void {
this.props.deps.assessmentViewUpdateHandler.update(
this.getUpdateHandlerProps(prevProps),
this.getUpdateHandlerProps(this.props),
);
}

public componentWillUnmount(): void {
this.props.deps.assessmentViewUpdateHandler.onUnmount(
this.getUpdateHandlerProps(this.props),
);
}

private getUpdateHandlerProps(props: TestStepViewProps): AssessmentViewUpdateHandlerProps {
return {
deps: props.deps,
isRequirementEnabled: props.isStepEnabled,
assessmentNavState: props.assessmentNavState,
assessmentData: props.assessmentData,
prevTarget: props.prevTarget,
currentTarget: props.currentTarget,
};
}

private renderTable(): JSX.Element {
if (this.props.testStep.isManual) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ exports[`AssessmentTestView assessment view, isScanning is false 1`] = `
"detailsViewActionMessageCreator": Object {},
}
}
selectedRequirementIsEnabled={false}
/>
}
featureFlag="reflowUI"
Expand Down Expand Up @@ -184,6 +185,7 @@ exports[`AssessmentTestView assessment view, isScanning is true 1`] = `
"detailsViewActionMessageCreator": Object {},
}
}
selectedRequirementIsEnabled={false}
/>
}
featureFlag="reflowUI"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports[`AssessmentViewTest render 1`] = `
<TestStepsNav deps={{...}} ariaLabel=\\"Requirements\\" selectedTest={-1} selectedTestStep=\\"assessment-1-step-1\\" stepStatus={{...}} />
</div>
<div className=\\"testStepViewContainer\\">
<TestStepView deps={{...}} isScanning={false} testStep={{...}} renderStaticContent={[undefined]} instancesMap={{...}} assessmentNavState={{...}} assessmentInstanceTableHandler={{...}} manualTestStepResultMap={{...}} assessmentsProvider={{...}} isStepEnabled={false} isStepScanned={false} assessmentDefaultMessageGenerator={{...}} featureFlagStoreData={{...}} pathSnippetStoreData={{...}} assessmentData={{...}} currentTarget={{...}} prevTarget={{...}} />
<TestStepView deps={{...}} isScanning={false} testStep={{...}} renderStaticContent={[undefined]} instancesMap={{...}} assessmentNavState={{...}} assessmentInstanceTableHandler={{...}} manualTestStepResultMap={{...}} assessmentsProvider={{...}} isStepEnabled={false} isStepScanned={false} assessmentDefaultMessageGenerator={{...}} featureFlagStoreData={{...}} pathSnippetStoreData={{...}} />
</div>
</div>
</AssessmentViewMainContentExtensionPoint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
exports[`AssessmentViewTest render for gettting started 1`] = `
<div>
<TargetChangeDialog
deps={Object {}}
deps={
Object {
"assessmentViewUpdateHandler": proxy {
"___id": "BCDF5CE5-F0DF-40B7-8BA0-69DF395033C8",
},
}
}
newTab={
Object {
"id": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ exports[`TestStepViewTest render snapshot matches with manual false and scanning
<div className=\\"test-step-title-container\\">
<h3 className=\\"test-step-view-title\\">
Test Step Test Name
<GuidanceTags deps={{...}} links={{...}} />
<GuidanceTags deps={[undefined]} links={{...}} />
</h3>
<ContentPanelButton deps={{...}} reference={[undefined]} iconName=\\"info\\" contentTitle=\\"Test Step Test Name\\">
<ContentPanelButton deps={[undefined]} reference={[undefined]} iconName=\\"info\\" contentTitle=\\"Test Step Test Name\\">
Info &amp; examples
</ContentPanelButton>
</div>
Expand All @@ -25,9 +25,9 @@ exports[`TestStepViewTest render, variable part for assisted test 1`] = `
<div className=\\"test-step-title-container\\">
<h3 className=\\"test-step-view-title\\">
Test Step Test Name
<GuidanceTags deps={{...}} links={{...}} />
<GuidanceTags deps={[undefined]} links={{...}} />
</h3>
<ContentPanelButton deps={{...}} reference={[undefined]} iconName=\\"info\\" contentTitle=\\"Test Step Test Name\\">
<ContentPanelButton deps={[undefined]} reference={[undefined]} iconName=\\"info\\" contentTitle=\\"Test Step Test Name\\">
Info &amp; examples
</ContentPanelButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ describe('AssessmentViewTest', () => {
const firstAssessment = assessmentsProvider.all()[0];
const stepName = firstAssessment.requirements[0].key;
let detailsViewActionMessageCreatorMock: IMock<DetailsViewActionMessageCreator>;
let isRequirementEnabled: boolean;
let selectedRequirementIsEnabled: boolean;

let testObject: AssessmentViewUpdateHandler;

beforeEach(() => {
isRequirementEnabled = false;
selectedRequirementIsEnabled = false;
detailsViewActionMessageCreatorMock = Mock.ofType<DetailsViewActionMessageCreator>();
testObject = new AssessmentViewUpdateHandler();
});
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('AssessmentViewTest', () => {
a.enableVisualHelper(firstAssessment.visualizationType, stepName, false),
)
.verifiable(Times.never());
isRequirementEnabled = true;
selectedRequirementIsEnabled = true;
const props = buildProps({ selector: {} });

testObject.onMount(props);
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('AssessmentViewTest', () => {
deps,
prevTarget,
currentTarget: isTargetChanged ? anotherTarget : prevTarget,
isRequirementEnabled: isRequirementEnabled,
selectedRequirementIsEnabled: selectedRequirementIsEnabled,
assessmentNavState,
assessmentData,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@ describe('AssessmentViewTest', () => {
expect(rendered.debug()).toMatchSnapshot();
});

test('componentDidMount', () => {
const props = builder.buildProps();
builder.updateHandlerMock.setup(u => u.onMount(props)).verifiable(Times.once());

const testObject = new AssessmentView(props);

testObject.componentDidMount();
builder.verifyAll();
});

test('componentDidUpdate', () => {
const prevProps = buildPrevProps();
const props = builder.buildProps();
const onAssessmentViewUpdateMock = Mock.ofInstance(
(previousProps: AssessmentViewProps, currentProps: AssessmentViewProps) => {},
);

builder.updateHandlerMock.setup(u => u.update(prevProps, props)).verifiable(Times.once());
builder.detailsViewExtensionPointMock
.setup(d => d.apply(props.assessmentTestResult.definition.extensions))
.returns(() => {
Expand All @@ -60,6 +71,16 @@ describe('AssessmentViewTest', () => {
onAssessmentViewUpdateMock.verifyAll();
});

test('componentWillUnmount', () => {
const props = builder.buildProps();
builder.updateHandlerMock.setup(u => u.onUnmount(props)).verifiable(Times.once());

const testObject = new AssessmentView(props);

testObject.componentWillUnmount();
builder.verifyAll();
});

function buildPrevProps(): AssessmentViewProps {
const prevStep = 'prevStep';
const prevTest = -100 as VisualizationType;
Expand Down
Loading