Five places where the data existed and the screen did not use it. Booking a whole course had no button because it needs a doctor and the course does not carry one — each session can be with a different doctor. The page now asks for the doctor the same way the resource booking page does, and the button explains that it is all-or-nothing before it is pressed. A course whose package does not cover the remaining sessions is still valid — the rest is simply charged normally — but nobody was told. The course response carries package_balance and the shortfall, and the page warns. Before session six, not during it. The credit ledger already returned who recorded a row and which appointment it belonged to, and showed neither. An adjustable ledger without the name of the person who adjusted it is half an audit trail. Version history printed a JSON blob of each version's effects, which does not answer the question anyone actually has: what changed? It now diffs each version against the previous one, field by field, and says so plainly when a version changed nothing meaningful. A resource with no calendar showed "—" for utilization. Null means undefined, not zero, and the next step is always the same: set up the calendar. It is a link now. The report range also accepts a custom from/to, kept in the URL like the rest. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import PolicyVersionDiff from './PolicyVersionDiff';
|
|
|
|
const version = (n: number, snapshot: Record<string, unknown>) => ({
|
|
version: n,
|
|
created_at: 1_800_000_000 + n,
|
|
snapshot,
|
|
});
|
|
|
|
describe('PolicyVersionDiff', () => {
|
|
/** ⭐ سؤال واقعی «چه چیزی عوض شد؟» است، نه «هر نسخه چه بود». */
|
|
it('shows only the fields that changed between versions', () => {
|
|
render(
|
|
<PolicyVersionDiff
|
|
versions={[
|
|
version(1, { name: 'تخفیف پاییز', priority: 0, effects: [{ type: 'discount_percent', value: 10 }] }),
|
|
version(2, { name: 'تخفیف پاییز', priority: 5, effects: [{ type: 'discount_percent', value: 20 }] }),
|
|
]}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByText('اولویت')).toBeInTheDocument();
|
|
expect(screen.getByText('اثرها')).toBeInTheDocument();
|
|
// نام عوض نشده، پس نباید ردیف بگیرد.
|
|
expect(screen.queryByText('نام')).toBeNull();
|
|
});
|
|
|
|
it('marks the first version rather than diffing it against nothing', () => {
|
|
render(<PolicyVersionDiff versions={[version(1, { name: 'قانون' })]} />);
|
|
|
|
expect(screen.getByText('نسخهٔ نخست')).toBeInTheDocument();
|
|
});
|
|
|
|
it('says so when a version changed nothing meaningful', () => {
|
|
render(
|
|
<PolicyVersionDiff
|
|
versions={[version(1, { name: 'قانون', priority: 0 }), version(2, { name: 'قانون', priority: 0 })]}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByText('بدون تغییرِ معنادار')).toBeInTheDocument();
|
|
});
|
|
});
|