Skip to content

Commit d32b67e

Browse files
committed
Reuse MFA actor done event helper
1 parent e0c7247 commit d32b67e

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

tests/utils/mfa/flowActors.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type createActors from '@components/MultifactorAuthentication/machine/mfaActors';
22
import mfaMachine from '@components/MultifactorAuthentication/machine/mfaMachine';
3-
import type {MfaContext, MfaEvent} from '@components/MultifactorAuthentication/machine/types';
3+
import type {MfaContext} from '@components/MultifactorAuthentication/machine/types';
44

55
import type {OutputFrom, StateValue} from 'xstate';
66

77
import {createActor} from 'xstate';
88

99
import createInitEvent from './flowFixtures';
10-
import {CHECK_LOCAL_CREDENTIALS_DONE_EVENT_TYPE, VALIDATE_DEVICE_DONE_EVENT_TYPE} from './flowPaths';
10+
import {CHECK_LOCAL_CREDENTIALS_DONE_EVENT_TYPE, createActorDoneEvent, VALIDATE_DEVICE_DONE_EVENT_TYPE} from './flowPaths';
1111

1212
type ValidateDeviceOutput = OutputFrom<ReturnType<typeof createActors>['validateDevice']>;
1313
type CheckLocalCredentialsOutput = OutputFrom<ReturnType<typeof createActors>['checkLocalCredentials']>;
@@ -46,18 +46,14 @@ function createActorAtState(value: StateValue, contextOverrides?: Partial<MfaCon
4646
* Completes the invoked device-check actor by sending its done event carrying the given output.
4747
*/
4848
function sendValidateDeviceDone(actor: ReturnType<typeof createActorAtState>, output: ValidateDeviceOutput) {
49-
// Framework actor events are not part of the application's MfaEvent union.
50-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
51-
actor.send({type: VALIDATE_DEVICE_DONE_EVENT_TYPE, output} as unknown as MfaEvent);
49+
actor.send(createActorDoneEvent(VALIDATE_DEVICE_DONE_EVENT_TYPE, output));
5250
}
5351

5452
/**
5553
* Completes the invoked credentials-check actor by sending its done event carrying the given output.
5654
*/
5755
function sendCheckLocalCredentialsDone(actor: ReturnType<typeof createActorAtState>, output: CheckLocalCredentialsOutput) {
58-
// Framework actor events are not part of the application's MfaEvent union.
59-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
60-
actor.send({type: CHECK_LOCAL_CREDENTIALS_DONE_EVENT_TYPE, output} as unknown as MfaEvent);
56+
actor.send(createActorDoneEvent(CHECK_LOCAL_CREDENTIALS_DONE_EVENT_TYPE, output));
6157
}
6258

6359
export {createActorAtState, createFlowContext, sendCheckLocalCredentialsDone, sendValidateDeviceDone};

tests/utils/mfa/flowPaths.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export default getWalkedPaths;
254254
export {
255255
CHECK_LOCAL_CREDENTIALS_DONE_EVENT_TYPE,
256256
CHECK_LOCAL_CREDENTIALS_ERROR_EVENT_TYPE,
257+
createActorDoneEvent,
257258
getDrivingJourneyPaths,
258259
getMfaShortestPaths,
259260
isAutoDrivenEvent,

0 commit comments

Comments
 (0)