Skip to content

Commit

Permalink
fix: real time polling even if empty (#20077)
Browse files Browse the repository at this point in the history
* fix: real time polling even if empty

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
pauldambra and github-actions[bot] authored Feb 1, 2024
1 parent bb91076 commit 1c63b97
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,21 @@ describe('sessionRecordingDataLogic', () => {
if (req.url.searchParams.get('source') === 'blob') {
return res(ctx.text(snapshotsAsJSONLines()))
} else if (req.url.searchParams.get('source') === 'realtime') {
if (req.params.id === 'has-only-empty-realtime') {
return res(ctx.json({ snapshots: [] }))
}
// ... since this is fake, we'll just return the same data in the right format
return res(ctx.json(snapshotsAsRealTimeJSONPayload()))
}

// with no source requested should return sources
const sources = [BLOB_SOURCE]
let sources = [BLOB_SOURCE]
if (req.params.id === 'has-real-time-too') {
sources.push(REALTIME_SOURCE)
}
if (req.params.id === 'has-only-empty-realtime') {
sources = [REALTIME_SOURCE]
}
return [
200,
{
Expand Down Expand Up @@ -393,4 +399,28 @@ describe('sessionRecordingDataLogic', () => {
})
})
})

describe('empty realtime loading', () => {
beforeEach(async () => {
logic = sessionRecordingDataLogic({
sessionRecordingId: 'has-only-empty-realtime',
// we don't want to wait for the default real time polling interval in tests
realTimePollingIntervalMilliseconds: 10,
})
logic.mount()
// Most of these tests assume the metadata is being loaded upfront which is the typical case
logic.actions.loadRecordingMeta()
})

it('should start polling even though realtime is empty', async () => {
await expectLogic(logic, () => {
logic.actions.loadRecordingSnapshots()
}).toDispatchActions([
'loadRecordingSnapshotsSuccess',
'startRealTimePolling',
'pollRecordingSnapshots',
'pollRecordingSnapshotsSuccess',
])
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
source: sources[0],
})

// If we only have a realtime source and its empty, start polling it anyway
if (sources[0].source === SnapshotSourceType.realtime) {
actions.startRealTimePolling()
}

return
}

Expand Down

0 comments on commit 1c63b97

Please sign in to comment.