ci: ✅ Fix e2e tests
This commit is contained in:
15
apps/viewer/pages/api/mock/fail.ts
Normal file
15
apps/viewer/pages/api/mock/fail.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { withSentry } from '@sentry/nextjs'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed } from 'utils'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (req.method === 'POST') {
|
||||
return res.status(500).json({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Fail',
|
||||
})
|
||||
}
|
||||
methodNotAllowed(res)
|
||||
}
|
||||
|
||||
export default withSentry(handler)
|
15
apps/viewer/pages/api/mock/success.ts
Normal file
15
apps/viewer/pages/api/mock/success.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { withSentry } from '@sentry/nextjs'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { methodNotAllowed } from 'utils'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (req.method === 'POST') {
|
||||
return res.status(200).json({
|
||||
statusCode: 200,
|
||||
statusMessage: 'OK',
|
||||
})
|
||||
}
|
||||
methodNotAllowed(res)
|
||||
}
|
||||
|
||||
export default withSentry(handler)
|
@ -13,21 +13,22 @@ test('should execute webhooks properly', async ({ page }) => {
|
||||
)
|
||||
await createWebhook(typebotId, {
|
||||
id: 'success-webhook',
|
||||
url: 'https://webhook.site/912bafb0-b92f-4be8-ae6a-186b5879a17a',
|
||||
url: 'http://localhost:3001/api/mock/success',
|
||||
method: HttpMethod.POST,
|
||||
})
|
||||
await createWebhook(typebotId, {
|
||||
id: 'failed-webhook',
|
||||
url: 'https://webhook.site/8be94c01-141e-4792-b3c6-cf45137481d6',
|
||||
url: 'http://localhost:3001/api/mock/fail',
|
||||
method: HttpMethod.POST,
|
||||
})
|
||||
|
||||
await page.goto(`/${typebotId}-public`)
|
||||
await typebotViewer(page).locator('text=Send success webhook').click()
|
||||
await page.waitForResponse(
|
||||
(resp) =>
|
||||
async (resp) =>
|
||||
resp.request().url().includes(`/api/typebots/${typebotId}/blocks`) &&
|
||||
resp.status() === 200
|
||||
resp.status() === 200 &&
|
||||
(await resp.json()).statusCode === 200
|
||||
)
|
||||
await typebotViewer(page).locator('text=Send failed webhook').click()
|
||||
await page.waitForResponse(
|
||||
|
Reference in New Issue
Block a user