Fix date-range filter selections (Refs #104)
This commit is contained in:
@@ -53,6 +53,27 @@ beforeEach(() => {
|
||||
});
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
it.each([
|
||||
['', '0', 'All retained history'],
|
||||
['0', '0', 'All retained history'],
|
||||
['1', '1', 'Last 24 hours'],
|
||||
['7', '7', 'Last 7 days'],
|
||||
['30', '30', 'Last 30 days'],
|
||||
['90', '90', 'Last 90 days'],
|
||||
['14', '14', 'Last 14 days']
|
||||
])('selects the current date range for days=%s on desktop and mobile', (days, value, label) => {
|
||||
scope(days ? `/activity?days=${days}` : '/activity');
|
||||
const body = render(ActivityLog, { props: { initial: report() } }).body;
|
||||
for (const suffix of ['', '-mobile']) {
|
||||
const select = body.match(
|
||||
new RegExp(`<select\\b[^>]*id="activity-days${suffix}"[^>]*>([\\s\\S]*?)</select>`)
|
||||
)?.[1];
|
||||
expect(select).toBeDefined();
|
||||
expect(select).toContain(`<option value="${value}" selected="">${label}</option>`);
|
||||
expect(select?.match(/\bselected=""/g)).toHaveLength(1);
|
||||
}
|
||||
});
|
||||
|
||||
it('sends only supported normalized filters and enforces scoped identities', () => {
|
||||
const url = new URL(
|
||||
'https://example.test/servers/town?tab=history&server=wrong&source=host&state=failed&offset=50&returnTo=%2F'
|
||||
|
||||
@@ -41,6 +41,27 @@ beforeEach(() => {
|
||||
vi.setSystemTime(new Date('2026-10-06T20:00:00Z'));
|
||||
});
|
||||
afterEach(() => vi.useRealTimers());
|
||||
it.each([
|
||||
['', '0', 'All time'],
|
||||
['0', '0', 'All time'],
|
||||
['7', '7', 'Last 7 days'],
|
||||
['30', '30', 'Last 30 days'],
|
||||
['90', '90', 'Last 90 days']
|
||||
])(
|
||||
'selects the current date range for matchDays=%s on desktop and mobile',
|
||||
(days, value, label) => {
|
||||
scope(days ? `?matchDays=${days}` : '');
|
||||
const body = render(MatchHistory, { props: { initial: report() } }).body;
|
||||
for (const suffix of ['', '-mobile']) {
|
||||
const select = body.match(
|
||||
new RegExp(`<select\\b[^>]*id="match-days${suffix}"[^>]*>([\\s\\S]*?)</select>`)
|
||||
)?.[1];
|
||||
expect(select).toBeDefined();
|
||||
expect(select).toContain(`<option value="${value}" selected="">${label}</option>`);
|
||||
expect(select?.match(/\bselected=""/g)).toHaveLength(1);
|
||||
}
|
||||
}
|
||||
);
|
||||
it('renders one page heading, six columns, a combined identity, and compact dates', () => {
|
||||
const body = render(MatchHistoryPage, {
|
||||
props: { data: { history: report(), user: null, setupRequired: false } }
|
||||
|
||||
Reference in New Issue
Block a user