Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Jan 1, 2025
1 parent 5c3aa89 commit 0ef640b
Showing 1 changed file with 50 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { SessionRecordingType } from '~/types'

const EXPECTED_RECORDING_PROPERTIES = [
{
id: 's1',
properties: {
$browser: 'Chrome',
$device_type: 'Desktop',
$geoip_country_code: 'AU',
$os: 'Windows',
$os_name: 'Windows 10',
$referring_domain: 'google.com',
},
},
{
id: 's2',
properties: {
$browser: 'Safari',
$device_type: 'Mobile',
$geoip_country_code: 'GB',
$os: 'iOS',
$os_name: 'iOS 14',
$referring_domain: 'google.com',
},
},
]

const EXPECTED_RECORDING_PROPERTIES_BY_ID = {
s1: {
$browser: 'Chrome',
$device_type: 'Desktop',
$geoip_country_code: 'AU',
$os: 'Windows',
$os_name: 'Windows 10',
$referring_domain: 'google.com',
},
s2: {
$browser: 'Safari',
$device_type: 'Mobile',
$geoip_country_code: 'GB',
$os: 'iOS',
$os_name: 'iOS 14',
$referring_domain: 'google.com',
},
}

const mockSessons: SessionRecordingType[] = [
{
id: 's1',
Expand Down Expand Up @@ -41,8 +85,8 @@ describe('sessionRecordingsListPropertiesLogic', () => {
post: {
'/api/environments/:team_id/query': {
results: [
['s1', JSON.stringify({ blah: 'blah1' })],
['s2', JSON.stringify({ blah: 'blah2' })],
['s1', 'AU', 'Chrome', 'Desktop', 'Windows', 'Windows 10', 'google.com'],
['s2', 'GB', 'Safari', 'Mobile', 'iOS', 'iOS 14', 'google.com'],
],
},
},
Expand All @@ -61,14 +105,8 @@ describe('sessionRecordingsListPropertiesLogic', () => {
}).toDispatchActions(['loadPropertiesForSessionsSuccess'])

expect(logic.values).toMatchObject({
recordingProperties: [
{ id: 's1', properties: { blah: 'blah1' } },
{ id: 's2', properties: { blah: 'blah2' } },
],
recordingPropertiesById: {
s1: { blah: 'blah1' },
s2: { blah: 'blah2' },
},
recordingProperties: EXPECTED_RECORDING_PROPERTIES,
recordingPropertiesById: EXPECTED_RECORDING_PROPERTIES_BY_ID,
})
})

Expand All @@ -78,21 +116,15 @@ describe('sessionRecordingsListPropertiesLogic', () => {
}).toDispatchActions(['loadPropertiesForSessionsSuccess'])

expect(logic.values).toMatchObject({
recordingPropertiesById: {
s1: { blah: 'blah1' },
s2: { blah: 'blah2' },
},
recordingPropertiesById: EXPECTED_RECORDING_PROPERTIES_BY_ID,
})

await expectLogic(logic, () => {
logic.actions.maybeLoadPropertiesForSessions(mockSessons)
}).toNotHaveDispatchedActions(['loadPropertiesForSessionsSuccess'])

expect(logic.values).toMatchObject({
recordingPropertiesById: {
s1: { blah: 'blah1' },
s2: { blah: 'blah2' },
},
recordingPropertiesById: EXPECTED_RECORDING_PROPERTIES_BY_ID,
})
})
})

0 comments on commit 0ef640b

Please sign in to comment.