@@ -40,6 +40,7 @@ import {
4040} from "@azure/msal-common" ;
4141import {
4242 BrowserCacheLocation ,
43+ INTERACTION_TYPE ,
4344 InteractionType ,
4445 TemporaryCacheKeys ,
4546} from "../../src/utils/BrowserConstants.js" ;
@@ -1467,6 +1468,90 @@ describe("BrowserCacheManager tests", () => {
14671468 ) ;
14681469 } ) ;
14691470 } ) ;
1471+
1472+ describe ( "interactionInProgress" , ( ) => {
1473+ it ( "handles new format" , ( ) => {
1474+ const perfClient = new BrowserPerformanceClient ( {
1475+ auth : {
1476+ clientId : TEST_CONFIG . MSAL_CLIENT_ID ,
1477+ } ,
1478+ } ) ;
1479+ const cacheManager = new BrowserCacheManager (
1480+ TEST_CONFIG . MSAL_CLIENT_ID ,
1481+ cacheConfig ,
1482+ browserCrypto ,
1483+ logger ,
1484+ perfClient ,
1485+ new EventHandler ( )
1486+ ) ;
1487+
1488+ cacheManager . setInteractionInProgress ( true ) ;
1489+ expect (
1490+ cacheManager . getInteractionInProgress ( ) ?. clientId
1491+ ) . toEqual ( TEST_CONFIG . MSAL_CLIENT_ID ) ;
1492+ expect (
1493+ cacheManager . getInteractionInProgress ( ) ?. type
1494+ ) . toEqual ( INTERACTION_TYPE . SIGNIN ) ;
1495+ } ) ;
1496+
1497+ it ( "handles old format" , ( ) => {
1498+ const perfClient = new BrowserPerformanceClient ( {
1499+ auth : {
1500+ clientId : TEST_CONFIG . MSAL_CLIENT_ID ,
1501+ } ,
1502+ } ) ;
1503+ const cacheManager = new BrowserCacheManager (
1504+ TEST_CONFIG . MSAL_CLIENT_ID ,
1505+ cacheConfig ,
1506+ browserCrypto ,
1507+ logger ,
1508+ perfClient ,
1509+ new EventHandler ( )
1510+ ) ;
1511+
1512+ cacheManager . setTemporaryCache (
1513+ `${ Constants . CACHE_PREFIX } .${ TemporaryCacheKeys . INTERACTION_STATUS_KEY } ` ,
1514+ TEST_CONFIG . MSAL_CLIENT_ID
1515+ ) ;
1516+ expect ( cacheManager . getInteractionInProgress ( ) ) . toBeNull ( ) ;
1517+ } ) ;
1518+
1519+ it ( "handles old format and removes temporary artifacts" , ( ) => {
1520+ const perfClient = new BrowserPerformanceClient ( {
1521+ auth : {
1522+ clientId : TEST_CONFIG . MSAL_CLIENT_ID ,
1523+ } ,
1524+ } ) ;
1525+ const cacheManager = new BrowserCacheManager (
1526+ TEST_CONFIG . MSAL_CLIENT_ID ,
1527+ cacheConfig ,
1528+ browserCrypto ,
1529+ logger ,
1530+ perfClient ,
1531+ new EventHandler ( )
1532+ ) ;
1533+
1534+ cacheManager . setTemporaryCache (
1535+ `${ Constants . CACHE_PREFIX } .${ TemporaryCacheKeys . INTERACTION_STATUS_KEY } ` ,
1536+ TEST_CONFIG . MSAL_CLIENT_ID
1537+ ) ;
1538+ // @ts -ignore
1539+ const requestParamKey = cacheManager . generateCacheKey (
1540+ TemporaryCacheKeys . REQUEST_PARAMS
1541+ ) ;
1542+ const requestParamPayload = JSON . stringify ( {
1543+ correlationId : "test-correlation-id" ,
1544+ } ) ;
1545+ cacheManager . setTemporaryCache (
1546+ requestParamKey ,
1547+ requestParamPayload
1548+ ) ;
1549+ expect ( cacheManager . getInteractionInProgress ( ) ) . toBeNull ( ) ;
1550+ expect (
1551+ cacheManager . getTemporaryCache ( requestParamKey )
1552+ ) . toBeNull ( ) ;
1553+ } ) ;
1554+ } ) ;
14701555 } ) ;
14711556 } ) ;
14721557
0 commit comments