fleetAudience.test.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Fleet-size audience split for the sponsor surfaces.
  3. *
  4. * The threshold decides which pitch a user sees, so it is worth pinning: a
  5. * hobbyist must never be asked to buy a support contract, and a print farm must
  6. * never be asked to chip in $5.
  7. */
  8. import { describe, it, expect } from 'vitest';
  9. import {
  10. BUSINESS_FLEET_THRESHOLD,
  11. fleetAudience,
  12. sponsorHref,
  13. } from '../../utils/fleetAudience';
  14. describe('fleetAudience', () => {
  15. it('treats a fleet below the threshold as personal', () => {
  16. expect(fleetAudience(0)).toBe('personal');
  17. expect(fleetAudience(1)).toBe('personal');
  18. expect(fleetAudience(BUSINESS_FLEET_THRESHOLD - 1)).toBe('personal');
  19. });
  20. it('treats the threshold itself as business (inclusive boundary)', () => {
  21. expect(fleetAudience(BUSINESS_FLEET_THRESHOLD)).toBe('business');
  22. expect(fleetAudience(BUSINESS_FLEET_THRESHOLD + 1)).toBe('business');
  23. expect(fleetAudience(40)).toBe('business');
  24. });
  25. });
  26. describe('sponsorHref', () => {
  27. it('sends a personal audience to the sponsor tiers', () => {
  28. expect(sponsorHref('personal', 'app-settings')).toBe(
  29. 'https://bambuddy.cool/sponsors.html?from=app-settings',
  30. );
  31. });
  32. it('sends a business audience to the commercial page', () => {
  33. expect(sponsorHref('business', 'app-settings')).toBe(
  34. 'https://bambuddy.cool/business.html?from=app-settings',
  35. );
  36. });
  37. it('preserves the Matomo attribution param on both', () => {
  38. // The `?from=` tag is how the funnel is measured — losing it would make the
  39. // whole surface invisible in analytics.
  40. expect(sponsorHref('personal', 'app-toast-prints-10')).toContain('?from=app-toast-prints-10');
  41. expect(sponsorHref('business', 'app-toast-prints-10')).toContain('?from=app-toast-prints-10');
  42. });
  43. });