@@ -992,8 +992,9 @@ describe('PolicyUtils', () => {
992992 } as OnyxEntry < Policy > ;
993993
994994 it ( 'does return an ERROR RBR when a sync error exists for an admin' , ( ) => {
995- const policyWithConnectionFailures : OnyxEntry < Policy > = {
995+ const policyWithConnectionFailures = {
996996 ...baseAdminPolicy ,
997+ // Failed sync
997998 connections : {
998999 [ CONST . POLICY . CONNECTIONS . NAME . NETSUITE ] : {
9991000 verified : false ,
@@ -1014,10 +1015,90 @@ describe('PolicyUtils', () => {
10141015 expect ( result ) . toEqual ( CONST . BRICK_ROAD_INDICATOR_STATUS . ERROR ) ;
10151016 } ) ;
10161017
1017- it ( 'does not return an ERROR RBR when a sync error exists for a user' , ( ) => { } ) ;
1018+ it ( 'does not return an ERROR RBR when a sync error exists for a user' , ( ) => {
1019+ const policyWithConnectionFailures = {
1020+ ...baseUserPolicy ,
1021+ // Failed sync
1022+ connections : {
1023+ [ CONST . POLICY . CONNECTIONS . NAME . NETSUITE ] : {
1024+ verified : false ,
1025+ lastSync : {
1026+ errorDate : new Date ( ) . toISOString ( ) ,
1027+ errorMessage : 'Error' ,
1028+ isAuthenticationError : true ,
1029+ isConnected : false ,
1030+ isSuccessful : false ,
1031+ source : 'NEWEXPENSIFY' ,
1032+ successfulDate : '' ,
1033+ } ,
1034+ } ,
1035+ } as Connections ,
1036+ } as OnyxEntry < Policy > ;
1037+
1038+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithConnectionFailures , false ) ;
1039+ expect ( result ) . toBeUndefined ( ) ;
1040+ } ) ;
1041+
1042+ it ( 'does not return an ERROR RBR when no sync errors exist for an admin' , ( ) => {
1043+ const policyWithoutConnections = {
1044+ ...baseAdminPolicy ,
1045+ connections : { } as Connections ,
1046+ } as OnyxEntry < Policy > ;
1047+
1048+ const policyWithoutConnectionFailures = {
1049+ ...baseAdminPolicy ,
1050+ connections : {
1051+ [ CONST . POLICY . CONNECTIONS . NAME . NETSUITE ] : {
1052+ verified : true ,
1053+ lastSync : {
1054+ errorDate : '' ,
1055+ errorMessage : '' ,
1056+ isAuthenticationError : false ,
1057+ isConnected : true ,
1058+ isSuccessful : true ,
1059+ source : 'NEWEXPENSIFY' ,
1060+ successfulDate : '' ,
1061+ } ,
1062+ } ,
1063+ } as Connections ,
1064+ } as OnyxEntry < Policy > ;
1065+
1066+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithoutConnectionFailures , false ) ;
1067+ expect ( result ) . toBeUndefined ( ) ;
1068+
1069+ const result2 = getPolicyBrickRoadIndicatorStatus ( policyWithoutConnections , false ) ;
1070+ expect ( result2 ) . toBeUndefined ( ) ;
1071+ } ) ;
1072+
1073+ it ( 'does not return an ERROR RBR when no sync error exists for a user' , ( ) => {
1074+ const policyWithoutConnections = {
1075+ ...baseUserPolicy ,
1076+ connections : { } as Connections ,
1077+ } as OnyxEntry < Policy > ;
1078+
1079+ const policyWithoutConnectionFailures = {
1080+ ...baseUserPolicy ,
1081+ connections : {
1082+ [ CONST . POLICY . CONNECTIONS . NAME . NETSUITE ] : {
1083+ verified : true ,
1084+ lastSync : {
1085+ errorDate : '' ,
1086+ errorMessage : '' ,
1087+ isAuthenticationError : false ,
1088+ isConnected : true ,
1089+ isSuccessful : true ,
1090+ source : 'NEWEXPENSIFY' ,
1091+ successfulDate : '' ,
1092+ } ,
1093+ } ,
1094+ } as Connections ,
1095+ } as OnyxEntry < Policy > ;
10181096
1019- it ( 'does not return an ERROR RBR when no sync errors exist for an admin' , ( ) => { } ) ;
1097+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithoutConnections , false ) ;
1098+ expect ( result ) . toBeUndefined ( ) ;
10201099
1021- it ( 'does not return an ERROR RBR when no sync error exists for a user' , ( ) => { } ) ;
1100+ const result2 = getPolicyBrickRoadIndicatorStatus ( policyWithoutConnectionFailures , false ) ;
1101+ expect ( result2 ) . toBeUndefined ( ) ;
1102+ } ) ;
10221103 } ) ;
10231104} ) ;
0 commit comments