import { Before } from 'cypress-cucumber-preprocessor/steps' ; import { addFCBasicAuthorization , clearAllCookies , clearBusinessLog , disableSameSiteLax , getDefaultIdentityProvider , getDefaultServiceProvider , getDefaultUser , isUsingFCBasicAuthorization , } from '../helpers' ; import { IdentityProvider , ServiceProvider , UserData } from '../types' ; const skipTest = ( ) : void => { todo author cy . state ( 'runnable' ) . ctx . skip ( ) ; } ; const setFixtureContext = ( fixture , pathArray , contextName ) : void => { cy . task ( 'getFixturePath' , { fixture , pathArray } ) . then ( ( fixturePath ) => { cy . log ( fixturePath ) ; cy . fixture ( fixturePath ) . as ( contextName ) ; } ) ; } ; beforeEach ( function ( ) { const platform = Cypress . env ( 'PLATFORM' ) ; const testEnv = Cypress . env ( 'TEST_ENV' ) ; const pathArray = [ platform , testEnv ] ; setFixtureContext ( 'environment.json' , pathArray , 'env' ) ; setFixtureContext ( 'service-providers.json' , pathArray , 'serviceProviders' ) ; setFixtureContext ( 'identity-providers.json' , pathArray , 'identityProviders' ) ; setFixtureContext ( 'scopes.json' , pathArray , 'scopes' ) ; setFixtureContext ( 'users.json' , pathArray , 'users' ) ; cy . get < ServiceProvider [ ] > ( '@serviceProviders' ) . then ( ( serviceProviders ) => { getDefaultServiceProvider ( serviceProviders ) ; } ) ; cy . get < IdentityProvider [ ] > ( '@identityProviders' ) . then ( ( identityProviders ) => { getDefaultIdentityProvider ( identityProviders ) ; } ) ; cy . get < UserData [ ] > ( '@users' ) . then ( ( users ) => { getDefaultUser ( users ) ; } ) ; if ( isUsingFCBasicAuthorization ( ) ) { addFCBasicAuthorization ( ) ; } if ( testEnv === 'docker' ) { clearBusinessLog ( ) ; } else if ( testEnv === 'integ01' ) { clearAllCookies ( ) ; const crossDomains = { FC : 'dev-franceconnect.fr' , FI : 'fournisseur-d-identite.fr' , FS : 'fournisseur-de-service.fr' , } ; disableSameSiteLax ( crossDomains ) ; } } ) ; todo afterEach ( function ( ) { delete this . requestedScope ; delete this . serviceProvider ; delete this . identityProvider ; delete this . user ; delete this . operatorUser ; } ) ; Before ( { tags : '@ignoreInteg01' } , function ( ) { if ( Cypress . env ( 'TEST_ENV' ) === 'integ01' ) { skipTest ( ) ; } } ) ;