Skip to content

Commit

Permalink
chore: Typescript Cleanup Part 2 of 3 for rule: ruleStub & launchPane…
Browse files Browse the repository at this point in the history
…lType: panelType (#7289)

#### Details

Typescript Cleanup Part 2 of 3 
We have total 140 errors in 104 files. Thus, targeting each error and
fixing it.

##### Motivation

Errors observed in below files observed after removing deprecated
properties from tsconfig file:
1.**rule: ruleStub**  
src/tests/unit/tests/injected/element-based-view-model-creator.test.ts
(9)
scanNodeResults consists of unified results as well as ruleStub. So,
using scanNodeResults to resolve the issue.

2.**launchPanelType: panelType**  
src/popup/actions/popup-action-message-creator.ts(1)

src/tests/unit/tests/popup/actions/popup-action-message-creator.test.ts(1)
Added new type LaunchPanelTelemetryData in
extension-telemetry-events.ts, to resolve the error for launchPanelType:
panelType

Thus, total number of errors covered as part of this user story: **11**


##### Context

#### 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)
- [x] 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`
- [x] PR title *AND* final merge commit title both start with a semantic
tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See
`CONTRIBUTING.md`.
- [n/a] (UI changes only) Added screenshots/GIFs to description above
- [n/a] (UI changes only) Verified usability with NVDA/JAWS
  • Loading branch information
v-prachin authored Apr 8, 2024
1 parent d07237b commit a490e21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 56 deletions.
8 changes: 7 additions & 1 deletion src/common/extension-telemetry-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
import { ScanIncompleteWarningId } from 'common/types/store-data/scan-incomplete-warnings';
import { ReportExportServiceKey } from 'report-export/types/report-export-service';
import { LaunchPanelType } from './types/store-data/launch-panel-store-data';
import { SingleElementSelector } from './types/store-data/scoping-store-data';

export const POPUP_INITIALIZED: string = 'PopupInitialized';
Expand Down Expand Up @@ -288,6 +289,10 @@ export type UnhandledErrorTelemetryData = {
errorType: ErrorType;
};

export type LaunchPanelTelemetryData = {
launchPanelType: LaunchPanelType;
} & BaseTelemetryData;

export type TelemetryData =
| BaseTelemetryData
| ToggleTelemetryData
Expand All @@ -313,4 +318,5 @@ export type TelemetryData =
| TabStopsAutomatedResultsTelemetryData
| AutoDetectedFailuresDialogStateTelemetryData
| ShowAssessmentDialogStateTelemetryData
| UnhandledErrorTelemetryData;
| UnhandledErrorTelemetryData
| LaunchPanelTelemetryData;
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,7 @@ describe('ElementBasedViewModelCreator', () => {

getHighlightedResultInstanceIdsMock
.setup(mock =>
mock(
cardSelectionData,
[
{
...unifiedResult,
rule: ruleStub,
},
],
null,
isResultHighlightUnavailableStub,
),
mock(cardSelectionData, scanNodeResults, null, isResultHighlightUnavailableStub),
)
.returns(() => cardSelectionViewData);

Expand All @@ -105,7 +95,7 @@ describe('ElementBasedViewModelCreator', () => {
const ruleStub = { id: unifiedResult.ruleId } as UnifiedRule;
const identifierStub = unifiedResult.identifiers['css-selector'];
const decoratedResultStub = {} as DecoratedAxeNodeResult;
const scanNodeResults = [{ ...unifiedResult, rule: ruleStub }];
const scanNodeResults: ScanNodeResult[] = [{ ...unifiedResult, rule: ruleStub }];
const cardSelectionViewData = {
resultsHighlightStatus: { [unifiedResult.uid]: 'visible' },
} as CardSelectionViewData;
Expand All @@ -114,20 +104,15 @@ describe('ElementBasedViewModelCreator', () => {
.setup(mock =>
mock(
cardSelectionData,
[
{
...unifiedResult,
rule: ruleStub,
},
],
scanNodeResults,
null,
isResultHighlightUnavailableStub,
),
)
.returns(() => cardSelectionViewData);

getDecoratedAxeNodeCallbackMock
.setup(mock => mock({ ...unifiedResult, rule: ruleStub }, ruleStub, identifierStub))
.setup(mock => mock(scanNodeResults[0], ruleStub, identifierStub))
.returns(() => decoratedResultStub);

const expectedResult = {
Expand All @@ -140,7 +125,6 @@ describe('ElementBasedViewModelCreator', () => {
},
},
};

expect(
testSubject.getElementBasedViewModel(scanNodeResults, cardSelectionData),
).toEqual(expectedResult);
Expand All @@ -164,7 +148,7 @@ describe('ElementBasedViewModelCreator', () => {
id: 'some other id',
} as DecoratedAxeNodeResult;

const scanNodeResults = [
const scanNodeResults: ScanNodeResult[] = [
{ ...unifiedResultOne, rule: ruleStubOne },
{ ...unifiedResultTwo, rule: ruleStubTwo },
];
Expand All @@ -177,34 +161,16 @@ describe('ElementBasedViewModelCreator', () => {

getHighlightedResultInstanceIdsMock
.setup(mock =>
mock(
cardSelectionData,
[
{
...unifiedResultOne,
rule: ruleStubOne,
},
{
...unifiedResultTwo,
rule: ruleStubTwo,
},
],
null,
isResultHighlightUnavailableStub,
),
mock(cardSelectionData, scanNodeResults, null, isResultHighlightUnavailableStub),
)
.returns(() => cardSelectionViewData);

getDecoratedAxeNodeCallbackMock
.setup(mock =>
mock({ ...unifiedResultOne, rule: ruleStubOne }, ruleStubOne, identifierStub),
)
.setup(mock => mock(scanNodeResults[0], ruleStubOne, identifierStub))
.returns(() => decoratedResultStubOne);

getDecoratedAxeNodeCallbackMock
.setup(mock =>
mock({ ...unifiedResultTwo, rule: ruleStubTwo }, ruleStubTwo, identifierStub),
)
.setup(mock => mock(scanNodeResults[1], ruleStubTwo, identifierStub))
.returns(() => decoratedResultStubTwo);

const expectedResult = {
Expand All @@ -231,29 +197,19 @@ describe('ElementBasedViewModelCreator', () => {
const ruleStub = { id: unifiedResult.ruleId } as UnifiedRule;
const identifierStub = unifiedResult.identifiers['css-selector'];
const decoratedResultStub = {} as DecoratedAxeNodeResult;
const scanNodeResults = [{ ...unifiedResult, rule: ruleStub }];
const scanNodeResults: ScanNodeResult[] = [{ ...unifiedResult, rule: ruleStub }];
const cardSelectionViewData = {
resultsHighlightStatus: { [unifiedResult.uid]: 'visible' },
} as CardSelectionViewData;

getHighlightedResultInstanceIdsMock
.setup(mock =>
mock(
cardSelectionData,
[
{
...unifiedResult,
rule: ruleStub,
},
],
null,
isResultHighlightUnavailableStub,
),
mock(cardSelectionData, scanNodeResults, null, isResultHighlightUnavailableStub),
)
.returns(() => cardSelectionViewData);

getDecoratedAxeNodeCallbackMock
.setup(mock => mock({ ...unifiedResult, rule: ruleStub }, ruleStub, identifierStub))
.setup(mock => mock(scanNodeResults[0], ruleStub, identifierStub))
.returns(() => decoratedResultStub);

const expectedResult = {
Expand Down

0 comments on commit a490e21

Please sign in to comment.