insightsUpsellPage.spec.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {BillingConfigFixture} from 'getsentry-test/fixtures/billingConfig';
  3. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import type {TitleableModuleNames} from 'sentry/views/insights/common/components/modulePageProviders';
  6. import {InsightsUpsellPage} from 'getsentry/components/features/insightsUpsellPage';
  7. import {PlanTier} from 'getsentry/types';
  8. describe('InsightsUpsellPage', function () {
  9. const organization = OrganizationFixture();
  10. const subscription = SubscriptionFixture({
  11. organization,
  12. plan: 'am3_team',
  13. isFree: true,
  14. planTier: PlanTier.AM3,
  15. });
  16. beforeEach(() => {
  17. MockApiClient.clearMockResponses();
  18. MockApiClient.addMockResponse({
  19. url: `/customers/${organization.slug}/billing-config/`,
  20. body: BillingConfigFixture(PlanTier.AM3),
  21. });
  22. subscription.planDetails.features = [];
  23. });
  24. it('renders module if plan includes feature', async function () {
  25. subscription.planDetails.features = [
  26. 'insights-initial-modules',
  27. 'insights-addon-modules',
  28. ];
  29. render(
  30. <InsightsUpsellPage
  31. organization={organization}
  32. subscription={subscription}
  33. moduleName={'db'}
  34. >
  35. <span>db module content</span>
  36. </InsightsUpsellPage>
  37. );
  38. expect(await screen.findByText('db module content')).toBeInTheDocument();
  39. });
  40. it('renders upselling if feature is not included in plan', function () {
  41. render(
  42. <InsightsUpsellPage
  43. organization={organization}
  44. subscription={subscription}
  45. moduleName={'db'}
  46. >
  47. <span>db module content</span>
  48. </InsightsUpsellPage>
  49. );
  50. expect(screen.queryByText('db module content')).not.toBeInTheDocument();
  51. });
  52. it('renders module if no upselling exists', async function () {
  53. // let's assume there's a module in sentry, which has no upselling content in getsentry
  54. const unknownModuleName = 'new-fancy-feature' as TitleableModuleNames;
  55. render(
  56. <InsightsUpsellPage
  57. organization={organization}
  58. subscription={subscription}
  59. moduleName={unknownModuleName}
  60. >
  61. <span>new-fancy-feature</span>
  62. </InsightsUpsellPage>
  63. );
  64. expect(await screen.findByText('new-fancy-feature')).toBeInTheDocument();
  65. });
  66. });