Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add BillingService.ts test coverage #881

Merged
merged 5 commits into from
Nov 15, 2023

Conversation

fedealconada
Copy link
Contributor

BillingService coverage

  • Adds test coverage for BillingService.ts (95%)
  • Adds LCOV as a reporter (though /coverage is ignored). This is useful to combine it with Coverage Gutters VS code extension to see the coverage
  • Adds a __mocks__ directory that would contain external libraries mocks (e.g Stripe)
  • Moves BillingService.ts string errors to a separate Errors.ts file
  • Sets collectCoverage: false on jest config to improve test speed
  • Adds coverage script to package.json

Pull Request Checklist:

  • Please make sure all jobs pass before requesting a review.
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
  • Have you lint your code locally before submission?
  • Did you write tests where appropriate?

Related Issue?

Screenshots (if appropriate):

@fedealconada fedealconada force-pushed the billing-service-coverage branch 2 times, most recently from b2e3734 to 0c265bd Compare November 13, 2023 16:36
@fedealconada
Copy link
Contributor Author

This is ready for review @simlarsen, the build fails on the Probe service but probably #884 fixes that

SUBSCRIPTION_NOT_FOUND: 'Subscription not found.',
NO_PAYMENTS_METHODS:
'No payment methods added. Please add your card to this project to change your plan',
/// @dev consider consolidating the above and below error messages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consoliate this to: Payment Method not added. Please go to Project Settings > Billing and add a payment method.

@@ -0,0 +1,16 @@
import * as mock from 'jest-mock-extended';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pascal case this file

trialDate = OneUptimeDate.getSomeDaysAfter(
data.plan.getTrialPeriod()
);
trialDate = data.trial
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this condition in if else above

@@ -0,0 +1,7 @@
export default {
API: {
CLIENT_SECRET_MISSING:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move this to Errors file in CommonServer under BillingService?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an APIException, I felt like it was better to put it in Common/Utils, but happy to move that one as well as INVOICE_NOT_GENERATED to CommonServer/Utils/Errors.ts file.
What do you prefer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move it to CommonServer since they are related to Billing and are only used in CommonServer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@simlarsen simlarsen merged commit 4dc5c55 into OneUptime:master Nov 15, 2023
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants