@@ -12,6 +12,7 @@ const licenseResponseTemplate = <LicenseInfo>{
1212 instance_name : "Particular.ServiceControl" ,
1313 trial_license : false ,
1414 license_status : LicenseStatus . Valid ,
15+ license_extension_url : "" ,
1516 status : "valid" ,
1617} ;
1718export const hasActiveLicense = ( { driver } : SetupFactoryOptions ) => {
@@ -21,40 +22,51 @@ export const hasActiveLicense = ({ driver }: SetupFactoryOptions) => {
2122 } ) ;
2223 return licenseResponseTemplate ;
2324} ;
24- export const withExpiredLicense = ( licenseType : LicenseType , expiredDays : number ) => getLicenseMockedResponse ( licenseType , expiredDays , true ) ;
25- export const withExpiringLicense = ( licenseType : LicenseType , expiringInDays : number ) => getLicenseMockedResponse ( licenseType , expiringInDays , false ) ;
25+ export const hasExpiredLicense = ( licenseType : LicenseType , expiredDays : number = 10 , extensionUrl : string = "" ) => getLicenseMockedResponse ( licenseType , expiredDays , extensionUrl , true ) ;
26+ export const hasExpiringLicense = ( licenseType : LicenseType , expiringInDays : number = 10 , extensionUrl : string = "" ) => getLicenseMockedResponse ( licenseType , expiringInDays , extensionUrl , false ) ;
2627
2728const getLicenseMockedResponse =
28- ( licenseType : LicenseType , expiringInDays : number , isExpired : boolean ) =>
29+ ( licenseType : LicenseType , expiringInDays : number , extensionUrl : string , isExpired : boolean ) =>
2930 ( { driver } : SetupFactoryOptions ) => {
3031 const serviceControlInstanceUrl = window . defaultConfig . service_control_url ;
3132 const customISOString = getCustomDateISOString ( expiringInDays , isExpired ) ;
3233
3334 let status : LicenseStatus ;
34- let triallicense = false ;
35- let upgradeprotectionexpiration = "" ;
36- let expirationdate = "" ;
35+ let trialLicense = false ;
36+ let upgradeProtectionExpiration = "" ;
37+ let expirationDate = "" ;
38+ let licenseExtensionUrl = extensionUrl ;
3739
3840 switch ( licenseType ) {
3941 case LicenseType . Subscription :
4042 status = isExpired ? LicenseStatus . InvalidDueToExpiredSubscription : LicenseStatus . ValidWithExpiringSubscription ;
41- expirationdate = customISOString ;
43+ expirationDate = customISOString ;
4244 break ;
4345 case LicenseType . Trial :
4446 status = isExpired ? LicenseStatus . InvalidDueToExpiredTrial : LicenseStatus . ValidWithExpiringTrial ;
45- expirationdate = customISOString ;
46- triallicense = true ;
47+ expirationDate = customISOString ;
48+ trialLicense = true ;
49+ licenseExtensionUrl = extensionUrl ? extensionUrl : "https://particular.net/extend-your-trial?p=servicepulse" ;
4750 break ;
4851 case LicenseType . UpgradeProtection :
4952 status = isExpired ? LicenseStatus . InvalidDueToExpiredUpgradeProtection : LicenseStatus . ValidWithExpiringUpgradeProtection ;
50- upgradeprotectionexpiration = customISOString ;
53+ upgradeProtectionExpiration = customISOString ;
54+ licenseExtensionUrl = extensionUrl ? extensionUrl : "https://particular.net/extend-your-trial?p=servicepulse" ;
5155 break ;
5256 }
5357
5458 //We need to reset the global state to ensure the warning toast is always triggered by the value changing between multiple test runs. See documented issue and proposed solution https://github.com/Particular/ServicePulse/issues/1905
5559 license . license_status = LicenseStatus . Unavailable ;
5660
57- const response = { ...licenseResponseTemplate , license_type : licenseType , trial_license : triallicense , expiration_date : expirationdate , upgrade_protection_expiration : upgradeprotectionexpiration , license_status : status } ;
61+ const response = {
62+ ...licenseResponseTemplate ,
63+ license_type : licenseType ,
64+ trial_license : trialLicense ,
65+ expiration_date : expirationDate ,
66+ upgrade_protection_expiration : upgradeProtectionExpiration ,
67+ license_status : status ,
68+ license_extension_url : licenseExtensionUrl ,
69+ } ;
5870 console . log ( response ) ;
5971 driver . mockEndpoint ( `${ serviceControlInstanceUrl } license` , {
6072 body : response ,
0 commit comments