Skip to content

Commit

Permalink
feat(medium-pass-1): register MediumPass callbacks in ActionCreator (#…
Browse files Browse the repository at this point in the history
…6227)

#### Details

<!-- Usually a sentence or two describing what the PR changes -->
This PR ensures that the MediumPass/QuickAssess equivalents of
Assessment callbacks are registered in ActionCreator

##### Motivation

<!-- This can be as simple as "addresses issue #123" -->
Part of feature work

##### Context

<!-- Are there any parts that you've intentionally left out-of-scope for
a later PR to handle? -->

<!-- Were there any alternative approaches you considered? What
tradeoffs did you consider? -->

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [n/a] Addresses an existing issue: #0000
- [x] Ran `yarn null:autoadd`
- [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
lisli1 authored Dec 2, 2022
1 parent c569706 commit dbc3811
Show file tree
Hide file tree
Showing 2 changed files with 304 additions and 166 deletions.
102 changes: 94 additions & 8 deletions src/background/actions/action-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ActionCreator {
);
this.interpreter.registerTypeToPayloadCallback(
Messages.Assessment.AssessmentScanCompleted,
this.onAssessmentScanCompleted,
this.onAssessmentScanCompletedForAssessment,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.Assessment.StartOverTest,
Expand All @@ -147,11 +147,11 @@ export class ActionCreator {
);
this.interpreter.registerTypeToPayloadCallback(
Messages.Assessment.StartOverAllAssessments,
this.onStartOverAllAssessments,
this.onStartOverAllAssessmentsForAssessment,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.Assessment.CancelStartOverAllAssessments,
this.onCancelStartOverAllAssessments,
this.onCancelStartOverAllAssessmentsForAssessment,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.Assessment.EnableVisualHelper,
Expand All @@ -170,6 +170,43 @@ export class ActionCreator {
this.onEnableVisualHelperWithoutScan,
);

this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.AssessmentScanCompleted,
this.onAssessmentScanCompletedForQuickAssess,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.StartOverTest,
this.onStartOver,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.CancelStartOver,
this.onCancelStartOver,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.StartOverAllAssessments,
this.onStartOverAllAssessmentsForQuickAssess,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.CancelStartOverAllAssessments,
this.onCancelStartOverAllAssessmentsForQuickAssess,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.EnableVisualHelper,
this.onEnableVisualHelper,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.DisableVisualHelperForTest,
this.onDisableVisualHelpersForTest,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.DisableVisualHelper,
this.onDisableVisualHelper,
);
this.interpreter.registerTypeToPayloadCallback(
Messages.MediumPass.EnableVisualHelperWithoutScan,
this.onEnableVisualHelperWithoutScan,
);

this.interpreter.registerTypeToPayloadCallback(
Messages.Inspect.SetHoveredOverSelector,
this.onSetHoveredOverSelector,
Expand Down Expand Up @@ -219,20 +256,47 @@ export class ActionCreator {
this.telemetryEventHandler.publishTelemetry(eventName, payload);
};

private onStartOverAllAssessments = async (payload: ToggleActionPayload): Promise<void> => {
const eventName = TelemetryEvents.START_OVER_ASSESSMENT;
private onStartOverAllAssessments = async (
payload: ToggleActionPayload,
eventName: string,
): Promise<void> => {
this.telemetryEventHandler.publishTelemetry(eventName, payload);
await this.visualizationActions.disableAssessmentVisualizations.invoke(
null,
this.executingScope,
);
};

private onCancelStartOverAllAssessments = (payload: BaseActionPayload): void => {
const eventName = TelemetryEvents.CANCEL_START_OVER_ASSESSMENT;
private onStartOverAllAssessmentsForAssessment = async (
payload: ToggleActionPayload,
): Promise<void> => {
await this.onStartOverAllAssessments(payload, TelemetryEvents.START_OVER_ASSESSMENT);
};

private onStartOverAllAssessmentsForQuickAssess = async (
payload: ToggleActionPayload,
): Promise<void> => {
await this.onStartOverAllAssessments(payload, TelemetryEvents.START_OVER_MEDIUM_PASS);
};

private onCancelStartOverAllAssessments = (
payload: BaseActionPayload,
eventName: string,
): void => {
this.telemetryEventHandler.publishTelemetry(eventName, payload);
};

private onCancelStartOverAllAssessmentsForAssessment = (payload: BaseActionPayload): void => {
this.onCancelStartOverAllAssessments(payload, TelemetryEvents.CANCEL_START_OVER_ASSESSMENT);
};

private onCancelStartOverAllAssessmentsForQuickAssess = (payload: BaseActionPayload): void => {
this.onCancelStartOverAllAssessments(
payload,
TelemetryEvents.CANCEL_START_OVER_MEDIUM_PASS,
);
};

private onDetailsViewClosed = async (): Promise<void> => {
await this.visualizationActions.disableAssessmentVisualizations.invoke(
null,
Expand All @@ -243,8 +307,8 @@ export class ActionCreator {
private onAssessmentScanCompleted = async (
payload: ScanCompletedPayload<any>,
tabId: number,
eventName: string,
): Promise<void> => {
const eventName = TelemetryEvents.ASSESSMENT_SCAN_COMPLETED;
this.telemetryEventHandler.publishTelemetry(eventName, payload);
await this.visualizationActions.scanCompleted.invoke(null, this.executingScope);
this.notificationCreator.createNotificationByVisualizationKey(
Expand All @@ -256,6 +320,28 @@ export class ActionCreator {
await this.targetTabController.showTargetTab(tabId, payload.testType, payload.key);
};

private onAssessmentScanCompletedForAssessment = async (
payload: ScanCompletedPayload<any>,
tabId: number,
): Promise<void> => {
await this.onAssessmentScanCompleted(
payload,
tabId,
TelemetryEvents.ASSESSMENT_SCAN_COMPLETED,
);
};

private onAssessmentScanCompletedForQuickAssess = async (
payload: ScanCompletedPayload<any>,
tabId: number,
): Promise<void> => {
await this.onAssessmentScanCompleted(
payload,
tabId,
TelemetryEvents.MEDIUM_PASS_SCAN_COMPLETED,
);
};

private onTabbedElementAdded = async (payload: AddTabbedElementPayload): Promise<void> => {
await this.visualizationScanResultActions.addTabbedElement.invoke(
payload,
Expand Down
Loading

0 comments on commit dbc3811

Please sign in to comment.