0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00

make sure to remove shown_as when switching to trends from stickiness (#6443)

This commit is contained in:
Eric Duong 2021-10-14 12:26:23 -04:00 committed by GitHub
parent 9041e919b2
commit e7b7c18ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { cleanFilters } from './cleanFilters'
import { ChartDisplayType } from '~/types'
import { ShownAsValue } from 'lib/constants'
describe('cleanFilters', () => {
it('switches display to table if moving from TRENDS to RETENTION', () => {
@ -10,4 +11,13 @@ describe('cleanFilters', () => {
)
).toEqual(expect.objectContaining({ insight: 'RETENTION', display: ChartDisplayType.ActionsTable }))
})
it('removes shownas if moving from stickiness to trends', () => {
expect(
cleanFilters(
{ insight: 'TRENDS', shown_as: ShownAsValue.STICKINESS },
{ insight: 'STICKINESS', shown_as: ShownAsValue.STICKINESS }
)
).toEqual(expect.objectContaining({ insight: 'TRENDS', shown_as: undefined }))
})
})

View File

@ -133,9 +133,10 @@ export function cleanFilters(filters: Partial<FilterType>, oldFilters?: Partial<
// TODO: Deprecated; should be removed once backend is updated
if (filters.insight === ViewType.STICKINESS) {
cleanSearchParams['shown_as'] = ShownAsValue.STICKINESS
}
if (filters.insight === ViewType.LIFECYCLE) {
} else if (filters.insight === ViewType.LIFECYCLE) {
cleanSearchParams['shown_as'] = ShownAsValue.LIFECYCLE
} else {
cleanSearchParams['shown_as'] = undefined
}
if (filters.insight === ViewType.SESSIONS && !filters.session) {