fix: preserve newlines for nav to explorer

This commit is contained in:
TzeYiing authored and Ziinc committed 2022-04-05 14:47:15 +02:00
1 parent c3beade58d
commit 609ff20193
3 files changed
+11 -2

No files matched your search

@@ -47,7 +47,7 @@ const SavedQueriesItem: FC<Props> = ({ item }: Props) => {
type="alternative"
iconRight={<IconPlay size={10} />}
onClick={() =>
router.push(`/project/${ref}/logs-explorer?sql=${encodeURI(item.content.sql)}`)
router.push(`/project/${ref}/logs-explorer?sql=${encodeURIComponent(item.content.sql)}`)
}
>
Run
@@ -159,7 +159,7 @@ export const LogsPreviewer: React.FC<Props> = ({
: ''
}
onExploreClick={() => {
router.push(`/project/${projectRef}/logs-explorer?q=${params.rawSql}`)
router.push(`/project/${projectRef}/logs-explorer?q=${encodeURIComponent(params.rawSql)}`)
}}
onSelectTemplate={onSelectTemplate}
dispatchWhereFilters={dispatchWhereFilters}
@@ -283,3 +283,12 @@ test('bug: nav backwards with params change results in ui changing', async () =>
await screen.findByDisplayValue('simple-query')
})
test("bug: nav to explorer preserves newlines", async ()=>{
render(
<LogsPreviewer projectRef="123" tableName={LogsTableName.EDGE} />
)
const router = useRouter()
userEvent.click(await screen.findByText(/Explore/))
await expect(router.push).toBeCalledWith(expect.stringContaining(encodeURIComponent("\n")))
}