Code review updates

This commit is contained in:
Dean 2022-05-16 11:13:17 +01:00
parent 2fe7581dd3
commit 2a1ef4c87f
3 changed files with 32 additions and 9 deletions

View File

@ -123,6 +123,17 @@ filterTests(['smoke', 'all'], () => {
cy.applicationInAppTable("Teds app") cy.applicationInAppTable("Teds app")
cy.deleteApp("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("", "") cy.updateUserInformation("", "")
}) })

View File

@ -79,8 +79,9 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
}) })
cy.get(".spectrum-Modal.is-open").within(() => { cy.get(".spectrum-Modal.is-open").within(() => {
cy.get("[data-cy='user-first-name']").clear()
if (!firstName || firstName == "") { if (!firstName || firstName == "") {
cy.get("[data-cy='user-first-name']").clear()
cy.get("[data-cy='user-first-name']").invoke("val").should("be.empty") cy.get("[data-cy='user-first-name']").invoke("val").should("be.empty")
} else { } else {
cy.get("[data-cy='user-first-name']") cy.get("[data-cy='user-first-name']")
@ -88,8 +89,10 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
.should("have.value", firstName) .should("have.value", firstName)
.blur() .blur()
} }
cy.get("[data-cy='user-last-name']").clear()
if (!lastName || lastName == "") { if (!lastName || lastName == "") {
cy.get("[data-cy='user-last-name']").clear()
cy.get("[data-cy='user-last-name']").invoke("val").should("be.empty") cy.get("[data-cy='user-last-name']").invoke("val").should("be.empty")
} else { } else {
cy.get("[data-cy='user-last-name']") cy.get("[data-cy='user-last-name']")

View File

@ -16,16 +16,27 @@
export let template export let template
let creating = false let creating = false
let defaultAppName
const values = writable({ name: "", url: null }) const values = writable({ name: "", url: null })
const validation = createValidationStore() const validation = createValidationStore()
$: validation.check($values) $: validation.check($values)
onMount(async () => { onMount(async () => {
const defaultName = $auth.user?.firstName const lastChar = $auth.user?.firstName
? `${$auth.user.firstName}s app` ? $auth.user?.firstName[$auth.user?.firstName.length - 1]
: "My app" : null
$values.name = resolveAppName(template, defaultName) 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) nameToUrl($values.name)
await setupValidation() await setupValidation()
}) })
@ -169,9 +180,7 @@
on:blur={() => ($validation.touched.name = true)} on:blur={() => ($validation.touched.name = true)}
on:change={nameToUrl($values.name)} on:change={nameToUrl($values.name)}
label="Name" label="Name"
placeholder={$auth.user?.firstName placeholder={defaultAppName}
? `${$auth.user.firstName}s app`
: "My app"}
/> />
<span> <span>
<Input <Input