2
0

ci: Fix e2e tests

This commit is contained in:
Baptiste Arnaud
2022-05-13 06:47:39 -07:00
parent 7507a1ab1e
commit e268638786
7 changed files with 65 additions and 18 deletions

View 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)

View 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)

View File

@ -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(