From 883765f894b9010fa00aa3e8b3b4b40f142384dd Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 16 May 2022 11:13:17 +0100 Subject: [PATCH] Code review updates --- .../cypress/integration/createApp.spec.js | 11 +++++++++ packages/builder/cypress/support/commands.js | 7 ++++-- .../components/start/CreateAppModal.svelte | 23 +++++++++++++------ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/packages/builder/cypress/integration/createApp.spec.js b/packages/builder/cypress/integration/createApp.spec.js index 0797ce4fb1..a29f16a5e8 100644 --- a/packages/builder/cypress/integration/createApp.spec.js +++ b/packages/builder/cypress/integration/createApp.spec.js @@ -123,6 +123,17 @@ filterTests(['smoke', 'all'], () => { cy.applicationInAppTable("Teds app") cy.deleteApp("Teds app") + //Accomodate names that end in 'S' + cy.updateUserInformation("Chris", "Userman") + + cy.createApp() + + cy.visit(`${Cypress.config().baseUrl}/builder`) + cy.wait(1000) + + cy.applicationInAppTable("Chris app") + cy.deleteApp("Chris app") + cy.updateUserInformation("", "") }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 7bfb7676cf..23370a3e6f 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -79,8 +79,9 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => { }) cy.get(".spectrum-Modal.is-open").within(() => { + cy.get("[data-cy='user-first-name']").clear() + if (!firstName || firstName == "") { - cy.get("[data-cy='user-first-name']").clear() cy.get("[data-cy='user-first-name']").invoke("val").should("be.empty") } else { cy.get("[data-cy='user-first-name']") @@ -88,8 +89,10 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => { .should("have.value", firstName) .blur() } + + cy.get("[data-cy='user-last-name']").clear() + if (!lastName || lastName == "") { - cy.get("[data-cy='user-last-name']").clear() cy.get("[data-cy='user-last-name']").invoke("val").should("be.empty") } else { cy.get("[data-cy='user-last-name']") diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index 73ae95a81e..e46f4f9302 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -16,16 +16,27 @@ export let template let creating = false + let defaultAppName const values = writable({ name: "", url: null }) const validation = createValidationStore() $: validation.check($values) onMount(async () => { - const defaultName = $auth.user?.firstName - ? `${$auth.user.firstName}s app` - : "My app" - $values.name = resolveAppName(template, defaultName) + const lastChar = $auth.user?.firstName + ? $auth.user?.firstName[$auth.user?.firstName.length - 1] + : null + console.log(lastChar) + defaultAppName = + lastChar && lastChar.toLowerCase() == "s" + ? `${$auth.user?.firstName} app` + : `${$auth.user.firstName}s app` + + console.log(defaultAppName) + $values.name = resolveAppName( + template, + !$auth.user?.firstName ? "My app" : defaultAppName + ) nameToUrl($values.name) await setupValidation() }) @@ -169,9 +180,7 @@ on:blur={() => ($validation.touched.name = true)} on:change={nameToUrl($values.name)} label="Name" - placeholder={$auth.user?.firstName - ? `${$auth.user.firstName}s app` - : "My app"} + placeholder={defaultAppName} />