Files
carmanagement/apps/homepage/tests/unit/pricing-section.test.tsx
T
root d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
redesign the homepage
2026-06-26 16:27:21 -04:00

43 lines
1.7 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" homePath="/en" 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');
});
it('keeps unapproved public prices out of the rendered section', () => {
const content = buildHomepageContent(enHomepage, enShell).pricing;
render(<PricingSection content={content} locale="en" homePath="/en" demoSubmissionEnabled />);
expect(screen.getAllByText('Starting price pending approval')).toHaveLength(2);
expect(screen.getByText('Custom pricing')).toBeInTheDocument();
});
});