From df01c233e4c93ff5e414763a2a6d913617ded91a Mon Sep 17 00:00:00 2001 From: Frank Noirot Date: Mon, 13 Jan 2025 10:42:08 -0500 Subject: [PATCH] Fix unit test, use kebab-case for url query param --- e2e/playwright/command-bar-tests.spec.ts | 4 ++-- src/components/OpenInDesktopAppHandler.test.tsx | 2 +- src/lib/constants.ts | 2 +- src/lib/links.test.ts | 2 +- src/lib/links.ts | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/playwright/command-bar-tests.spec.ts b/e2e/playwright/command-bar-tests.spec.ts index 37ad8c557..bad646ece 100644 --- a/e2e/playwright/command-bar-tests.spec.ts +++ b/e2e/playwright/command-bar-tests.spec.ts @@ -354,7 +354,7 @@ test.describe('Command bar tests', () => { homePage, }) => { 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({ projectCards: [], 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 () => { - 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({ projectCards: [ { diff --git a/src/components/OpenInDesktopAppHandler.test.tsx b/src/components/OpenInDesktopAppHandler.test.tsx index 965befefe..40ba866c7 100644 --- a/src/components/OpenInDesktopAppHandler.test.tsx +++ b/src/components/OpenInDesktopAppHandler.test.tsx @@ -39,7 +39,7 @@ describe('OpenInDesktopAppHandler tests', () => { test(`renders the modal if the query param is present`, () => { render( - +

Dummy app contents

diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 29b49d7fd..d463bc2de 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -150,4 +150,4 @@ export const ZOO_STUDIO_PROTOCOL = 'zoo-studio:' * A query parameter that triggers a modal * 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' diff --git a/src/lib/links.test.ts b/src/lib/links.test.ts index c9639cb56..9267e3cc9 100644 --- a/src/lib/links.test.ts +++ b/src/lib/links.test.ts @@ -8,7 +8,7 @@ describe(`link creation tests`, () => { // Converted with external online tools 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 }) expect(result.toString()).toBe(expectedLink) diff --git a/src/lib/links.ts b/src/lib/links.ts index 9729b59f1..90eb4998b 100644 --- a/src/lib/links.ts +++ b/src/lib/links.ts @@ -23,11 +23,11 @@ export function createCreateFileUrl({ code, name, units }: FileLinkParams) { // Use the dev server if we are in development mode let origin = DEV ? 'http://localhost:3000' : PROD_APP_URL const searchParams = new URLSearchParams({ - [CREATE_FILE_URL_PARAM]: '', + [CREATE_FILE_URL_PARAM]: String(true), name, units, code: stringToBase64(code), - [ASK_TO_OPEN_QUERY_PARAM]: '', + [ASK_TO_OPEN_QUERY_PARAM]: String(true), }) const createFileUrl = new URL(`?${searchParams.toString()}`, origin)