2
0

♻️ (api) Auto start bot if starting with input

Closes #877, closes #884
This commit is contained in:
Baptiste Arnaud
2023-10-04 16:47:58 +02:00
parent 2bc9dfb503
commit 9e6a1f7dc0
11 changed files with 180 additions and 39 deletions

View File

@ -27,6 +27,13 @@ test('API chat execution should work on preview bot', async ({ request }) => {
id: 'chat-sub-bot',
publicId: 'chat-sub-bot-public',
})
await importTypebotInDatabase(
getTestAsset('typebots/chat/startingWithInput.json'),
{
id: 'starting-with-input',
publicId: 'starting-with-input-public',
}
)
await createWebhook(typebotId, {
id: 'chat-webhook-id',
method: HttpMethod.GET,
@ -218,4 +225,26 @@ test('API chat execution should work on published bot', async ({ request }) => {
])
expect(messages[2].content.richText.length).toBeGreaterThan(0)
})
await test.step('Starting with a message when typebot starts with input should proceed', async () => {
const { messages } = await (
await request.post(`/api/v1/sendMessage`, {
data: {
message: 'Hey',
startParams: {
typebot: 'starting-with-input-public',
},
} satisfies SendMessageInput,
})
).json()
expect(messages[0].content.richText).toStrictEqual([
{
children: [
{
text: "That's nice!",
},
],
type: 'p',
},
])
})
})