Skip to content

Commit

Permalink
fix(bot): ⚡️ Better incoming variable parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jun 24, 2022
1 parent 7c3345a commit 554365d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import { UsersIcon } from 'assets/icons'
import React from 'react'
import { CollaborationList } from './CollaborationList'

export const CollaborationMenuButton = () => {
export const CollaborationMenuButton = ({
isLoading,
}: {
isLoading: boolean
}) => {
return (
<Popover isLazy placement="bottom-end">
<PopoverTrigger>
<span>
<Tooltip label="Invite users to collaborate">
<IconButton
isLoading={isLoading}
icon={<UsersIcon />}
aria-label="Show collaboration menu"
size="sm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const TypebotHeader = () => {
</HStack>

<HStack right="40px" pos="absolute" display={['none', 'flex']}>
<CollaborationMenuButton />
<CollaborationMenuButton isLoading={isNotDefined(typebot)} />
{router.pathname.includes('/edit') && isNotDefined(rightPanel) && (
<Button
onClick={handlePreviewClick}
Expand Down
18 changes: 1 addition & 17 deletions apps/builder/playwright/tests/bubbles/embed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,7 @@ test.describe.parallel('Embed bubble block', () => {
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Click to edit...')
await page.fill('input[placeholder="Paste the link or code..."]', pdfSrc)
await expect(page.locator('iframe#embed-bubble-content')).toHaveAttribute(
'src',
pdfSrc
)
await page.fill(
'input[placeholder="Paste the link or code..."]',
iframeCode
)
await expect(page.locator('iframe#embed-bubble-content')).toHaveAttribute(
'src',
'https://typebot.io'
)
await page.fill('input[placeholder="Paste the link or code..."]', siteSrc)
await expect(page.locator('iframe#embed-bubble-content')).toHaveAttribute(
'src',
siteSrc
)
await expect(page.locator('text="Show embed"')).toBeVisible()
})
})

Expand Down
3 changes: 3 additions & 0 deletions apps/builder/playwright/tests/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ test.describe.parallel('Settings page', () => {
}
)
await page.goto(`/typebots/${typebotId}/settings`)
await expect(
typebotViewer(page).locator('a:has-text("Made with Typebot")')
).toHaveAttribute('href', 'https://www.typebot.io/?utm_source=litebadge')
await page.click('button:has-text("Typing emulation")')
await page.fill('[data-testid="speed"] input', '350')
await page.fill('[data-testid="max-delay"] input', '1.5')
Expand Down
7 changes: 4 additions & 3 deletions packages/bot-engine/src/contexts/TypebotContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,13 @@ export const TypebotContext = ({
}

const formatIncomingVariableValue = (
value: string | number
): string | number => {
value?: string | number
): string | number | undefined => {
// This first check avoid to parse 004 as the number 4.
if (typeof value === 'string' && value.startsWith('0') && value.length > 1)
return value
return isNaN(Number(value)) ? value : Number(value)
if (typeof value === 'number') return value
return isNaN(value?.toString() as unknown as number) ? value : Number(value)
}

export const useTypebot = () => useContext(typebotContext)

5 comments on commit 554365d

@vercel
Copy link

@vercel vercel bot commented on 554365d Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 554365d Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

apr.nigerias.io
apo.nigerias.io
sat.cr8.ai
aso.nigerias.io
vhpage.cr8.ai
bot.aws.bj
am.nigerias.io
bt.id8rs.com
an.nigerias.io
ar.nigerias.io
eventhub.com.au
sakuranembro.it
chat.sureb4.com
bot.piccinato.co
games.klujo.com
faqs.nigerias.io
feedback.ofx.one
bot.upfunnel.art
clo.closeer.work
stan.vselise.com
app.chatforms.net
voicehelp.cr8.ai
gentleman-shop.fr
typebot.stillio.com
this-is-a-test.com
zap.techadviser.in
bot.eventhub.com.au
forms.webisharp.com
goalsettingbot.com
bot.ansuraniphone.my
chat.hayurihijab.com
bot.cotemeuplano.com
get.freebotoffer.xyz
abutton.wpwakanda.com
chat.missarkansas.org
sbutton.wpwakanda.com
bot.meuesocial.com.br
cdd.searchcube.com.sg
bot.incusservices.com
apply.ansuraniphone.my
felipewelington.com.br
kodawariab736.skeep.it
form.searchcube.com.sg
83242573.actualizar.xyz
info.clickasuransi.com
mainmenu.diddancing.com
gcase.barrettamario.it
c23111azqw.nigerias.io
serviziaziendali.online
view.onlinebotdemo.xyz
91181264.your-access.one
boyfriend-breakup.riku.ai
type.opaulovieira.com.br
designguide.techyscouts.com
hunterbot.saleshunter.ai
form.sergiolimajr.com.br
piazzatorre.barrettamario.it
onboarding.libertydreamcare.ie
aibot.angrybranding.co.uk
type.dericsoncalari.com.br
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
viewer-v2-alpha-typebot-io.vercel.app
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
viewer-v2-alpha-git-main-typebot-io.vercel.app
personal-trainer.barrettamario.it

@vercel
Copy link

@vercel vercel bot commented on 554365d Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 554365d Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 554365d Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.