Skip to content

Commit

Permalink
chore: Typescript Cleanup- Part 2 for Test Files (#7269)
Browse files Browse the repository at this point in the history
#### Details

As part of Typescript migration added/removed the error causing fields.
As most of the files are test cases which were removed from actual file
but not updated the test case files.

##### Motivation
TypeScript 5.0 has marked some options as deprecated. We can temporarily
override these deprecations, but the documented plan is for the ability
to override the flag to go away in TypeScript 5.5

##### Context

**1. displayName:   'JSON'**

- **Error:** Type '{ key: "json"; displayName: string; generateMenuItem:
(onMenuItemClick: (event: MouseEvent<HTMLButtonElement |
HTMLAnchorElement, MouseEvent>, selectedServiceKey:
ReportExportServiceKey) => void, href: string, download: string) => {
...; }; }' is not assignable to type 'ReportExportService'.
- Object literal may only specify known properties, and 'displayName'
does not exist in type 'ReportExportService'.

**2. columnConfiguration: []**

- **Error :** Type '{ instancesMap:
DictionaryStringTo<GeneratedAssessmentInstance<{}, {}>>;
columnConfiguration: undefined[]; assessmentNavState: { ...; }; ... 4
more ...; hasVisualHelper: true; }' is not assignable to type
'AssessmentInstanceTableProps'
- Object literal may only specify known properties, and
'columnConfiguration' does not exist in type
'AssessmentInstanceTableProps'.

**3. noClick**

-  **Error:** Property 'noClick' does not exist on type

**4. newTab: newTab**	

- **Error:** Type '{ deps: { urlParser: UrlParser;
getAssessmentActionMessageCreator: () => AssessmentActionMessageCreator;
detailsViewId: undefined; }; prevTab: PersistedTabInfo; ... 4 more ...;
isOpen: true; }' is not assignable to type 'LoadAssessmentDialogProps'.
- Object literal may only specify known properties, and 'newTab' does
not exist in type 'LoadAssessmentDialogProps'.

**5. showAssessment: true**

- **Error:** Type '{ showAssessment: true; showTest: true; }' is not
assignable to type 'StartOverContextMenuKeyOptions'.
Object literal may only specify known properties, and 'showAssessment'
does not exist in type 'StartOverContextMenuKeyOptions'.
- In actual file they removed the StartOverContextMenuKeyOptions
'showAssessment: true,' and didn't removed from test file

**6. status: 'fail'**

- **Error:** Type '{ deps: { tabStopRequirementActionMessageCreator:
TabStopRequirementActionMessageCreator; tabStopsTestViewController:
TabStopsTestViewController; }; requirementState:
TabStopRequirementState; status: string; }' is not assignable to type
'TabStopsRequirementsTableProps'.
- Object literal may only specify known properties, and 'status' does
not exist in type 'TabStopsRequirementsTableProps'

**7. highlightState: 'hidden**

- **Error:** Type '{ deps: InstanceDetailsFooterDeps; result:
CardResult; rule: UnifiedRule; targetAppInfo: TargetAppData;
highlightState: string; userConfigurationStoreData:
UserConfigurationStoreData; }' is not assignable to type
'InstanceDetailsFooterProps'.
- Object literal may only specify known properties, and 'highlightState'
does not exist in type 'InstanceDetailsFooterProps'.
- highlightState was removed from actual file and didn't update the test
case.

**8.  fixInstructionProcessor**

- **Error:** Type '{ deps: InstanceDetailsGroupDeps;
fixInstructionProcessor: FixInstructionProcessor; recommendColor:
RecommendColor; rule: CardRuleResult; userConfigurationStoreData: null;
targetAppInfo: { ...; }; cardSelectionMessageCreator:
CardSelectionMessageCreator; }' is not assignable to type
'InstanceDetailsGroupProps'.
- Object literal may only specify known properties, and
'fixInstructionProcessor' does not exist in type
'InstanceDetailsGroupProps'.

**9. showCongratsIfNotInstances:   true**

