fix(scheduler): checking for predicates fullfillment on applying discount

This commit is contained in:
Karol Sójko 2022-07-25 13:00:40 +02:00
parent b9661d74ee
commit 6374248132
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0
2 changed files with 6 additions and 0 deletions

View file

@ -189,6 +189,11 @@ describe('JobDoneInterpreter', () => {
userIdentifier: 'test@standardnotes.com',
userIdentifierType: 'email',
} as jest.Mocked<Job>)
predicateRepository.findByJobUuid = jest
.fn()
.mockReturnValue([
{ name: PredicateName.SubscriptionPurchased, status: PredicateStatus.Denied } as jest.Mocked<Predicate>,
])
await createInterpreter().interpret('1-2-3')

View file

@ -124,6 +124,7 @@ export class JobDoneInterpreter implements JobDoneInterpreterInterface {
PredicateStatus.Denied
)
case JobName.ENCOURAGE_SUBSCRIPTION_PURCHASING:
case JobName.APPLY_SUBSCRIPTION_DISCOUNT:
return (
predicates.find((predicate) => predicate.name === PredicateName.SubscriptionPurchased)?.status ===
PredicateStatus.Denied