Tailwind was configured with darkMode: "class" while next-themes writes data-theme="dark" on the public pages. Every dark: utility on the public site — 111 of them — compiled to a selector that never matched, which is why the booking flow stayed white in dark mode. The variant strategy now accepts both .dark (the panel) and [data-theme="dark"] (the public pages), so neither provider had to change and 66 dark rules now compile against the real attribute. The cancel and reschedule modals get tests, the first component tests in this repo. They pin the things that would be silently wrong: the penalty comes from the server before anything is cancelled, the free window says "no penalty" rather than showing a zero, confirming actually sends the request (the old dialog's confirm button only closed it), a failed preview does not block the cancellation, slots are requested with exclude_appointment_uuid so the patient's own hour is not shown as taken, and the reschedule sends only the start time because the server owns the duration. The amount assertion deliberately checks the number and unit rather than the digit shape — numberToArStyle uses the ar-AE locale and its output depends on the ICU data in the environment. lib/getStateInfo.test.js had been failing since before this work: an unknown host falls through to the representation API, so the test made a real network call and timed out after five seconds. It mocks lib/req now. The suite is fully green for the first time: 158 tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
|
const { hostRef } = vi.hoisted(() => ({ hostRef: { value: '' } }));
|
|
|
|
vi.mock('next/headers', () => ({
|
|
headers: async () => ({ get: (k) => (k === 'host' ? hostRef.value : null) }),
|
|
}));
|
|
|
|
// هاستِ ناشناخته به API نمایندگی میرود؛ بدون این mock تست به شبکهٔ واقعی میزند و
|
|
// بعد از پنج ثانیه timeout میشود — همان شکستِ قدیمیِ این فایل.
|
|
vi.mock('@/lib/req', () => ({
|
|
fetchReq: async () => null,
|
|
}));
|
|
|
|
import { getStateInfo } from '@/lib/getStateInfo';
|
|
|
|
beforeEach(() => {
|
|
hostRef.value = '';
|
|
});
|
|
|
|
describe('getStateInfo (server)', () => {
|
|
it('subdomain شناختهشده → شهر و استان درست', async () => {
|
|
hostRef.value = 'arak-nobat.ir';
|
|
const { matchedCity, matchedState } = await getStateInfo();
|
|
expect(matchedCity?.name).toBe('اراک');
|
|
expect(matchedState?.name).toBe('مرکزی');
|
|
});
|
|
|
|
it('host ناشناخته → بدون تطبیق', async () => {
|
|
hostRef.value = 'unknown-city.ir';
|
|
const { matchedCity, matchedState } = await getStateInfo();
|
|
expect(matchedCity).toBeUndefined();
|
|
expect(matchedState).toBeFalsy();
|
|
});
|
|
|
|
it('host خالی → بدون تطبیق', async () => {
|
|
hostRef.value = '';
|
|
const { matchedCity } = await getStateInfo();
|
|
expect(matchedCity).toBeUndefined();
|
|
});
|
|
});
|