- **Error:** Type '{ deps: ResultSectionContentDeps; results:
CardRuleResult[]; outcomeType: "pass"; showCongratsIfNotInstances:
boolean; userConfigurationStoreData: null; ... 5 more ...;
cardSelectionMessageCreator: CardSelectionMessageCreator; }' is not
assignable to type 'ResultSectionContentProps'.
- Object literal may only specify known properties, and
'showCongratsIfNotInstances' does not exist in type
'ResultSectionContentProps'.

**10. iconName="test icon"** 

- **Error :** Type '{ deps: { contentProvider: ContentProvider;
contentActionMessageCreator: ContentActionMessageCreator; }; guidance:
string; headingTitle: string; iconName: string; }' is not assignable to
type 'IntrinsicAttributes & HeaderWithContentLinkProps & { children?:
ReactNode; }'
- Property 'iconName' does not exist on type 'IntrinsicAttributes &
HeaderWithContentLinkProps

**11. selectedTest:   VisualizationType[-1]**

- Here for this error the props imported was wrong instead of
AssessmentRequirementScanTelemetryData they used
RuleAnalyzerScanTelemetryData due to this getting error.

**12.  requirementName**

- **Error:** Type '{ scanDuration: number; NumberOfElementsScanned:
number; include: undefined[]; exclude: undefined[]; testName: string;
requirementName: string; }' is not assignable to type
'RuleAnalyzerScanTelemetryData'.
Object literal may only specify known properties, and 'requirementName'
does not exist in type 'RuleAnalyzerScanTelemetryData'.

**13. status: ManualTestStatus.FAIL,**

- **Error:** Type '{ step: string; test:
VisualizationType.HeadingsAssessment; status: ManualTestStatus;
assessmentInstanceTableHandler: AssessmentInstanceTableHandler;
manualTestStepResultMap: { ...; }; assessmentsProvider:
AssessmentsProvider; featureFlagStoreData: FeatureFlagStoreData;
pathSnippetStoreData: { ...; }; }' is not assignable to type
'ManualTestStepViewProps'.
- Object literal may only specify known properties, and 'status' does
not exist in type 'ManualTestStepViewProps'.

**14. featureFlagStoreData: {},**

- **Error:** Type '{ container: DetailsDialog; dialogHandler:
IssueDetailsNavigationClickHandler; featureFlagStoreData: {};
failuresCount: number; }' is not assignable to type
'IssueDetailsNavigationControlsProps'.
- Object literal may only specify known properties, and
'featureFlagStoreData' does not exist in type
'IssueDetailsNavigationControlsProps'.

**15.  userConfigurationStoreData**

- **Error:** Type '{ deps: IssueFilingSettingsContainerDeps;
selectedIssueFilingService: IssueFilingService;
userConfigurationStoreData: UserConfigurationStoreData;
selectedIssueFilingServiceData: IssueFilingServiceProperties;
onPropertyUpdateCallback: () => any; onSelectedServiceChange: () => any;
}' is not assignable to type 'IssueFilingSettingsContainerProps'.
- Object literal may only specify known properties, and
'userConfigurationStoreData' does not exist in type
'IssueFilingSettingsContainerProps'.

**16. featureFlagStoreData: {},**

- **Error:** Type '{ backLinkHandler: () => void;
diagnosticViewToggleFactory: DiagnosticViewToggleFactory;
featureFlagStoreData: {}; }' is not assignable to type
'AdHocToolsPanelProps'.
- Object literal may only specify known properties, and
'featureFlagStoreData' does not exist in type 'AdHocToolsPanelProps'.

**17. shortcutModifyHandler**

