11import mfaMachine from '@components/MultifactorAuthentication/machine/mfaMachine' ;
2+ import snapshotToState from '@components/MultifactorAuthentication/machine/snapshotToState' ;
23import type { CheckLocalCredentialsInput , ValidateDeviceInput } from '@components/MultifactorAuthentication/machine/types' ;
34
45import type { MFAResult } from '@libs/MultifactorAuthentication/shared/MFAResult' ;
@@ -123,7 +124,7 @@ describe('MFA magic code and registration decision', () => {
123124
124125 const result = actor . getSnapshot ( ) ;
125126 expect ( result . matches ( { [ MFA_STATE . OPEN ] : { [ MFA_STATE . MAGIC_CODE ] : { [ MFA_STATE . AWAITING_VALIDATE_CODE ] : MFA_STATE . AWAITING_INPUT } } } ) ) . toBe ( true ) ;
126- expect ( result . hasTag ( ' showsInvalidCodeError' ) ) . toBe ( false ) ;
127+ expect ( snapshotToState ( result ) . showsInvalidCodeError ) . toBe ( false ) ;
127128 expect ( requestValidateCodeActionMock ) . toHaveBeenCalledTimes ( 1 ) ;
128129
129130 actor . stop ( ) ;
@@ -183,7 +184,7 @@ describe('MFA magic code and registration decision', () => {
183184
184185 const result = actor . getSnapshot ( ) ;
185186 expect ( result . matches ( { [ MFA_STATE . OPEN ] : { [ MFA_STATE . MAGIC_CODE ] : { [ MFA_STATE . AWAITING_VALIDATE_CODE ] : MFA_STATE . INVALID_CODE } } } ) ) . toBe ( true ) ;
186- expect ( result . hasTag ( ' showsInvalidCodeError' ) ) . toBe ( true ) ;
187+ expect ( snapshotToState ( result ) . showsInvalidCodeError ) . toBe ( true ) ;
187188 expect ( result . context . registrationChallenge ) . toBeUndefined ( ) ;
188189 expect ( result . context . error ) . toBeUndefined ( ) ;
189190 expect ( requestValidateCodeActionMock ) . not . toHaveBeenCalled ( ) ;
@@ -198,14 +199,14 @@ describe('MFA magic code and registration decision', () => {
198199 actor . start ( ) ;
199200 actor . send ( { type : 'VALIDATE_CODE_ENTERED' , validateCode : MFA_TEST_VALIDATE_CODE } ) ;
200201 await waitForBatchedUpdates ( ) ;
201- expect ( actor . getSnapshot ( ) . hasTag ( ' showsInvalidCodeError' ) ) . toBe ( true ) ;
202+ expect ( snapshotToState ( actor . getSnapshot ( ) ) . showsInvalidCodeError ) . toBe ( true ) ;
202203 actor . send ( { type : 'VALIDATE_CODE_ENTERED' , validateCode : MFA_TEST_VALIDATE_CODE } ) ;
203204 await waitForBatchedUpdates ( ) ;
204205
205206 const result = actor . getSnapshot ( ) ;
206207 expect ( result . context . registrationChallenge ) . toBe ( MFA_TEST_REGISTRATION_CHALLENGE ) ;
207208 expect ( result . context . validateCode ) . toBe ( MFA_TEST_VALIDATE_CODE ) ;
208- expect ( result . hasTag ( ' showsInvalidCodeError' ) ) . toBe ( false ) ;
209+ expect ( snapshotToState ( result ) . showsInvalidCodeError ) . toBe ( false ) ;
209210
210211 actor . stop ( ) ;
211212 } ) ;
@@ -250,7 +251,7 @@ describe('MFA magic code and registration decision', () => {
250251
251252 const result = actor . getSnapshot ( ) ;
252253 expect ( result . matches ( { [ MFA_STATE . OPEN ] : { [ MFA_STATE . MAGIC_CODE ] : { [ MFA_STATE . AWAITING_VALIDATE_CODE ] : MFA_STATE . AWAITING_INPUT } } } ) ) . toBe ( true ) ;
253- expect ( result . hasTag ( ' showsInvalidCodeError' ) ) . toBe ( false ) ;
254+ expect ( snapshotToState ( result ) . showsInvalidCodeError ) . toBe ( false ) ;
254255
255256 actor . stop ( ) ;
256257 } ) ;
0 commit comments