-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: screenshot test the inspector list (#26229)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0e2199c
commit e92e4a8
Showing
5 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions
88
frontend/src/scenes/session-recordings/player/inspector/PlayerInspector.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Meta, StoryFn, StoryObj } from '@storybook/react' | ||
import { BindLogic, useActions, useValues } from 'kea' | ||
import { useEffect } from 'react' | ||
import recordingEventsJson from 'scenes/session-recordings/__mocks__/recording_events_query' | ||
import recordingMetaJson from 'scenes/session-recordings/__mocks__/recording_meta.json' | ||
import { snapshotsAsJSONLines } from 'scenes/session-recordings/__mocks__/recording_snapshots' | ||
import { PlayerInspector } from 'scenes/session-recordings/player/inspector/PlayerInspector' | ||
import { sessionRecordingDataLogic } from 'scenes/session-recordings/player/sessionRecordingDataLogic' | ||
import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic' | ||
|
||
import { mswDecorator } from '~/mocks/browser' | ||
|
||
type Story = StoryObj<typeof PlayerInspector> | ||
const meta: Meta<typeof PlayerInspector> = { | ||
title: 'Components/PlayerInspector', | ||
component: PlayerInspector, | ||
decorators: [ | ||
mswDecorator({ | ||
get: { | ||
'/api/environments/:team_id/session_recordings/:id': recordingMetaJson, | ||
'/api/environments/:team_id/session_recordings/:id/snapshots': (req, res, ctx) => { | ||
// with no sources, returns sources... | ||
if (req.url.searchParams.get('source') === 'blob') { | ||
return res(ctx.text(snapshotsAsJSONLines())) | ||
} | ||
// with no source requested should return sources | ||
return [ | ||
200, | ||
{ | ||
sources: [ | ||
{ | ||
source: 'blob', | ||
start_timestamp: '2023-08-11T12:03:36.097000Z', | ||
end_timestamp: '2023-08-11T12:04:52.268000Z', | ||
blob_key: '1691755416097-1691755492268', | ||
}, | ||
], | ||
}, | ||
] | ||
}, | ||
}, | ||
post: { | ||
'/api/environments/:team_id/query': (req, res, ctx) => { | ||
const body = req.body as Record<string, any> | ||
if (body.query.kind === 'EventsQuery' && body.query.properties.length === 1) { | ||
return res(ctx.json(recordingEventsJson)) | ||
} | ||
|
||
// default to an empty response or we duplicate information | ||
return res(ctx.json({ results: [] })) | ||
}, | ||
}, | ||
}), | ||
], | ||
} | ||
export default meta | ||
|
||
const BasicTemplate: StoryFn<typeof PlayerInspector> = () => { | ||
const dataLogic = sessionRecordingDataLogic({ sessionRecordingId: '12345', playerKey: 'story-template' }) | ||
const { sessionPlayerMetaData } = useValues(dataLogic) | ||
|
||
const { loadSnapshots, loadEvents } = useActions(dataLogic) | ||
loadSnapshots() | ||
|
||
// TODO you have to call actions in a particular order | ||
// and only when some other data has already been loaded | ||
// 🫠 | ||
useEffect(() => { | ||
loadEvents() | ||
}, [sessionPlayerMetaData]) | ||
|
||
return ( | ||
<div className="flex flex-col gap-2 min-w-96 min-h-120"> | ||
<BindLogic | ||
logic={sessionRecordingPlayerLogic} | ||
props={{ | ||
sessionRecordingId: '12345', | ||
playerKey: 'story-template', | ||
}} | ||
> | ||
<PlayerInspector /> | ||
</BindLogic> | ||
</div> | ||
) | ||
} | ||
|
||
export const Default: Story = BasicTemplate.bind({}) | ||
Default.args = {} |
11 changes: 11 additions & 0 deletions
11
frontend/src/scenes/session-recordings/player/inspector/PlayerInspector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PlayerInspectorControls } from 'scenes/session-recordings/player/inspector/PlayerInspectorControls' | ||
import { PlayerInspectorList } from 'scenes/session-recordings/player/inspector/PlayerInspectorList' | ||
|
||
export function PlayerInspector(): JSX.Element { | ||
return ( | ||
<> | ||
<PlayerInspectorControls /> | ||
<PlayerInspectorList /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters