feat: redesign routed ZarinPal merchant dashboard

This commit is contained in:
2026-08-20 21:41:18 +03:30
parent d8eeff57cd
commit 9ce2e6ec83
183 changed files with 7991 additions and 1569 deletions

View File

@@ -0,0 +1,41 @@
import { describe, expect, it } from 'vitest';
import { parseDashboardFilters, setDashboardQuery, type DashboardRange } from './dashboard-filters';
describe('dashboard filters', () => {
const terminals = ['T83', 'T84'];
it('uses safe, shareable defaults for invalid query values', () => {
const query = new URLSearchParams('range=year&terminal=someone-elses-terminal&minAmount=-1');
expect(parseDashboardFilters(query, terminals)).toEqual({
range: 'month',
terminal: 'all',
status: 'all',
minAmount: null,
maxAmount: null,
});
});
it.each<DashboardRange>(['day', 'week', 'month', 'season'])(
'keeps the %s range in the copied URL',
(range) => {
const next = setDashboardQuery(new URL('https://example.test/transactions?terminal=T83'), {
range,
});
expect(next.searchParams.get('range')).toBe(range);
expect(next.searchParams.get('terminal')).toBe('T83');
},
);
it('normalizes an inverted amount range', () => {
const filters = parseDashboardFilters(
new URLSearchParams('minAmount=900000&maxAmount=100000'),
terminals,
);
expect(filters.minAmount).toBe(100000);
expect(filters.maxAmount).toBe(900000);
});
});