diff --git a/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.test.ts b/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.test.ts new file mode 100644 index 0000000000000..ae854da7b1330 --- /dev/null +++ b/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.test.ts @@ -0,0 +1,182 @@ +import { filterInspectorListItems } from 'scenes/session-recordings/player/inspector/inspectorListFiltering' +import { + InspectorListBrowserVisibility, + InspectorListItemDoctor, + InspectorListItemEvent, + InspectorListOfflineStatusChange, +} from 'scenes/session-recordings/player/inspector/playerInspectorLogic' +import { SharedListMiniFilter } from 'scenes/session-recordings/player/playerSettingsLogic' + +import { PerformanceEvent, SessionRecordingPlayerTab } from '~/types' + +describe('filtering inspector list items', () => { + describe('the all tab', () => { + it('includes browser visibility', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: 'browser-visibility', + } as InspectorListBrowserVisibility, + ], + tab: SessionRecordingPlayerTab.ALL, + miniFiltersByKey: { 'all-everything': { enabled: true } as unknown as SharedListMiniFilter }, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + ).toHaveLength(1) + }) + + it('hides doctor items in everything mode', () => { + const filteredItems = filterInspectorListItems({ + allItems: [ + { + type: 'browser-visibility', + } as InspectorListBrowserVisibility, + { + type: 'doctor', + } as InspectorListItemDoctor, + ], + tab: SessionRecordingPlayerTab.ALL, + miniFiltersByKey: { 'all-everything': { enabled: true } as unknown as SharedListMiniFilter }, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + expect(filteredItems.map((item) => item.type)).toEqual(['browser-visibility']) + }) + }) + + describe('the events tab', () => { + it('filters by window id', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: SessionRecordingPlayerTab.EVENTS, + windowId: 'this window', + data: { event: '$exception' } as unknown as PerformanceEvent, + } as unknown as InspectorListItemEvent, + { + type: SessionRecordingPlayerTab.EVENTS, + windowId: 'a different window', + data: { event: '$exception' } as unknown as PerformanceEvent, + } as unknown as InspectorListItemEvent, + ], + tab: SessionRecordingPlayerTab.EVENTS, + miniFiltersByKey: { 'events-all': { enabled: true } as unknown as SharedListMiniFilter }, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: 'a different window', + }) + ).toHaveLength(1) + }) + + it('excludes browser visibility on console filter', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: 'browser-visibility', + } as InspectorListBrowserVisibility, + ], + tab: SessionRecordingPlayerTab.EVENTS, + miniFiltersByKey: { 'all-everything': { enabled: false } as unknown as SharedListMiniFilter }, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + ).toHaveLength(0) + }) + + it('excludes browser visibility when show only matching', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: 'browser-visibility', + } as InspectorListBrowserVisibility, + ], + tab: SessionRecordingPlayerTab.EVENTS, + miniFiltersByKey: { 'all-everything': { enabled: true } as unknown as SharedListMiniFilter }, + showOnlyMatching: true, + showMatchingEventsFilter: true, + windowIdFilter: null, + }) + ).toHaveLength(0) + }) + }) + + describe('the doctor tab', () => { + it('ignores events that are not exceptions', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: SessionRecordingPlayerTab.EVENTS, + data: { event: 'an event' } as unknown as PerformanceEvent, + } as unknown as InspectorListItemEvent, + ], + tab: SessionRecordingPlayerTab.DOCTOR, + miniFiltersByKey: {}, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + ).toHaveLength(0) + }) + + it('includes events that are exceptions', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: SessionRecordingPlayerTab.EVENTS, + data: { event: '$exception' } as unknown as PerformanceEvent, + } as unknown as InspectorListItemEvent, + ], + tab: SessionRecordingPlayerTab.DOCTOR, + miniFiltersByKey: {}, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + ).toHaveLength(1) + }) + + it('includes browser offline status', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: 'offline-status', + } as unknown as InspectorListOfflineStatusChange, + ], + tab: SessionRecordingPlayerTab.DOCTOR, + miniFiltersByKey: {}, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + ).toHaveLength(1) + }) + + it('includes browser visibility status', () => { + expect( + filterInspectorListItems({ + allItems: [ + { + type: 'browser-visibility', + } as InspectorListBrowserVisibility, + ], + tab: SessionRecordingPlayerTab.DOCTOR, + miniFiltersByKey: {}, + showOnlyMatching: false, + showMatchingEventsFilter: false, + windowIdFilter: null, + }) + ).toHaveLength(1) + }) + }) +}) diff --git a/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.ts b/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.ts index fe262dbef0ad1..481170e46f659 100644 --- a/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.ts +++ b/frontend/src/scenes/session-recordings/player/inspector/inspectorListFiltering.ts @@ -109,7 +109,8 @@ export function filterInspectorListItems({ const inspectorTabFilters: Record boolean> = { [SessionRecordingPlayerTab.ALL]: (item: InspectorListItem) => { - const isAllEverything = miniFiltersByKey['all-everything']?.enabled === true + // even in everything mode we don't show doctor events + const isAllEverything = miniFiltersByKey['all-everything']?.enabled === true && !isDoctorEvent(item) const isAllAutomatic = !!miniFiltersByKey['all-automatic']?.enabled && (isOfflineStatusChange(item) || diff --git a/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts b/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts index 37b5ee585fdce..4f0bf12fc81cd 100644 --- a/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts +++ b/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts @@ -1,17 +1,9 @@ import { expectLogic } from 'kea-test-utils' import { featureFlagLogic } from 'lib/logic/featureFlagLogic' -import { filterInspectorListItems } from 'scenes/session-recordings/player/inspector/inspectorListFiltering' -import { - InspectorListBrowserVisibility, - InspectorListItemEvent, - InspectorListOfflineStatusChange, - playerInspectorLogic, -} from 'scenes/session-recordings/player/inspector/playerInspectorLogic' -import { SharedListMiniFilter } from 'scenes/session-recordings/player/playerSettingsLogic' +import { playerInspectorLogic } from 'scenes/session-recordings/player/inspector/playerInspectorLogic' import { useMocks } from '~/mocks/jest' import { initKeaTests } from '~/test/init' -import { PerformanceEvent, SessionRecordingPlayerTab } from '~/types' const playerLogicProps = { sessionRecordingId: '1', playerKey: 'playlist' } @@ -30,157 +22,6 @@ describe('playerInspectorLogic', () => { logic.mount() }) - describe('filtering inspector list items', () => { - describe('the events tab', () => { - it('filters by window id', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: SessionRecordingPlayerTab.EVENTS, - windowId: 'this window', - data: { event: '$exception' } as unknown as PerformanceEvent, - } as unknown as InspectorListItemEvent, - { - type: SessionRecordingPlayerTab.EVENTS, - windowId: 'a different window', - data: { event: '$exception' } as unknown as PerformanceEvent, - } as unknown as InspectorListItemEvent, - ], - tab: SessionRecordingPlayerTab.EVENTS, - miniFiltersByKey: { 'events-all': { enabled: true } as unknown as SharedListMiniFilter }, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: 'a different window', - }) - ).toHaveLength(1) - }) - - it('includes browser visibility', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: 'browser-visibility', - } as InspectorListBrowserVisibility, - ], - tab: SessionRecordingPlayerTab.ALL, - miniFiltersByKey: { 'all-everything': { enabled: true } as unknown as SharedListMiniFilter }, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: null, - }) - ).toHaveLength(1) - }) - - it('excludes browser visibility on console filter', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: 'browser-visibility', - } as InspectorListBrowserVisibility, - ], - tab: SessionRecordingPlayerTab.EVENTS, - miniFiltersByKey: { 'all-everything': { enabled: false } as unknown as SharedListMiniFilter }, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: null, - }) - ).toHaveLength(0) - }) - - it('excludes browser visibility when show only matching', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: 'browser-visibility', - } as InspectorListBrowserVisibility, - ], - tab: SessionRecordingPlayerTab.EVENTS, - miniFiltersByKey: { 'all-everything': { enabled: true } as unknown as SharedListMiniFilter }, - showOnlyMatching: true, - showMatchingEventsFilter: true, - windowIdFilter: null, - }) - ).toHaveLength(0) - }) - }) - - describe('the doctor tab', () => { - it('ignores events that are not exceptions', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: SessionRecordingPlayerTab.EVENTS, - data: { event: 'an event' } as unknown as PerformanceEvent, - } as unknown as InspectorListItemEvent, - ], - tab: SessionRecordingPlayerTab.DOCTOR, - miniFiltersByKey: {}, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: null, - }) - ).toHaveLength(0) - }) - - it('includes events that are exceptions', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: SessionRecordingPlayerTab.EVENTS, - data: { event: '$exception' } as unknown as PerformanceEvent, - } as unknown as InspectorListItemEvent, - ], - tab: SessionRecordingPlayerTab.DOCTOR, - miniFiltersByKey: {}, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: null, - }) - ).toHaveLength(1) - }) - - it('includes browser offline status', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: 'offline-status', - } as unknown as InspectorListOfflineStatusChange, - ], - tab: SessionRecordingPlayerTab.DOCTOR, - miniFiltersByKey: {}, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: null, - }) - ).toHaveLength(1) - }) - - it('includes browser visibility status', () => { - expect( - filterInspectorListItems({ - allItems: [ - { - type: 'browser-visibility', - } as InspectorListBrowserVisibility, - ], - tab: SessionRecordingPlayerTab.DOCTOR, - miniFiltersByKey: {}, - showOnlyMatching: false, - showMatchingEventsFilter: false, - windowIdFilter: null, - }) - ).toHaveLength(1) - }) - }) - }) - describe('setWindowIdFilter', () => { it('happy case', async () => { await expectLogic(logic).toMatchValues({