Fix unit test, use kebab-case for url query param
This commit is contained in:
@ -354,7 +354,7 @@ test.describe('Command bar tests', () => {
|
|||||||
homePage,
|
homePage,
|
||||||
}) => {
|
}) => {
|
||||||
await test.step(`Prepare and navigate to home page with query params`, async () => {
|
await test.step(`Prepare and navigate to home page with query params`, async () => {
|
||||||
const targetURL = `?create-file&name=test&units=mm&code=ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D&askToOpenInDesktop`
|
const targetURL = `?create-file&name=test&units=mm&code=ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D&ask-open-desktop`
|
||||||
await homePage.expectState({
|
await homePage.expectState({
|
||||||
projectCards: [],
|
projectCards: [],
|
||||||
sortBy: 'last-modified-desc',
|
sortBy: 'last-modified-desc',
|
||||||
@ -413,7 +413,7 @@ test.describe('Command bar tests', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
await test.step(`Prepare and navigate to home page with query params`, async () => {
|
await test.step(`Prepare and navigate to home page with query params`, async () => {
|
||||||
const targetURL = `?create-file&name=test&units=mm&code=ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D&askToOpenInDesktop`
|
const targetURL = `?create-file&name=test&units=mm&code=ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D&ask-open-desktop`
|
||||||
await homePage.expectState({
|
await homePage.expectState({
|
||||||
projectCards: [
|
projectCards: [
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ describe('OpenInDesktopAppHandler tests', () => {
|
|||||||
test(`renders the modal if the query param is present`, () => {
|
test(`renders the modal if the query param is present`, () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<TestWrap location="/?askToOpenInDesktop">
|
<TestWrap location="/?ask-open-desktop">
|
||||||
<p>Dummy app contents</p>
|
<p>Dummy app contents</p>
|
||||||
</TestWrap>
|
</TestWrap>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
@ -150,4 +150,4 @@ export const ZOO_STUDIO_PROTOCOL = 'zoo-studio:'
|
|||||||
* A query parameter that triggers a modal
|
* A query parameter that triggers a modal
|
||||||
* to "open in desktop app" when present in the URL
|
* to "open in desktop app" when present in the URL
|
||||||
*/
|
*/
|
||||||
export const ASK_TO_OPEN_QUERY_PARAM = 'askToOpenInDesktop'
|
export const ASK_TO_OPEN_QUERY_PARAM = 'ask-open-desktop'
|
||||||
|
@ -8,7 +8,7 @@ describe(`link creation tests`, () => {
|
|||||||
|
|
||||||
// Converted with external online tools
|
// Converted with external online tools
|
||||||
const expectedEncodedCode = `ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D`
|
const expectedEncodedCode = `ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D`
|
||||||
const expectedLink = `http://localhost:3000/?create-file=&name=test&units=mm&code=${expectedEncodedCode}&askToOpenInDesktop`
|
const expectedLink = `http://localhost:3000/?create-file=true&name=test&units=mm&code=${expectedEncodedCode}&ask-open-desktop=true`
|
||||||
|
|
||||||
const result = createCreateFileUrl({ code, name, units })
|
const result = createCreateFileUrl({ code, name, units })
|
||||||
expect(result.toString()).toBe(expectedLink)
|
expect(result.toString()).toBe(expectedLink)
|
||||||
|
@ -23,11 +23,11 @@ export function createCreateFileUrl({ code, name, units }: FileLinkParams) {
|
|||||||
// Use the dev server if we are in development mode
|
// Use the dev server if we are in development mode
|
||||||
let origin = DEV ? 'http://localhost:3000' : PROD_APP_URL
|
let origin = DEV ? 'http://localhost:3000' : PROD_APP_URL
|
||||||
const searchParams = new URLSearchParams({
|
const searchParams = new URLSearchParams({
|
||||||
[CREATE_FILE_URL_PARAM]: '',
|
[CREATE_FILE_URL_PARAM]: String(true),
|
||||||
name,
|
name,
|
||||||
units,
|
units,
|
||||||
code: stringToBase64(code),
|
code: stringToBase64(code),
|
||||||
[ASK_TO_OPEN_QUERY_PARAM]: '',
|
[ASK_TO_OPEN_QUERY_PARAM]: String(true),
|
||||||
})
|
})
|
||||||
const createFileUrl = new URL(`?${searchParams.toString()}`, origin)
|
const createFileUrl = new URL(`?${searchParams.toString()}`, origin)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user