From aaa51ae822d06758040a857a8e33664c86ed2cae Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Mon, 30 Nov 2026 11:22:49 -0600 Subject: [PATCH 1/3] Address /next feedback: bulk status, local times, DST charts - Batch multi-id stack/event routes to 10 ids per request so IIS/HTTP.sys's 260-char path segment limit no longer 400s bulk actions - Format times with the user's locale clock instead of forcing AM/PM - Bucket date histograms in the IANA time zone so day buckets stay on local midnight across daylight saving changes - Detail-page filter drilldowns search all time instead of the last 7 days - Highlight a linked summary's bold type/method on hover - Users column shows the affected user count (share in tooltip) - Soften the floating table toolbar ring Co-Authored-By: Claude Opus 5.5 --- .../src/lib/features/events/api.svelte.ts | 13 +++- .../events/components/summary/summary.svelte | 69 +++++++++++-------- .../table/stack-users-summary-cell.svelte | 26 +++++-- .../src/lib/features/shared/api/api.svelte.ts | 25 +++++++ .../src/lib/features/shared/api/urls.test.ts | 21 ++++++ .../src/lib/features/shared/api/urls.ts | 20 ++++++ .../data-table/data-table-footer.svelte | 2 +- .../components/formatters/date-time.svelte | 1 - .../src/lib/features/shared/dates.test.ts | 12 +++- .../src/lib/features/shared/dates.ts | 20 ++++-- .../src/lib/features/stacks/api.svelte.ts | 55 ++++++++++----- .../stacks/components/stack-card.svelte | 4 +- .../src/routes/(app)/event/+page.svelte | 4 +- .../event/[eventId=objectid]/+page.svelte | 4 +- .../[projectId]/stacks/[stackId]/+page.svelte | 4 +- .../(app)/redirect-to-events.svelte.test.ts | 12 ++++ .../routes/(app)/redirect-to-events.svelte.ts | 10 +++ .../src/routes/(app)/sessions/+page.svelte | 4 +- .../src/routes/(app)/stack/+page.svelte | 4 +- .../stack/[stackId=objectid]/+page.svelte | 4 +- .../[action=stackaction]/+page.svelte | 4 +- .../event/[eventId=objectid]/+page.svelte | 4 +- .../PersistentEventQueryValidatorTests.cs | 2 + .../Stats/AggregationTests.cs | 21 ++++++ 24 files changed, 262 insertions(+), 83 deletions(-) diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts index cbdeeb4feb..8550a3ee3c 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts @@ -8,6 +8,7 @@ import type { CountResult, WorkInProgressResult } from '#shared/models/index.ts' import { accessToken } from '#features/auth/index.svelte.ts'; import { queryKeys as stackQueryKeys } from '#features/stacks/api.svelte.ts'; import { DEFAULT_OFFSET } from '#shared/api/api.svelte.ts'; +import { toIdPathSegments } from '#shared/api/urls.ts'; import type { EventSummaryModel, SummaryTemplateKeys } from './components/summary/index'; import type { PersistentEvent } from './models'; @@ -351,9 +352,15 @@ export function deleteEvent(request: DeleteEventsRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async () => { const client = useFetchClient(); - const response = await client.deleteJSON(`events/${request.route.ids?.join(',')}`); + const workers: string[] = []; + for (const ids of toIdPathSegments(request.route.ids)) { + const response = await client.deleteJSON(`events/${ids}`); + workers.push(...(response.data?.workers ?? [])); + } - return response.data!; + return { + workers + }; }, mutationKey: queryKeys.deleteEvent(request.route.ids), onError: () => { @@ -493,7 +500,7 @@ export function getOrganizationEventsQuery(request: GetOrganizationEventsRequest /** * Get session count with aggregations for stats and chart data. - * Uses aggregation: avg:value cardinality:user date:(date^offset cardinality:user) + * Uses aggregation: avg:value cardinality:user date:(date^timezone cardinality:user) */ export function getOrganizationSessionsCountQuery(request: GetOrganizationSessionsCountRequest) { const queryClient = useQueryClient(); diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/summary/summary.svelte b/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/summary/summary.svelte index 51ab2de906..4c82a4bb98 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/summary/summary.svelte +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/summary/summary.svelte @@ -28,34 +28,45 @@ let { linkToDetails = true, showStatus = true, showType = true, summary }: Props = $props(); let showBadge: boolean = $derived(showStatus && 'status' in summary && summary.status !== 'open'); let badgeStatus = $derived(('status' in summary && (summary.status as StackStatus)) || StackStatus.Open); + // Stack summaries always link to the stack; event summaries only when asked to. + let isLinked = $derived(linkToDetails || summary.template_key.startsWith('stack-')); -{#if summary.template_key === 'event-summary'} - -{:else if summary.template_key === 'stack-summary'} - -{:else if summary.template_key === 'event-simple-summary'} - -{:else if summary.template_key === 'stack-simple-summary'} - -{:else if summary.template_key === 'event-error-summary'} - -{:else if summary.template_key === 'stack-error-summary'} - -{:else if summary.template_key === 'event-session-summary'} - -{:else if summary.template_key === 'stack-session-summary'} - -{:else if summary.template_key === 'event-notfound-summary'} - -{:else if summary.template_key === 'stack-notfound-summary'} - -{:else if summary.template_key === 'event-feature-summary'} - -{:else if summary.template_key === 'stack-feature-summary'} - -{:else if summary.template_key === 'event-log-summary'} - -{:else} - -{/if} + +
+ {#if summary.template_key === 'event-summary'} + + {:else if summary.template_key === 'stack-summary'} + + {:else if summary.template_key === 'event-simple-summary'} + + {:else if summary.template_key === 'stack-simple-summary'} + + {:else if summary.template_key === 'event-error-summary'} + + {:else if summary.template_key === 'stack-error-summary'} + + {:else if summary.template_key === 'event-session-summary'} + + {:else if summary.template_key === 'stack-session-summary'} + + {:else if summary.template_key === 'event-notfound-summary'} + + {:else if summary.template_key === 'stack-notfound-summary'} + + {:else if summary.template_key === 'event-feature-summary'} + + {:else if summary.template_key === 'stack-feature-summary'} + + {:else if summary.template_key === 'event-log-summary'} + + {:else} + + {/if} +
+ + diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/stack-users-summary-cell.svelte b/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/stack-users-summary-cell.svelte index 38781515da..ba18a212e9 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/stack-users-summary-cell.svelte +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/stack-users-summary-cell.svelte @@ -5,11 +5,29 @@ summary: SummaryModel; } + const countFormat = new Intl.NumberFormat(); + const compactCountFormat = new Intl.NumberFormat(undefined, { + notation: 'compact' + }); + const percentFormat = new Intl.NumberFormat(undefined, { + maximumFractionDigits: 1, + style: 'percent' + }); + let { summary }: Props = $props(); let source = $derived(summary as StackSummaryModel); - let percentage = $derived(source.total_users > 0 ? (source.users / source.total_users) * 100.0 : 0); + let users = $derived(source.users ?? 0); + let totalUsers = $derived(source.total_users ?? 0); + let title = $derived( + totalUsers > 0 + ? `${countFormat.format(users)} of ${countFormat.format(totalUsers)} users (${percentFormat.format(users / totalUsers)})` + : `${countFormat.format(users)} users` + ); - - {percentage.toFixed(1)}% - + +{#if users > 0} + {compactCountFormat.format(users)} +{:else} + — +{/if} diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/api.svelte.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/api.svelte.ts index 20ad16e13c..ea7ef5f8ea 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/api.svelte.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/api.svelte.ts @@ -14,6 +14,12 @@ export { DEFAULT_LIMIT } from './constants'; */ export const DEFAULT_OFFSET = new SvelteDate().getTimezoneOffset() !== 0 ? new SvelteDate().getTimezoneOffset() * -1 + 'm' : undefined; +/** + * The time zone date histograms bucket in. An IANA zone keeps day buckets on local midnight across daylight saving changes, + * which a fixed offset can't: buckets from the other half of the year would start at 1 AM or 11 PM local time. + */ +export const DEFAULT_HISTOGRAM_TIME_ZONE = getHistogramTimeZone(); + export class FetchClientStatus { public isLoading = $state(false); @@ -46,10 +52,29 @@ export async function fetchApiJson(path: string, init: RequestInit): Promise< return (await response.json()) as T; } +/** The `date` aggregation term, bucketed in the user's time zone, e.g. `date^Europe/Amsterdam`. */ +export function getDateHistogramTerm(field = 'date'): string { + return DEFAULT_HISTOGRAM_TIME_ZONE ? `${field}^${DEFAULT_HISTOGRAM_TIME_ZONE}` : field; +} + export function useFetchClientStatus(target?: FetchClient | FetchClientProvider) { return new FetchClientStatus(target); } +function getHistogramTimeZone(): string | undefined { + try { + const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; + // Unquoted aggregation terms can't contain whitespace or query syntax characters. + if (timeZone && timeZone !== 'UTC' && /^[\w+\-/]+$/.test(timeZone)) { + return timeZone; + } + } catch { + // Fall back to the fixed offset below. + } + + return DEFAULT_OFFSET; +} + async function toProblemDetails(response: Response): Promise { const contentType = response.headers.get('Content-Type') ?? ''; if (contentType.startsWith('application/problem+json') || contentType.startsWith('application/json')) { diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts index a069754836..38eed1a7bc 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts @@ -34,3 +34,24 @@ describe('API hosting URLs', () => { expect((await import('../help-links')).apiReferenceHref).toBe('https://localhost:8443/docs'); }); }); + +describe('toIdPathSegments', () => { + it('batches ids so each path segment stays short enough for strict hosts', async () => { + const { toIdPathSegments } = await import('./urls'); + const ids = Array.from({ length: 12 }, (_, index) => index.toString(16).padStart(24, '0')); + + const segments = toIdPathSegments(ids); + + expect(segments).toHaveLength(2); + expect(segments[0]!.split(',')).toEqual(ids.slice(0, 10)); + expect(segments[1]!.split(',')).toEqual(ids.slice(10)); + expect(segments.every((segment) => segment.length < 260)).toBe(true); + }); + + it('returns no segments for no ids', async () => { + const { toIdPathSegments } = await import('./urls'); + + expect(toIdPathSegments(undefined)).toEqual([]); + expect(toIdPathSegments([])).toEqual([]); + }); +}); diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.ts index eacfcf88e5..6403439ed9 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.ts @@ -9,3 +9,23 @@ export function getServerUrl(path: string): string { const base = (PUBLIC_BASE_URL ?? '').trim().replace(/\/+$/, ''); return `${base}/${path.replace(/^\/+/, '')}`; } + +/** + * Some hosts and proxies reject a URL path segment longer than 260 characters (IIS/HTTP.sys, for example, answer 400 Bad Request). + * Ten 24-character ids joined with commas stay under that, so multi-id routes send their ids in batches of this size. + */ +export const MAX_IDS_PER_PATH_SEGMENT = 10; + +/** Splits ids into comma-joined batches that each fit in one URL path segment. */ +export function toIdPathSegments(ids: readonly string[] | undefined, size = MAX_IDS_PER_PATH_SEGMENT): string[] { + if (!ids?.length) { + return []; + } + + const segments: string[] = []; + for (let index = 0; index < ids.length; index += size) { + segments.push(ids.slice(index, index + size).join(',')); + } + + return segments; +} diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/data-table/data-table-footer.svelte b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/data-table/data-table-footer.svelte index 2e5938aa01..95e6378991 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/data-table/data-table-footer.svelte +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/data-table/data-table-footer.svelte @@ -93,7 +93,7 @@ diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/formatters/date-time.svelte b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/formatters/date-time.svelte index 9a64fca082..5dc2bddc20 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/formatters/date-time.svelte +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/formatters/date-time.svelte @@ -15,7 +15,6 @@ return date.toLocaleString(undefined, { day: 'numeric', hour: 'numeric', - hour12: true, minute: '2-digit', month: 'short', second: '2-digit', diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts index 55a588ab89..828f9c4198 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { formatDateLabel, formatDateRangeLabel, getDifferenceInSeconds, getRelativeTimeFormatUnit, getSetIntervalTime } from './dates'; +import { formatDateLabel, formatDateRangeLabel, getDifferenceInSeconds, getRelativeTimeFormatUnit, getSetIntervalTime, usesTwelveHourClock } from './dates'; describe('formatDateLabel', () => { it('preserves local date and relative-label behavior without a timezone override', () => { @@ -49,7 +49,15 @@ describe('formatDateLabel', () => { // Assert expect(label).toContain(' at '); - expect(label).toContain(new Intl.DateTimeFormat(undefined, { hour: 'numeric', hour12: true, minute: '2-digit', timeZone }).format(date)); + expect(label).toContain(new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit', timeZone }).format(date)); + }); +}); + +describe('usesTwelveHourClock', () => { + it('follows the locale instead of always using AM/PM', () => { + expect(usesTwelveHourClock('en-US')).toBe(true); + expect(usesTwelveHourClock('nl-NL')).toBe(false); + expect(usesTwelveHourClock('de-DE')).toBe(false); }); }); diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.ts index 9c302423ed..455afd6dc0 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.ts @@ -4,7 +4,7 @@ import { fromDate, getLocalTimeZone, isSameDay, isSameYear } from '@internationa * Configuration options for date and time formatting */ interface DateLabelFormatOptions { - /** Use 12-hour format with AM/PM (default: true) */ + /** Use 12-hour format with AM/PM (default: the user's locale) */ hour12?: boolean; /** Show relative labels like "Today" and "Yesterday" (default: true) */ includeRelative?: boolean; @@ -54,7 +54,7 @@ export function formatDate(value: Date): string { * }) */ export function formatDateLabel(date: Date, currentDate: Date = new Date(), options: DateLabelFormatOptions = {}): string { - const { hour12 = true, includeRelative = true, joiner = ' at ', month = 'long', timeZone } = options; + const { hour12, includeRelative = true, joiner = ' at ', month = 'long', timeZone } = options; const displayDate = fromDate(date, timeZone ?? getLocalTimeZone()); const displayCurrentDate = fromDate(currentDate, timeZone ?? getLocalTimeZone()); @@ -87,8 +87,8 @@ export function formatDateLabel(date: Date, currentDate: Date = new Date(), opti const timeOpts: Intl.DateTimeFormatOptions = { hour: 'numeric', - hour12, - ...(min > 0 || sec > 0 ? { minute: '2-digit' } : {}), + ...(hour12 === undefined ? {} : { hour12 }), + ...(min > 0 || sec > 0 || !(hour12 ?? usesTwelveHourClock()) ? { minute: '2-digit' } : {}), ...(sec > 0 ? { second: '2-digit' } : {}), ...(timeZone ? { timeZone } : {}) }; @@ -196,6 +196,15 @@ export function isSameUtcMonth(date: Date, other: Date = new Date()): boolean { return date.getUTCFullYear() === other.getUTCFullYear() && date.getUTCMonth() === other.getUTCMonth(); } +/** + * Whether the user's locale writes times on a 12-hour clock ("2 PM") rather than a 24-hour one ("14:00"). + * A bare hour reads well on a 12-hour clock, but a 24-hour time always needs its minutes. + */ +export function usesTwelveHourClock(locale?: string): boolean { + const hourCycle = new Intl.DateTimeFormat(locale, { hour: 'numeric' }).resolvedOptions().hourCycle; + return hourCycle === 'h11' || hourCycle === 'h12'; +} + function formatCompactDateTimeLabel(date: Date, currentDate: Date): string { const datePart = formatDatePart(date, currentDate); const timePart = formatTimePart(date, true); @@ -230,8 +239,7 @@ function formatTimePart(date: Date, omitSeconds: boolean): string { const opts: Intl.DateTimeFormatOptions = { hour: 'numeric', - hour12: true, - ...(min > 0 || (!omitSeconds && sec > 0) ? { minute: '2-digit' } : {}), + ...(min > 0 || (!omitSeconds && sec > 0) || !usesTwelveHourClock() ? { minute: '2-digit' } : {}), ...(!omitSeconds && sec > 0 ? { second: '2-digit' } : {}) }; diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/api.svelte.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/api.svelte.ts index 24a6277315..6cc3955a64 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/api.svelte.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/api.svelte.ts @@ -6,6 +6,7 @@ import type { WebSocketMessageValue } from '#features/websockets/models.ts'; import type { WorkInProgressResult } from '#shared/models/index.ts'; import { accessToken } from '#features/auth/index.svelte.ts'; +import { toIdPathSegments } from '#shared/api/urls.ts'; import type { Stack, StackStatus } from './models'; @@ -169,7 +170,9 @@ export function deleteMarkCritical(request: PostMarkCriticalRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async () => { const client = useFetchClient(); - await client.delete(`stacks/${request.route.ids?.join(',')}/mark-critical`); + for (const ids of toIdPathSegments(request.route.ids)) { + await client.delete(`stacks/${ids}/mark-critical`); + } }, mutationKey: queryKeys.deleteMarkCritical(request.route.ids), onError: () => { @@ -195,9 +198,15 @@ export function deleteStack(request: DeleteStackRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async () => { const client = useFetchClient(); - const response = await client.deleteJSON(`stacks/${request.route.ids?.join(',')}`); + const workers: string[] = []; + for (const ids of toIdPathSegments(request.route.ids)) { + const response = await client.deleteJSON(`stacks/${ids}`); + workers.push(...(response.data?.workers ?? [])); + } - return response.data!; + return { + workers + }; }, mutationKey: queryKeys.deleteStack(request.route.ids), onError: () => { @@ -285,11 +294,13 @@ export function postChangeStatus(request: PostChangeStatusRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async (status: StackStatus) => { const client = useFetchClient(); - await client.post(`stacks/${request.route.ids?.join(',')}/change-status`, undefined, { - params: { - status - } - }); + for (const ids of toIdPathSegments(request.route.ids)) { + await client.post(`stacks/${ids}/change-status`, undefined, { + params: { + status + } + }); + } }, mutationKey: queryKeys.postChangeStatus(request.route.ids), onError: () => { @@ -315,7 +326,9 @@ export function postMarkCritical(request: PostMarkCriticalRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async () => { const client = useFetchClient(); - await client.post(`stacks/${request.route.ids?.join(',')}/mark-critical`); + for (const ids of toIdPathSegments(request.route.ids)) { + await client.post(`stacks/${ids}/mark-critical`); + } }, mutationKey: queryKeys.postMarkCritical(request.route.ids), onError: () => { @@ -341,11 +354,13 @@ export function postMarkFixed(request: PostMarkFixedRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async (version?: string) => { const client = useFetchClient(); - await client.post(`stacks/${request.route.ids?.join(',')}/mark-fixed`, undefined, { - params: { - version - } - }); + for (const ids of toIdPathSegments(request.route.ids)) { + await client.post(`stacks/${ids}/mark-fixed`, undefined, { + params: { + version + } + }); + } }, mutationKey: queryKeys.postMarkFixed(request.route.ids), onError: () => { @@ -371,11 +386,13 @@ export function postMarkSnoozed(request: PostMarkSnoozedRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async (snoozeUntilUtc: Date) => { const client = useFetchClient(); - await client.post(`stacks/${request.route.ids?.join(',')}/mark-snoozed`, undefined, { - params: { - snoozeUntilUtc: snoozeUntilUtc.toISOString() - } - }); + for (const ids of toIdPathSegments(request.route.ids)) { + await client.post(`stacks/${ids}/mark-snoozed`, undefined, { + params: { + snoozeUntilUtc: snoozeUntilUtc.toISOString() + } + }); + } }, mutationKey: queryKeys.postMarkSnoozed(request.route.ids), onError: () => { diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stack-card.svelte b/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stack-card.svelte index ff5fdb8ab8..34cb24a99a 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stack-card.svelte +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stack-card.svelte @@ -34,7 +34,7 @@ import TagList from '#features/shared/components/tag-list.svelte'; import { fillDateSeries } from '#features/shared/utils/charts.ts'; import { getStackQuery } from '#features/stacks/api.svelte.ts'; - import { DEFAULT_OFFSET } from '#shared/api/api.svelte.ts'; + import { getDateHistogramTerm } from '#shared/api/api.svelte.ts'; import StackLogLevel from './stack-log-level.svelte'; import StackOptionsDropdownMenu from './stack-options-dropdown-menu.svelte'; @@ -91,7 +91,7 @@ // TODO: Add stack charts for Occurrences, Average Value, Value Sum const stackCountQuery = getStackCountQuery({ params: { - aggregations: `date:(date${DEFAULT_OFFSET ? '^' + DEFAULT_OFFSET : ''} cardinality:user sum:count~1) min:date max:date cardinality:user sum:count~1`, + aggregations: `date:(${getDateHistogramTerm()} cardinality:user sum:count~1) min:date max:date cardinality:user sum:count~1`, time: METRICS_TIME_RANGE }, route: { diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/+page.svelte index 3ad4c4d8ed..af5b92321f 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/+page.svelte @@ -73,7 +73,7 @@ import { parseDateMathRange } from '#features/shared/utils/datemath.ts'; import { StackStatus } from '#features/stacks/models.ts'; import { ChangeType, type WebSocketMessageValue } from '#features/websockets/models.ts'; - import { DEFAULT_OFFSET } from '#shared/api/api.svelte.ts'; + import { DEFAULT_OFFSET, getDateHistogramTerm } from '#shared/api/api.svelte.ts'; import { createQueryParameters } from '#shared/query-params/index.ts'; import { @@ -983,7 +983,7 @@ enabled: () => !isSavedViewRoutePending, params: { get aggregations() { - return `date:(date${DEFAULT_OFFSET ? `^${DEFAULT_OFFSET}` : ''} cardinality:stack sum:count~1) cardinality:stack terms:(first @include:true) sum:count~1`; + return `date:(${getDateHistogramTerm()} cardinality:stack sum:count~1) cardinality:stack terms:(first @include:true) sum:count~1`; }, get filter() { return eventsQueryParameters.filter; diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/[eventId=objectid]/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/[eventId=objectid]/+page.svelte index 71fce3adc9..853a06bfce 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/[eventId=objectid]/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/event/[eventId=objectid]/+page.svelte @@ -15,10 +15,10 @@ import { buildEventDetailsHref } from '#features/events/components/summary/index.ts'; import { organization } from '#features/organizations/context.svelte.ts'; - import { getEventsNavigationOptionsForFilter, redirectToEventsWithFilter } from '../../redirect-to-events.svelte.ts'; + import { getDetailsNavigationOptions, redirectToEventsWithFilter } from '../../redirect-to-events.svelte.ts'; async function filterChanged(addedOrUpdated: FacetedFilter.IFilter) { - await redirectToEventsWithFilter(organization.current, addedOrUpdated, getEventsNavigationOptionsForFilter(addedOrUpdated)); + await redirectToEventsWithFilter(organization.current, addedOrUpdated, getDetailsNavigationOptions()); } async function handleError(problem: ProblemDetails) { diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/project/[projectId]/stacks/[stackId]/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/project/[projectId]/stacks/[stackId]/+page.svelte index bddebf6492..bb318d873c 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/project/[projectId]/stacks/[stackId]/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/project/[projectId]/stacks/[stackId]/+page.svelte @@ -14,7 +14,7 @@ import { getStackQuery } from '#features/stacks/api.svelte.ts'; import StackDetails from '#features/stacks/components/stack-details.svelte'; - import { getEventsNavigationOptionsForFilter, redirectToEventsWithFilter } from '../../../../redirect-to-events.svelte.ts'; + import { getDetailsNavigationOptions, redirectToEventsWithFilter } from '../../../../redirect-to-events.svelte.ts'; const projectId = $derived(page.params.projectId || ''); const stackId = $derived(page.params.stackId || ''); @@ -40,7 +40,7 @@ }); async function filterChanged(addedOrUpdated: IFilter) { - await redirectToEventsWithFilter(organization.current, addedOrUpdated, getEventsNavigationOptionsForFilter(addedOrUpdated)); + await redirectToEventsWithFilter(organization.current, addedOrUpdated, getDetailsNavigationOptions()); } async function handleDeleted() { diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.test.ts b/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.test.ts index a4516aa383..16f9cb1250 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.test.ts @@ -99,6 +99,18 @@ describe('redirect-to-events', () => { expect(url.searchParams.has('filters')).toBe(false); }); + it('searches all time for drilldowns from a details page', async () => { + // Arrange + const { ALL_TIME_QUERY_VALUE, buildListPageHref, getDetailsNavigationOptions } = await import('./redirect-to-events.svelte'); + + // Act + const href = buildListPageHref('events', 'org-1', [new StringFilter('error.code', '500')], getDetailsNavigationOptions()); + const url = new URL(href, 'https://example.test'); + + // Assert + expect(url.searchParams.get('time')).toBe(ALL_TIME_QUERY_VALUE); + }); + it('uses relative duration shortcuts for time query parameters', async () => { // Arrange const { buildListPageHref, deserializeTimeQueryParam } = await import('./redirect-to-events.svelte'); diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.ts b/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.ts index 62b7ca77a1..ff851d0ea9 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.ts +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/redirect-to-events.svelte.ts @@ -103,6 +103,16 @@ export function deserializeTimeQueryParam(time: string): string { return trimmed; } +/** + * Drilldowns from a stack or event details page have no time range of their own, and the event they come from can be older + * than the list's default range. Search all time so the destination always includes the event the value came from. + */ +export function getDetailsNavigationOptions(): ListNavigationOptions { + return { + time: null + }; +} + /** * Stack filter drilldowns mean "show every event for this stack". * Clear any active date range so the destination cannot hide older stack events. diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/sessions/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/sessions/+page.svelte index d7bc404527..3289218985 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/sessions/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/sessions/+page.svelte @@ -60,7 +60,7 @@ import { fillDateSeries } from '#features/shared/utils/charts.ts'; import { parseDateMathRange, toDateMathRange } from '#features/shared/utils/datemath.ts'; import { ChangeType, type WebSocketMessageValue } from '#features/websockets/models.ts'; - import { DEFAULT_OFFSET } from '#shared/api/api.svelte.ts'; + import { DEFAULT_OFFSET, getDateHistogramTerm } from '#shared/api/api.svelte.ts'; import { createQueryParameters } from '#shared/query-params/index.ts'; import { @@ -859,7 +859,7 @@ enabled: () => hasPremiumFeatures && !isSavedViewRoutePending, params: { get aggregations() { - return `avg:value cardinality:user date:(date${DEFAULT_OFFSET ? `^${DEFAULT_OFFSET}` : ''} cardinality:user)`; + return `avg:value cardinality:user date:(${getDateHistogramTerm()} cardinality:user)`; }, get filter() { return eventsQueryParameters.filter; diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/+page.svelte index 7efab475c4..93b4eb805e 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/+page.svelte @@ -72,7 +72,7 @@ import TableStacksBulkActionsDropdownMenu from '#features/stacks/components/stacks-bulk-actions-dropdown-menu.svelte'; import { StackStatus } from '#features/stacks/models.ts'; import { ChangeType, type WebSocketMessageValue } from '#features/websockets/models.ts'; - import { DEFAULT_OFFSET } from '#shared/api/api.svelte.ts'; + import { DEFAULT_OFFSET, getDateHistogramTerm } from '#shared/api/api.svelte.ts'; import { createQueryParameters } from '#shared/query-params/index.ts'; import { @@ -879,7 +879,7 @@ enabled: () => !isSavedViewRoutePending, params: { get aggregations() { - return `date:(date${DEFAULT_OFFSET ? `^${DEFAULT_OFFSET}` : ''} cardinality:stack sum:count~1) cardinality:stack terms:(first @include:true) sum:count~1`; + return `date:(${getDateHistogramTerm()} cardinality:stack sum:count~1) cardinality:stack terms:(first @include:true) sum:count~1`; }, get filter() { return eventsQueryParameters.filter; diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/+page.svelte index c7287d9cb0..111f252c08 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/+page.svelte @@ -16,12 +16,12 @@ import { organization } from '#features/organizations/context.svelte.ts'; import StackDetails from '#features/stacks/components/stack-details.svelte'; - import { getEventsNavigationOptionsForFilter, redirectToEventsWithFilter } from '../../redirect-to-events.svelte.ts'; + import { getDetailsNavigationOptions, redirectToEventsWithFilter } from '../../redirect-to-events.svelte.ts'; const stackId = $derived(page.params.stackId || ''); async function filterChanged(addedOrUpdated: IFilter) { - await redirectToEventsWithFilter(organization.current, addedOrUpdated, getEventsNavigationOptionsForFilter(addedOrUpdated)); + await redirectToEventsWithFilter(organization.current, addedOrUpdated, getDetailsNavigationOptions()); } async function handleDeleted() { diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/[action=stackaction]/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/[action=stackaction]/+page.svelte index fd083a2c84..c5587aef07 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/[action=stackaction]/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/[action=stackaction]/+page.svelte @@ -6,12 +6,12 @@ import type { PageProps } from './$types'; - import { getEventsNavigationOptionsForFilter, redirectToEventsWithFilter } from '../../../redirect-to-events.svelte.ts'; + import { getDetailsNavigationOptions, redirectToEventsWithFilter } from '../../../redirect-to-events.svelte.ts'; let { params }: PageProps = $props(); async function filterChanged(filter: IFilter) { - await redirectToEventsWithFilter(organization.current, filter, getEventsNavigationOptionsForFilter(filter)); + await redirectToEventsWithFilter(organization.current, filter, getDetailsNavigationOptions()); } diff --git a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/event/[eventId=objectid]/+page.svelte b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/event/[eventId=objectid]/+page.svelte index be0bb96c3c..a8943fc091 100644 --- a/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/event/[eventId=objectid]/+page.svelte +++ b/src/Exceptionless.Web/ClientApp/src/routes/(app)/stack/[stackId=objectid]/event/[eventId=objectid]/+page.svelte @@ -15,13 +15,13 @@ import { organization } from '#features/organizations/context.svelte.ts'; import StackDetails from '#features/stacks/components/stack-details.svelte'; - import { getEventsNavigationOptionsForFilter, redirectToEventsWithFilter } from '../../../../redirect-to-events.svelte.ts'; + import { getDetailsNavigationOptions, redirectToEventsWithFilter } from '../../../../redirect-to-events.svelte.ts'; const stackId = $derived(page.params.stackId || ''); const eventId = $derived(page.params.eventId || ''); async function filterChanged(addedOrUpdated: IFilter) { - await redirectToEventsWithFilter(organization.current, addedOrUpdated, getEventsNavigationOptionsForFilter(addedOrUpdated)); + await redirectToEventsWithFilter(organization.current, addedOrUpdated, getDetailsNavigationOptions()); } async function handleDeleted() { diff --git a/tests/Exceptionless.Tests/Search/PersistentEventQueryValidatorTests.cs b/tests/Exceptionless.Tests/Search/PersistentEventQueryValidatorTests.cs index 5323532380..64c9c815c5 100644 --- a/tests/Exceptionless.Tests/Search/PersistentEventQueryValidatorTests.cs +++ b/tests/Exceptionless.Tests/Search/PersistentEventQueryValidatorTests.cs @@ -130,6 +130,8 @@ public async Task CanProcessQueryAsync(string query, string expected, bool isVal [InlineData("date:(date cardinality:stack sum:count~1) cardinality:stack terms:(first @include:true) sum:count~1", true, false)] // dashboards [InlineData("date:(date cardinality:user sum:value avg:value sum:count~1) min:date max:date cardinality:user sum:count~1", true, false)] // stack dashboard [InlineData("avg:value cardinality:user date:(date cardinality:user)", true, false)] // session dashboard + [InlineData("date:(date^Europe/Amsterdam cardinality:stack sum:count~1) cardinality:stack terms:(first @include:true) sum:count~1", true, false)] // dashboards bucketed in a time zone + [InlineData("date:(date^America/Argentina/Buenos_Aires cardinality:user)", true, false)] [InlineData("date:(date~month terms:(project cardinality:stack terms:(first @include:true)) cardinality:stack terms:(first @include:true))", true, true)] // Breakdown of total events, new events and unique events per month by project public async Task CanProcessAggregationsAsync(string? query, bool isValid, bool usesPremiumFeatures) { diff --git a/tests/Exceptionless.Tests/Stats/AggregationTests.cs b/tests/Exceptionless.Tests/Stats/AggregationTests.cs index 1cba629e64..0be877a20c 100644 --- a/tests/Exceptionless.Tests/Stats/AggregationTests.cs +++ b/tests/Exceptionless.Tests/Stats/AggregationTests.cs @@ -82,6 +82,27 @@ public async Task CanGetDateHistogramWithCardinalityAggregationsAsync() } } + [Fact] + public async Task CanGetDateHistogramInTimeZoneAsync() + { + const int eventCount = 100; + await CreateDataAsync(eventCount, false); + + // A time zone name keeps every day bucket on local midnight, including across daylight saving changes. + var result = await _eventRepository.CountAsync(q => q.Project(TestConstants.ProjectId).AggregationsExpression("date:(date~1d^Europe/Amsterdam cardinality:id)")); + var dateHistogram = result.Aggregations.DateHistogram("date_date"); + Assert.NotNull(dateHistogram); + Assert.NotEmpty(dateHistogram.Buckets); + Assert.Equal(eventCount, dateHistogram.Buckets.Sum(t => t.Total)); + + var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Amsterdam"); + Assert.All(dateHistogram.Buckets, bucket => + { + var local = TimeZoneInfo.ConvertTime(new DateTimeOffset(bucket.Date, TimeSpan.Zero), timeZone); + Assert.Equal(TimeSpan.Zero, local.TimeOfDay); + }); + } + [Fact] public async Task CanGetExcludedTermsAggregationsAsync() { From a460aeb6bd19b4768cd11db29e6a0aa72cc28cd7 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Mon, 30 Nov 2026 11:25:49 -0600 Subject: [PATCH 2/3] Add Arrange/Act/Assert sections to new tests Co-Authored-By: Claude Opus 5.5 --- .../src/lib/features/shared/api/urls.test.ts | 13 +++++++++++-- .../ClientApp/src/lib/features/shared/dates.test.ts | 11 ++++++++--- tests/Exceptionless.Tests/Stats/AggregationTests.cs | 7 +++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts index 38eed1a7bc..58739238ac 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/api/urls.test.ts @@ -37,11 +37,14 @@ describe('API hosting URLs', () => { describe('toIdPathSegments', () => { it('batches ids so each path segment stays short enough for strict hosts', async () => { + // Arrange const { toIdPathSegments } = await import('./urls'); const ids = Array.from({ length: 12 }, (_, index) => index.toString(16).padStart(24, '0')); + // Act const segments = toIdPathSegments(ids); + // Assert expect(segments).toHaveLength(2); expect(segments[0]!.split(',')).toEqual(ids.slice(0, 10)); expect(segments[1]!.split(',')).toEqual(ids.slice(10)); @@ -49,9 +52,15 @@ describe('toIdPathSegments', () => { }); it('returns no segments for no ids', async () => { + // Arrange const { toIdPathSegments } = await import('./urls'); - expect(toIdPathSegments(undefined)).toEqual([]); - expect(toIdPathSegments([])).toEqual([]); + // Act + const fromUndefined = toIdPathSegments(undefined); + const fromEmpty = toIdPathSegments([]); + + // Assert + expect(fromUndefined).toEqual([]); + expect(fromEmpty).toEqual([]); }); }); diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts index 828f9c4198..f931914d90 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/shared/dates.test.ts @@ -55,9 +55,14 @@ describe('formatDateLabel', () => { describe('usesTwelveHourClock', () => { it('follows the locale instead of always using AM/PM', () => { - expect(usesTwelveHourClock('en-US')).toBe(true); - expect(usesTwelveHourClock('nl-NL')).toBe(false); - expect(usesTwelveHourClock('de-DE')).toBe(false); + // Arrange + const locales = ['en-US', 'nl-NL', 'de-DE']; + + // Act + const results = locales.map((locale) => usesTwelveHourClock(locale)); + + // Assert + expect(results).toEqual([true, false, false]); }); }); diff --git a/tests/Exceptionless.Tests/Stats/AggregationTests.cs b/tests/Exceptionless.Tests/Stats/AggregationTests.cs index 0be877a20c..182c3119d9 100644 --- a/tests/Exceptionless.Tests/Stats/AggregationTests.cs +++ b/tests/Exceptionless.Tests/Stats/AggregationTests.cs @@ -85,17 +85,20 @@ public async Task CanGetDateHistogramWithCardinalityAggregationsAsync() [Fact] public async Task CanGetDateHistogramInTimeZoneAsync() { + // Arrange const int eventCount = 100; await CreateDataAsync(eventCount, false); + var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Amsterdam"); + // Act // A time zone name keeps every day bucket on local midnight, including across daylight saving changes. var result = await _eventRepository.CountAsync(q => q.Project(TestConstants.ProjectId).AggregationsExpression("date:(date~1d^Europe/Amsterdam cardinality:id)")); + + // Assert var dateHistogram = result.Aggregations.DateHistogram("date_date"); Assert.NotNull(dateHistogram); Assert.NotEmpty(dateHistogram.Buckets); Assert.Equal(eventCount, dateHistogram.Buckets.Sum(t => t.Total)); - - var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Amsterdam"); Assert.All(dateHistogram.Buckets, bucket => { var local = TimeZoneInfo.ConvertTime(new DateTimeOffset(bucket.Date, TimeSpan.Zero), timeZone); From 714d63b272ea1c6f1445e631cca9e5a3b7808078 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Mon, 30 Nov 2026 11:28:31 -0600 Subject: [PATCH 3/3] Run selected-row bulk actions as background tasks Selected stacks and events now go through POST bulk-operations with an ids selection (ids in the body, up to 1000) instead of batching comma-joined ids into URL paths. Single-stack actions keep their direct endpoints. Co-Authored-By: Claude Opus 5.5 --- .../src/lib/features/events/api.svelte.ts | 11 +- .../events-bulk-actions-dropdown-menu.svelte | 92 +++--- ...-bulk-actions-dropdown-menu.svelte.test.ts | 22 +- .../src/lib/features/shared/api/urls.test.ts | 30 -- .../src/lib/features/shared/api/urls.ts | 20 -- .../src/lib/features/stacks/api.svelte.ts | 55 ++-- .../stacks-bulk-actions-dropdown-menu.svelte | 282 ++++++------------ ...-bulk-actions-dropdown-menu.svelte.test.ts | 36 ++- 8 files changed, 181 insertions(+), 367 deletions(-) diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts index 8550a3ee3c..1b6c1d4554 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/events/api.svelte.ts @@ -8,7 +8,6 @@ import type { CountResult, WorkInProgressResult } from '#shared/models/index.ts' import { accessToken } from '#features/auth/index.svelte.ts'; import { queryKeys as stackQueryKeys } from '#features/stacks/api.svelte.ts'; import { DEFAULT_OFFSET } from '#shared/api/api.svelte.ts'; -import { toIdPathSegments } from '#shared/api/urls.ts'; import type { EventSummaryModel, SummaryTemplateKeys } from './components/summary/index'; import type { PersistentEvent } from './models'; @@ -352,15 +351,9 @@ export function deleteEvent(request: DeleteEventsRequest) { enabled: () => !!accessToken.current && !!request.route.ids?.length, mutationFn: async () => { const client = useFetchClient(); - const workers: string[] = []; - for (const ids of toIdPathSegments(request.route.ids)) { - const response = await client.deleteJSON(`events/${ids}`); - workers.push(...(response.data?.workers ?? [])); - } + const response = await client.deleteJSON(`events/${request.route.ids?.join(',')}`); - return { - workers - }; + return response.data!; }, mutationKey: queryKeys.deleteEvent(request.route.ids), onError: () => { diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/events-bulk-actions-dropdown-menu.svelte b/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/events-bulk-actions-dropdown-menu.svelte index 20ae96d5d5..b23c0ceef0 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/events-bulk-actions-dropdown-menu.svelte +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/events/components/table/events-bulk-actions-dropdown-menu.svelte @@ -3,8 +3,6 @@ open, setOpen}> diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stacks-bulk-actions-dropdown-menu.svelte.test.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stacks-bulk-actions-dropdown-menu.svelte.test.ts index ca1d5687ac..d5d559a200 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stacks-bulk-actions-dropdown-menu.svelte.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/stacks/components/stacks-bulk-actions-dropdown-menu.svelte.test.ts @@ -3,17 +3,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; const startBulk = vi.hoisted(() => vi.fn()); const toast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn() })); -const mutations = vi.hoisted(() => ({ changeStatus: vi.fn(), delete: vi.fn(), markFixed: vi.fn(), snooze: vi.fn() })); vi.mock('svelte-sonner', () => ({ toast })); vi.mock('#features/tasks/api.svelte.ts', () => ({ postBulkOperation: () => ({ mutateAsync: startBulk }) })); - -vi.mock('../api.svelte', () => ({ - deleteStack: vi.fn(() => ({ mutateAsync: mutations.delete })), - postChangeStatus: vi.fn(() => ({ mutateAsync: mutations.changeStatus })), - postMarkFixed: vi.fn(() => ({ mutateAsync: mutations.markFixed })), - postMarkSnoozed: vi.fn(() => ({ mutateAsync: mutations.snooze })) -})); +vi.mock('#features/organizations/context.svelte.ts', () => ({ organization: { current: 'current-organization-id' } })); import { BulkOperationSelectionKind } from '#features/tasks/models.ts'; @@ -40,7 +33,6 @@ describe('StacksBulkActionsDropdownMenu', () => { startBulk.mockResolvedValue(undefined); toast.error.mockClear(); toast.success.mockClear(); - Object.values(mutations).forEach((m) => m.mockReset()); }); afterEach(async () => { @@ -81,17 +73,30 @@ describe('StacksBulkActionsDropdownMenu', () => { expect(trigger.title).toBe('Actions'); }); - it('changes the selected stacks through the per-id endpoint when all matching is not active', async () => { + it('starts a background task for the selected stack ids without confirming', async () => { // Arrange - const table = { getSelectedRowModel: () => ({ flatRows: [{ id: 'a' }] }), resetRowSelection: vi.fn() } as never; - render(StacksBulkActionsDropdownMenu, { props: { table } }); + const ids = Array.from({ length: 12 }, (_, index) => `stack-${index}`); + const resetRowSelection = vi.fn(); + const onAllMatchingStarted = vi.fn(); + const table = { getSelectedRowModel: () => ({ flatRows: ids.map((id) => ({ id })) }), resetRowSelection } as never; + render(StacksBulkActionsDropdownMenu, { props: { onAllMatchingStarted, table } }); // Act - await choose('Mark Open'); + await choose('Mark Ignored'); // Assert - await waitFor(() => expect(mutations.changeStatus).toHaveBeenCalledWith('open')); - expect(startBulk).not.toHaveBeenCalled(); + await waitFor(() => + expect(startBulk).toHaveBeenCalledWith({ + organization_id: 'current-organization-id', + parameters: { status: 'ignored' }, + selection: { ids, kind: BulkOperationSelectionKind.Ids }, + type: 'stacks.change-status' + }) + ); + expect(screen.queryByRole('alertdialog')).toBeNull(); + expect(resetRowSelection).toHaveBeenCalledOnce(); + expect(onAllMatchingStarted).not.toHaveBeenCalled(); + expect(toast.success).toHaveBeenCalledWith('Marking 12 stacks as ignored. Progress is shown at the bottom of the page.'); }); it.each([ @@ -111,7 +116,6 @@ describe('StacksBulkActionsDropdownMenu', () => { await waitFor(() => expect(startBulk).toHaveBeenCalledWith({ organization_id: 'organization-id', parameters, selection, type })); expect(onAllMatchingStarted).toHaveBeenCalledOnce(); expect(resetRowSelection).toHaveBeenCalledOnce(); - expect(mutations.changeStatus).not.toHaveBeenCalled(); }); it('only opens the snooze durations when the submenu is opened with the keyboard', async () => {