Skip to content

Commit

Permalink
fix: don't show doctor events in everything mode (#24594)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Aug 27, 2024
1 parent f685cec commit 92a86ec
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 161 deletions.
Original file line number Diff line number Diff line change
@@ -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)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export function filterInspectorListItems({

const inspectorTabFilters: Record<SessionRecordingPlayerTab, (item: InspectorListItem) => 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) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -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' }

Expand All @@ -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({
Expand Down

0 comments on commit 92a86ec

Please sign in to comment.