Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 111 additions & 2 deletions src/Exceptionless.Web/ClientApp/e2e/tests/session-investigation.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
import { createReferenceId, expect, test } from '../fixtures/e2e-test';
import { getVisibleRow, getVisibleText } from '../support/page-helpers';
import { createSessionEvent } from '../support/synthetic-event';
import { createRepresentativeEvent, createSessionEvent } from '../support/synthetic-event';

test('operator can find and inspect a user session', async ({ e2eApi, e2eScenario, page }) => {
test('operator can find and inspect a user session', async ({ e2eApi, e2eScenario, page, request }) => {
const sessionId = createReferenceId(e2eScenario.run, '-session');
const eventReferenceId = createReferenceId(e2eScenario.run, '-session-error');
const identity = `session-${e2eScenario.run}@exceptionless.test`;
const name = `Session User ${e2eScenario.run}`;
const longMessage = Array.from({ length: 42 }, (_, index) => `session-processing-failure-${String(index + 1).padStart(2, '0')}`).join(' ');
let relatedEventId = '';
let relatedStackId = '';

await test.step('seed a representative session', async () => {
const savedViewResponse = await request.post(`/api/v2/organizations/${e2eScenario.organizationId}/saved-views`, {
data: {
columns: {
date: { position: 1, visible: true },
summary: { position: 0, visible: true, wrap: true }
},
name: 'All',
organization_id: e2eScenario.organizationId,
slug: 'all',
view_type: 'events'
},
headers: { Authorization: `Bearer ${e2eScenario.userToken}` }
});
expect(savedViewResponse.status(), await savedViewResponse.text()).toBe(201);

await e2eApi.submitEvent(e2eScenario.projectId, e2eScenario.projectToken, createSessionEvent({ identity, name, sessionId }));
await e2eApi.pollForEventByReference(e2eScenario.userToken, e2eScenario.projectId, sessionId);

const relatedEvent = createRepresentativeEvent({
appUrl: e2eApi.environment.appUrl,
message: longMessage,
referenceId: eventReferenceId,
runId: e2eApi.environment.runId
});
relatedEvent.data = {
...(relatedEvent.data as Record<string, unknown>),
'@environment': {
ip_address: '10.42.0.25',
machine_name: 'session-worker-07',
process_name: 'Exceptionless.Worker'
},
'@ref:session': sessionId,
'@user': {
identity,
name
}
};

await e2eApi.submitEvent(e2eScenario.projectId, e2eScenario.projectToken, relatedEvent);
const persistedRelatedEvent = await e2eApi.pollForEventByReference(e2eScenario.userToken, e2eScenario.projectId, eventReferenceId);
expect(persistedRelatedEvent.stack_id).toBeTruthy();
relatedEventId = persistedRelatedEvent.id;
relatedStackId = persistedRelatedEvent.stack_id!;
});

await test.step('open the session from the Sessions table', async () => {
Expand All @@ -28,4 +73,68 @@ test('operator can find and inspect a user session', async ({ e2eApi, e2eScenari
await expect(page).toHaveURL(/\/next\/(?:event|stack\/[^/]+\/event)\//);
await expect(getVisibleText(page, identity)).toBeVisible();
});

await test.step('session events wrap summaries, show users, and open with the Events All view', async () => {
await page.getByRole('tab', { name: 'Session Events' }).click();
await expect(page.getByRole('tab', { name: 'Session Events' })).toHaveAttribute('aria-selected', 'true');
const summaryHeader = page.getByRole('columnheader', { name: 'Summary' });
await expect(summaryHeader).toBeVisible({ timeout: 30_000 });

const sessionEventsTable = summaryHeader.locator('xpath=ancestor::div[@data-slot="table-container"]');
await expect(sessionEventsTable.getByRole('columnheader')).toHaveText(['Summary', 'User', 'Session Time']);
await expect(sessionEventsTable.getByTitle(`${name} (${identity})`).first()).toBeVisible();
const summaryCell = sessionEventsTable.getByRole('cell').first();
await expect(summaryCell).toHaveCSS('overflow-wrap', 'anywhere');
await expect(summaryCell).toHaveCSS('white-space', 'normal');
await expect.poll(() => sessionEventsTable.evaluate((element) => element.scrollWidth / element.offsetWidth)).toBeLessThanOrEqual(1.02);

const eventsLink = page.getByRole('link', { name: 'Open events filtered to this session' });
await expect(eventsLink).toHaveAttribute('href', /\/next\/event\/all\?/);
const eventsHref = await eventsLink.getAttribute('href');
const eventsUrl = new URL(eventsHref!, page.url());
expect(eventsUrl.searchParams.get('session')).toBe(sessionId);
expect(eventsUrl.searchParams.get('filter')).toBe('');
expect(eventsUrl.searchParams.get('type')).toBe('');
expect(eventsUrl.searchParams.get('time')).toBe('all');
});

await test.step('event detail messages wrap and small alignment fixes render consistently', async () => {
await page.goto(`/next/stack/${relatedStackId}/event/${relatedEventId}`);
await expect(page.getByRole('tab', { name: 'Overview' })).toHaveAttribute('aria-selected', 'true');

const activePanel = () => page.getByRole('tabpanel').filter({ visible: true });
const activeTable = () => activePanel().locator('[data-slot="table-container"]').first();
const expectWrappedMessageWithoutMeaningfulOverflow = async () => {
const messageCell = activePanel().getByRole('row').filter({ hasText: 'Message' }).first().locator('[data-slot="table-cell"]').last();
await expect(messageCell).toHaveCSS('overflow-wrap', 'anywhere');
await expect(messageCell).toHaveCSS('white-space', 'normal');
await expect.poll(() => activeTable().evaluate((element) => element.scrollWidth / element.offsetWidth)).toBeLessThanOrEqual(1.05);
};

await expectWrappedMessageWithoutMeaningfulOverflow();
await page.getByRole('tab', { name: 'Exception' }).click();
await expectWrappedMessageWithoutMeaningfulOverflow();

await page.getByRole('tab', { name: 'Environment' }).click();
const machineNameRow = activePanel().getByRole('row').filter({ hasText: 'Machine Name' });
await expect(machineNameRow).toBeVisible();
await expect
.poll(() =>
machineNameRow
.locator('[data-slot="table-cell"]')
.last()
.evaluate((element) => getComputedStyle(element).display)
)
.toBe('table-cell');

await page.getByRole('button', { name: 'Stack options' }).click();
const stackingInformationItem = page.getByRole('menuitem', { name: 'View Stacking Information' });
await expect(stackingInformationItem).toBeVisible();
await expect.poll(() => stackingInformationItem.locator('svg').evaluate((element) => getComputedStyle(element).marginRight)).toBe('8px');
await page.keyboard.press('Escape');

const sidebarRail = page.locator('[data-slot="sidebar-rail"]');
await expect(sidebarRail).toBeVisible();
await expect.poll(() => sidebarRail.evaluate((element) => getComputedStyle(element).cursor)).toBe('pointer');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<Table.Cell class="w-4 pr-0"
><EventsFacetedFilter.StringTrigger changed={filterChanged} term="machine" value={environment.machine_name} /></Table.Cell
>
<Table.Cell class="flex items-center">{environment.machine_name}</Table.Cell>
<Table.Cell>{environment.machine_name}</Table.Cell>
</Table.Row>
{/if}
{#if environment.ip_address}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<Table.Row class="group">
<Table.Head class="w-40 font-semibold whitespace-nowrap">Message</Table.Head>
<Table.Cell class="w-4 pr-0"><EventsFacetedFilter.StringTrigger changed={filterChanged} term="error.message" value={message} /></Table.Cell>
<Table.Cell>{message}</Table.Cell>
<Table.Cell class="wrap-anywhere whitespace-normal">{message}</Table.Cell>
</Table.Row>
{/if}
{#if code}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<Table.Row class="group">
<Table.Head class="w-40 font-semibold whitespace-nowrap">Message</Table.Head>
<Table.Cell class="w-4 pr-0"><EventsFacetedFilter.StringTrigger changed={filterChanged} term="message" value={message} /></Table.Cell>
<Table.Cell>{message}</Table.Cell>
<Table.Cell class="wrap-anywhere whitespace-normal">{message}</Table.Cell>
</Table.Row>
{/if}
{#if version}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import type { SavedView } from '$features/saved-views/models';

import { describe, expect, it } from 'vitest';

import { getSessionEventsHref, getSessionEventsPath } from './session-events-navigation';

function createSavedView(overrides: Partial<SavedView> = {}): SavedView {
return {
created_by_user_id: 'user-id',
created_utc: '2026-08-29T00:00:00Z',
id: 'saved-view-id',
name: 'All',
organization_id: 'organization-id',
predefined_key: 'events:all',
slug: 'all',
updated_utc: '2026-08-29T00:00:00Z',
version: 1,
view_type: 'events',
...overrides
};
}

describe('getSessionEventsPath', () => {
it('waits for saved views before enabling navigation', () => {
expect(getSessionEventsPath(undefined, true)).toBeUndefined();
});

it('uses the Events All saved view when it exists', () => {
expect(getSessionEventsPath([createSavedView()])).toBe('/next/event/all');
});

it('uses the immutable predefined key after the Events All view is renamed', () => {
expect(getSessionEventsPath([createSavedView({ name: 'Everything', slug: 'everything' })])).toBe('/next/event/everything');
});

it('prefers the shared All view when a private view already owns the all slug', () => {
const privateAll = createSavedView({ id: 'private-all', user_id: 'user-id' });
const sharedAll = createSavedView({ id: 'shared-all', slug: 'all-2' });

expect(getSessionEventsPath([privateAll, sharedAll])).toBe('/next/event/all-2');
});

it('does not use a private All view when no shared All view exists', () => {
expect(getSessionEventsPath([createSavedView({ user_id: 'user-id' })])).toBe('/next/event');
});

it('falls back to the generic Events route when All is unavailable', () => {
expect(getSessionEventsPath([createSavedView({ name: 'Errors', predefined_key: 'events:errors', slug: 'errors' })])).toBe('/next/event');
});

it('does not mistake an unrelated all-N slug for the All view', () => {
expect(getSessionEventsPath([createSavedView({ name: 'Everything', predefined_key: undefined, slug: 'all-2' })])).toBe('/next/event');
});

it('supports a legacy unkeyed shared All view', () => {
expect(getSessionEventsPath([createSavedView({ predefined_key: undefined })])).toBe('/next/event/all');
});

it('does not use a differently keyed view that was renamed to All', () => {
expect(getSessionEventsPath([createSavedView({ predefined_key: 'events:errors' })])).toBe('/next/event');
});

it('does not use an All view belonging to another resource', () => {
expect(getSessionEventsPath([createSavedView({ view_type: 'stacks' })])).toBe('/next/event');
});
});

describe('getSessionEventsHref', () => {
it('keeps the saved view path while replacing every saved filter with the session', () => {
const href = getSessionEventsHref('/next/event/all-2', 'session-id');
const url = new URL(href!, 'https://example.test');

expect(url.pathname).toBe('/next/event/all-2');
expect(Object.fromEntries(url.searchParams)).toEqual({
bot: '',
filter: '',
first: '',
level: '',
project: '',
reference: '',
session: 'session-id',
stack: '',
status: '',
tag: '',
time: 'all',
type: '',
version: ''
});
});

it('does not enable navigation without both a path and session id', () => {
expect(getSessionEventsHref(undefined, 'session-id')).toBeUndefined();
expect(getSessionEventsHref('/next/event', undefined)).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { SavedView } from '$features/saved-views/models';

import { resolve } from '$app/paths';
import { savedViewHref } from '$features/saved-views/slugs';

const RESET_FILTER_QUERY_PARAMS = ['bot', 'filter', 'first', 'level', 'project', 'reference', 'stack', 'status', 'tag', 'type', 'version'] as const;
const EVENTS_ALL_PREDEFINED_KEY = 'events:all';

export function getSessionEventsHref(eventsPath: string | undefined, sessionId: string | undefined): string | undefined {
if (!eventsPath || !sessionId) {
return undefined;
}

const query = new URLSearchParams({ session: sessionId, time: 'all' });
for (const name of RESET_FILTER_QUERY_PARAMS) {
query.set(name, '');
}

return `${eventsPath}?${query.toString()}`;
}

export function getSessionEventsPath(savedViews: SavedView[] | undefined, isPending = false): string | undefined {
if (isPending) {
return undefined;
}

const sharedEventViews = (savedViews ?? []).filter((savedView) => savedView.view_type === 'events' && !savedView.user_id);
const allEventsView =
sharedEventViews.find((savedView) => savedView.predefined_key?.trim().toLowerCase() === EVENTS_ALL_PREDEFINED_KEY) ??
sharedEventViews.find((savedView) => !savedView.predefined_key && savedView.name.trim().toLowerCase() === 'all');

return allEventsView ? savedViewHref(allEventsView) : resolve('/(app)/event');
}
Loading
Loading