2
0

feat(settings): ️ Can disable query params auto hide

This commit is contained in:
Baptiste Arnaud
2022-05-14 11:53:59 -07:00
parent 731e646377
commit 42721865c5
5 changed files with 66 additions and 2 deletions

View File

@ -53,7 +53,11 @@ export const TypebotPage = ({
const clearQueryParams = () => {
const hasQueryParams = asPath.includes('?')
if (hasQueryParams) push(asPath.split('?')[0], undefined, { shallow: true })
if (
hasQueryParams &&
typebot.settings.general.isHideQueryParamsEnabled !== false
)
push(asPath.split('?')[0], undefined, { shallow: true })
}
const initializeResult = async () => {

View File

@ -74,6 +74,19 @@ export const createTypebots = async (partialTypebots: Partial<Typebot>[]) => {
})
}
export const updateTypebot = async (
partialTypebot: Partial<Typebot> & { id: string }
) => {
await prisma.typebot.updateMany({
where: { id: partialTypebot.id },
data: partialTypebot,
})
return prisma.publicTypebot.updateMany({
where: { typebotId: partialTypebot.id },
data: partialTypebot,
})
}
const parseTypebotToPublicTypebot = (
id: string,
typebot: Typebot

View File

@ -1,5 +1,9 @@
import test, { expect } from '@playwright/test'
import { createTypebots, parseDefaultBlockWithStep } from '../services/database'
import {
createTypebots,
parseDefaultBlockWithStep,
updateTypebot,
} from '../services/database'
import cuid from 'cuid'
import { defaultSettings, defaultTextInputOptions, InputStepType } from 'models'
@ -71,3 +75,31 @@ test.describe('Create result on page refresh enabled', () => {
expect(resultId).toBe(null)
})
})
test('Hide query params', async ({ page }) => {
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
...parseDefaultBlockWithStep({
type: InputStepType.TEXT,
options: defaultTextInputOptions,
}),
},
])
await page.goto(`/${typebotId}-public?Name=John`)
await page.waitForTimeout(1000)
expect(page.url()).toEqual(`http://localhost:3001/${typebotId}-public`)
await updateTypebot({
id: typebotId,
settings: {
...defaultSettings,
general: { ...defaultSettings.general, isHideQueryParamsEnabled: false },
},
})
await page.goto(`/${typebotId}-public?Name=John`)
await page.waitForTimeout(1000)
expect(page.url()).toEqual(
`http://localhost:3001/${typebotId}-public?Name=John`
)
})