- **Error:** Argument of type '{ diagnosticViewClickHandler: null;
popupViewControllerHandler: PopupViewControllerHandler;
launchPanelHeaderClickHandler: null; shortcutModifyHandler: null; }' is
not assignable to parameter of type 'PopupHandlers'.
- Object literal may only specify known properties, and
'shortcutModifyHandler' does not exist in type 'PopupHandlers'.

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [x] Addresses an existing issue:
#(#6611)
- [ ] Ran `yarn fastpass`
- [x] Added/updated relevant unit test(s) (and ran `yarn test`)
- [x] Verified code coverage for the changes made. Check coverage report
at: `<rootDir>/test-results/unit/coverage`
- [ ] PR title *AND* final merge commit title both start with a semantic
tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See
`CONTRIBUTING.md`.
- [ ] (UI changes only) Added screenshots/GIFs to description above
- [ ] (UI changes only) Verified usability with NVDA/JAWS
  • Loading branch information
JeevaniChinthala authored Apr 1, 2024
1 parent 989a6f9 commit 4cde9af
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 46 deletions.
1 change: 0 additions & 1 deletion src/report-export/services/json-report-export-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const reportExportAsJsonAutomationId = 'report-export-as-json';

export const JsonReportExportService: ReportExportService = {
key: jsonReportExportServiceKey,
displayName: 'JSON',
generateMenuItem: (onMenuItemClick, href, download) => {
return {
key: jsonReportExportServiceKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ describe('AssessmentInstanceTable', () => {
): AssessmentInstanceTableProps {
return {
instancesMap: instancesMap,
columnConfiguration: [],
assessmentNavState: {
selectedTestSubview: selectedTestStep,
selectedTestType: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('ChoiceGroupPassFail', () => {
selectedKey: TabStopRequirementStatuses.unknown,
onChange: () => {},
secondaryControls: (
<IconButton iconProps={{ iconName: 'add' }} aria-label="add" noClick={() => {}} />
<IconButton iconProps={{ iconName: 'add' }} aria-label="add" onClick={() => {}} />
),
onUndoClickedPassThrough: onUndoClickedMock.object,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { Dialog } from '@fluentui/react';
import { render } from '@testing-library/react';
import { PersistedTabInfo } from 'common/types/store-data/assessment-result-data';
import { Tab } from 'common/types/store-data/itab';
import { VersionedAssessmentData } from 'common/types/versioned-assessment-data';
import { UrlParser } from 'common/url-parser';
import { AssessmentActionMessageCreator } from 'DetailsView/actions/assessment-action-message-creator';
Expand All @@ -28,7 +27,6 @@ describe('LoadAssessmentDialog', () => {
let assessmentActionMessageCreatorMock: IMock<AssessmentActionMessageCreator>;
let loadAssessmentDialogProps: LoadAssessmentDialogProps;
let prevTab: PersistedTabInfo;
let newTab: Tab;

beforeEach(() => {
urlParserMock = Mock.ofType(UrlParser, MockBehavior.Strict);
Expand All @@ -39,20 +37,13 @@ describe('LoadAssessmentDialog', () => {
title: 'test title',
} as PersistedTabInfo;

newTab = {
id: 112,
url: 'https://www.test2.com',
title: 'test title 2',
} as Tab;

loadAssessmentDialogProps = {
deps: {
urlParser: urlParserMock.object,
getAssessmentActionMessageCreator: () => assessmentActionMessageCreatorMock.object,
detailsViewId: undefined,
},
prevTab: prevTab,
newTab: newTab,
tabId: 5,
loadedAssessmentData: {} as VersionedAssessmentData,
onClose: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('StartOverDropdownTest', () => {
defaultProps = {
singleTestSuffix: 'single test suffix stub',
allTestSuffix: 'all test suffix stub',
rightPanelOptions: { showAssessment: true, showTest: true },
switcherStartOverPreferences: { showAssessment: true, showTest: true },
rightPanelOptions: { showTest: true },
switcherStartOverPreferences: { showTest: true },
dropdownDirection: 'down',
openDialog: openDialogMock.object,
buttonRef: {} as IRefObject<IButton>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ describe('TabStopsRequirementsTable', () => {
tabStopsTestViewController: tabStopsTestViewControllerMock.object,
},
requirementState: requirementState,
status: 'fail',
};
requirementContentStub = {
id: 'test id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ describe('InstanceDetailsFooter', () => {
result: resultStub,
rule: ruleStub,
targetAppInfo: targetAppInfo,
highlightState: 'hidden',
userConfigurationStoreData: {} as UserConfigurationStoreData,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import {
InstanceDetailsGroupDeps,
InstanceDetailsGroupProps,
} from 'common/components/cards/instance-details-group';
import { FixInstructionProcessor } from 'common/components/fix-instruction-processor';
import { RecommendColor } from 'common/components/recommend-color';
import { CardSelectionMessageCreator } from 'common/message-creators/card-selection-message-creator';
import { CardRuleResult } from 'common/types/store-data/card-view-model';
import * as React from 'react';
import { Mock } from 'typemoq';

import { InstanceDetails } from '../../../../../../common/components/cards/instance-details';
import {
Expand All @@ -24,15 +21,11 @@ jest.mock('../../../../../../common/components/cards/instance-details');
describe('InstanceDetailsGroup', () => {
mockReactComponents([InstanceDetails]);
it('renders', () => {
const fixInstructionProcessorMock = Mock.ofType(FixInstructionProcessor);
const recommendColorStub = {} as RecommendColor;
const rule: CardRuleResult = exampleUnifiedRuleResult;
const depsStub: InstanceDetailsGroupDeps = {} as InstanceDetailsGroupDeps;

const props: InstanceDetailsGroupProps = {
deps: depsStub,
fixInstructionProcessor: fixInstructionProcessorMock.object,
recommendColor: recommendColorStub,
rule: rule,
userConfigurationStoreData: null,
targetAppInfo: { name: 'app' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ describe('ResultSectionContent', () => {
deps: depsStub,
results: emptyRules,
outcomeType: 'pass',
showCongratsIfNotInstances: true,
userConfigurationStoreData: null,
targetAppInfo: { name: 'app' },
visualHelperEnabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe('HeadingWithContentLink', () => {
deps={deps}
guidance={contentPath}
headingTitle={headingTitle}
iconName="test icon"
/>,
);
expect(renderResult.asFragment()).toMatchSnapshot();
Expand All @@ -64,7 +63,6 @@ describe('HeadingWithContentLink', () => {
guidance={contentPath}
headingTitle={headingTitle}
secondaryText={secondaryText}
iconName="test icon"
/>,
);
expect(renderResult.asFragment()).toMatchSnapshot();
Expand Down
3 changes: 2 additions & 1 deletion src/tests/unit/tests/common/telemetry-data-factory.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {
AssessmentRequirementScanTelemetryData,
AssessmentTelemetryData,
BaseTelemetryData,
DetailsViewOpenedTelemetryData,
Expand Down Expand Up @@ -465,7 +466,7 @@ describe('TelemetryDataFactoryTest', () => {
testVisualizationType,
requirementName,
);
const expected: RuleAnalyzerScanTelemetryData = {
const expected: AssessmentRequirementScanTelemetryData = {
scanDuration: elapsedTime,
NumberOfElementsScanned: elementsScanned,
include: analyzerResultStub.include,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ describe('BatchedRuleAnalyzer', () => {
include: [],
exclude: [],
testName,
requirementName,
};
return telemetryStub;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ describe('RuleAnalyzer', () => {
include: [],
exclude: [],
testName,
requirementName,
};
return telemetryStub;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('IssueDetailsNavigationControls', () => {
controlProps = {
container: Mock.ofType<DetailsDialog>().object,
dialogHandler: navigationHandlerMock.object,
featureFlagStoreData: {},
failuresCount: 5,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import * as React from 'react';
import { Mock } from 'typemoq';

import { UserConfigMessageCreator } from '../../../../../common/message-creators/user-config-message-creator';
import {
IssueFilingServiceProperties,
UserConfigurationStoreData,
} from '../../../../../common/types/store-data/user-configuration-store';
import { IssueFilingServiceProperties } from '../../../../../common/types/store-data/user-configuration-store';
import { IssueFilingChoiceGroup } from '../../../../../issue-filing/components/issue-filing-choice-group';
import {
IssueFilingSettingsContainer,
Expand All @@ -34,9 +31,6 @@ describe('IssueFilingSettingsContainerTest', () => {
settingsForm: AzureBoardsSettingsForm,
} as IssueFilingService;
const issueFilingServices = [selectedIssueFilingService];
const userConfigurationStoreData: UserConfigurationStoreData = {
bugService: 'test',
} as UserConfigurationStoreData;
const selectedIssueFilingServiceData: IssueFilingServiceProperties = {
repository: 'none',
};
Expand All @@ -47,7 +41,6 @@ describe('IssueFilingSettingsContainerTest', () => {
issueFilingServiceProvider: issueFilingServicesProviderMock.object,
} as IssueFilingSettingsContainerDeps,
selectedIssueFilingService,
userConfigurationStoreData,
selectedIssueFilingServiceData,
onPropertyUpdateCallback: () => null,
onSelectedServiceChange: () => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('AdHocToolsPanelTest', () => {
const props: AdHocToolsPanelProps = {
backLinkHandler: null,
diagnosticViewToggleFactory: diagnosticViewToggleFactoryMock.object,
featureFlagStoreData: {},
};

const renderResult = render(<AdHocToolsPanel {...props} />);
Expand All @@ -52,7 +51,6 @@ describe('AdHocToolsPanelTest', () => {
const props: AdHocToolsPanelProps = {
backLinkHandler: null,
diagnosticViewToggleFactory: diagnosticViewToggleFactoryMock.object,
featureFlagStoreData: {},
};

const renderResult = render(<AdHocToolsPanel {...props} />);
Expand All @@ -76,7 +74,6 @@ describe('AdHocToolsPanelTest', () => {
const props: AdHocToolsPanelProps = {
backLinkHandler: null,
diagnosticViewToggleFactory: diagnosticViewToggleFactoryMock.object,
featureFlagStoreData: featureFlagStoreData,
};

const renderResult = render(<AdHocToolsPanel {...props} />);
Expand All @@ -94,7 +91,6 @@ describe('AdHocToolsPanelTest', () => {
const props: AdHocToolsPanelProps = {
backLinkHandler: backLinkHandlerMock.object,
diagnosticViewToggleFactory: diagnosticViewToggleFactoryMock.object,
featureFlagStoreData: {},
};

render(<AdHocToolsPanel {...props} />);
Expand Down
4 changes: 0 additions & 4 deletions src/tests/unit/tests/popup/components/popup-view.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ describe('PopupView', () => {
let storeState: PopupViewControllerState;
let deps: PopupViewControllerDeps;
const rowConfigStub = {};
const shortcutModifyHandlerStub = {};
const launchPadRowConfigurationFactoryMock = Mock.ofType(LaunchPadRowConfigurationFactory);
const userConfigStoreData: UserConfigurationStoreData = {
isFirstTime: true,
Expand Down Expand Up @@ -155,7 +154,6 @@ describe('PopupView', () => {
diagnosticViewClickHandler: clickHandlerMock.object,
popupViewControllerHandler: handlerMock.object,
launchPanelHeaderClickHandler: null,
shortcutModifyHandler: shortcutModifyHandlerStub as any,
})
.with('hasAccess', true)
.with(
Expand Down Expand Up @@ -196,7 +194,6 @@ describe('PopupView', () => {
diagnosticViewClickHandler: clickHandlerMock.object,
popupViewControllerHandler: handlerMock.object,
launchPanelHeaderClickHandler: null,
shortcutModifyHandler: shortcutModifyHandlerStub as any,
})
.with('hasAccess', true)
.with(
Expand Down Expand Up @@ -232,7 +229,6 @@ describe('PopupView', () => {
diagnosticViewClickHandler: null,
popupViewControllerHandler: handlerMock.object,
launchPanelHeaderClickHandler: null,
shortcutModifyHandler: null,
})
.with('hasAccess', true)
.with('diagnosticViewToggleFactory', null)
Expand Down

0 comments on commit 4cde9af

Please sign in to comment.