2
0

🚸 (results) Improve results action buttons

Now have an export all modal with settings and a better column order form
This commit is contained in:
Baptiste Arnaud
2023-02-14 14:33:26 +01:00
parent 1a3596b15c
commit 08e33fbe70
16 changed files with 645 additions and 373 deletions

View File

@ -48,7 +48,7 @@ test('should work as expected', async ({ page, browser }) => {
await page.click('[data-testid="checkbox"] >> nth=0')
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('text="Export"').click(),
page.getByRole('button', { name: 'Export' }).click(),
])
const downloadPath = await download.path()
expect(downloadPath).toBeDefined()
@ -71,8 +71,8 @@ test('should work as expected', async ({ page, browser }) => {
await page2.goto(urls[0])
await expect(page2.locator('pre')).toBeVisible()
page.getByRole('button', { name: 'Delete' }).click()
await page.locator('button >> text="Delete"').click()
await page.locator('button >> text="Delete" >> nth=1').click()
await expect(page.locator('text="api.json"')).toBeHidden()
await page2.goto(urls[0])
await expect(page2.locator('pre')).toBeHidden()

View File

@ -45,7 +45,7 @@ test('should work as expected', async ({ page, browser }) => {
await page.click('[data-testid="checkbox"] >> nth=0')
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('text="Export"').click(),
page.getByRole('button', { name: 'Export' }).click(),
])
const downloadPath = await download.path()
expect(downloadPath).toBeDefined()
@ -68,8 +68,8 @@ test('should work as expected', async ({ page, browser }) => {
await page2.goto(urls[0])
await expect(page2.locator('pre')).toBeVisible()
page.getByRole('button', { name: 'Delete' }).click()
await page.locator('button >> text="Delete"').click()
await page.locator('button >> text="Delete" >> nth=1').click()
await expect(page.locator('text="api.json"')).toBeHidden()
await page2.goto(urls[0])
await expect(page2.locator('pre')).toBeHidden()

View File

@ -3,17 +3,15 @@ import { createId } from '@paralleldrive/cuid2'
import { HttpMethod, Typebot } from 'models'
import {
createWebhook,
deleteTypebots,
deleteWebhooks,
importTypebotInDatabase,
} from 'utils/playwright/databaseActions'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { apiToken } from 'utils/playwright/databaseSetup'
import { getTestAsset } from '@/test/utils/playwright'
test.describe('Bot', () => {
const typebotId = createId()
const typebotId = createId()
test.describe('Bot', () => {
test.beforeEach(async () => {
await importTypebotInDatabase(getTestAsset('typebots/webhook.json'), {
id: typebotId,
@ -45,19 +43,10 @@ test.describe('Bot', () => {
body: `{{Full body}}`,
})
} catch (err) {
console.log(err)
// Webhooks already created
}
})
test.afterEach(async () => {
await deleteTypebots([typebotId])
await deleteWebhooks([
'failing-webhook',
'partial-body-webhook',
'full-body-webhook',
])
})
test('should execute webhooks properly', async ({ page }) => {
await page.goto(`/${typebotId}-public`)
await typebotViewer(page).locator('text=Send failing webhook').click()

View File

@ -3,8 +3,6 @@ import { createId } from '@paralleldrive/cuid2'
import { HttpMethod } from 'models'
import {
createWebhook,
deleteTypebots,
deleteWebhooks,
importTypebotInDatabase,
} from 'utils/playwright/databaseActions'
import { getTestAsset } from '@/test/utils/playwright'
@ -42,19 +40,10 @@ test.beforeEach(async () => {
body: `{{Full body}}`,
})
} catch (err) {
console.log(err)
// Webhooks already created
}
})
test.afterEach(async () => {
await deleteTypebots([typebotId])
await deleteWebhooks([
'failing-webhook',
'partial-body-webhook',
'full-body-webhook',
])
})
test('should execute webhooks properly', async ({ page }) => {
await page.goto(`/next/${typebotId}-public`)
await page.locator('text=Send failing webhook').click()

View File

@ -99,9 +99,10 @@ const processAndSaveAnswer =
block: InputBlock
) =>
async (reply: string): Promise<Variable[]> => {
state.result &&
!state.isPreview &&
(await saveAnswer(state.result.id, block)(reply))
if (!state.isPreview && state.result) {
await saveAnswer(state.result.id, block)(reply)
if (!state.result.hasStarted) await setResultAsStarted(state.result.id)
}
const newVariables = saveVariableValueIfAny(state, block)(reply)
return newVariables
}
@ -126,6 +127,13 @@ const saveVariableValueIfAny =
]
}
const setResultAsStarted = async (resultId: string) => {
await prisma.result.update({
where: { id: resultId },
data: { hasStarted: true },
})
}
const parseRetryMessage = (
block: InputBlock
): Pick<ChatReply, 'messages' | 'input'> => {