Files
carmanagement/apps/homepage/tests/unit/pricing-section.test.tsx
T
root e51c44f486
Build & Push / Pipeline Tests (push) Successful in 1m51s
Test / Type Check (all packages) (push) Successful in 51s
Build & Push / Build & Push Docker Image (push) Failing after 4m11s
Test / API Unit Tests (push) Successful in 1m15s
Test / Homepage Unit Tests (push) Successful in 49s
Test / Carplace Unit Tests (push) Successful in 43s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m5s
fix pricing at home page
2026-08-08 01:16:44 -04:00

102 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { PricingSection } from '@/components/homepage/sections/PricingSection';
import enHomepage from '@/content/locales/en/homepage.json';
import enShell from '@/content/locales/en/shell.json';
import { buildHomepageContent } from '@/content/homepage-model';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { beforeEach, describe, expect, it } from 'vitest';
describe('PricingSection', () => {
beforeEach(() => {
document.documentElement.dataset.theme = 'light';
});
it('changes the recommended plan when the fleet band changes', async () => {
const user = userEvent.setup();
const content = buildHomepageContent(enHomepage, enShell).pricing;
const { container } = render(
<PricingSection
content={content}
locale="en"
themePreference="light"
homePath="/en/system"
demoSubmissionEnabled
/>,
);
expect(container.querySelector('[data-plan="launch"]')).toHaveAttribute(
'data-recommended',
'true',
);
await user.click(screen.getByLabelText('2675 vehicles'));
expect(container.querySelector('[data-plan="growth"]')).toHaveAttribute(
'data-recommended',
'true',
);
expect(container.querySelector('[data-plan="launch"]')).not.toHaveAttribute('data-recommended');
await user.click(screen.getByLabelText('76150 vehicles'));
expect(container.querySelector('[data-plan="growth"]')).toHaveAttribute(
'data-recommended',
'true',
);
expect(container.querySelector('[data-plan="launch"]')).not.toHaveAttribute('data-recommended');
});
it('renders approved public prices except for Enterprise custom pricing', async () => {
const user = userEvent.setup();
const content = buildHomepageContent(enHomepage, enShell).pricing;
render(
<PricingSection
content={content}
locale="en"
themePreference="light"
homePath="/en/system"
demoSubmissionEnabled
/>,
);
expect(screen.queryByText('Starting price pending approval')).not.toBeInTheDocument();
expect(screen.getByText(/149/)).toBeInTheDocument();
expect(screen.getByText(/299/)).toBeInTheDocument();
expect(screen.getByText('Custom pricing')).toBeInTheDocument();
await user.click(screen.getByLabelText(/Annual/));
expect(screen.getByText(/Save 20%/)).toBeInTheDocument();
expect(screen.getByText(/1,430/)).toBeInTheDocument();
expect(screen.getAllByText('/ year')).toHaveLength(2);
expect(screen.getAllByText('billed annually after full-payment discount')).toHaveLength(2);
});
it('links self-serve plan CTAs to account creation and opens a pricing form for Enterprise', () => {
const content = buildHomepageContent(enHomepage, enShell).pricing;
render(
<PricingSection
content={content}
locale="en"
themePreference="dark"
homePath="/en/system"
demoSubmissionEnabled
/>,
);
expect(screen.getByRole('link', { name: 'Estimate Launch pricing' })).toHaveAttribute(
'href',
'/dashboard/sign-up?lang=en&theme=dark&plan=STARTER',
);
expect(screen.getByRole('link', { name: 'Book a Growth demo' })).toHaveAttribute(
'href',
'/dashboard/sign-up?lang=en&theme=dark&plan=GROWTH',
);
expect(screen.getByRole('button', { name: 'Talk to sales' })).toHaveAttribute(
'data-demo-source',
'pricing',
);
expect(screen.queryByRole('link', { name: 'Talk to sales' })).not.toBeInTheDocument();
});
});