Files
carmanagement/apps/homepage/tests/unit/pricing-section.test.tsx
T
root 781512399b
Build & Deploy / Build & Push Docker Image (push) Successful in 2m51s
Test / Type Check (all packages) (push) Successful in 52s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Successful in 49s
Test / Homepage Unit Tests (push) Successful in 44s
Test / Storefront Unit Tests (push) Successful in 39s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Successful in 40s
Test / API Integration Tests (push) Successful in 1m0s
Update homepage routes to include language and mode
2026-07-02 14:10:17 -04:00

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