🐛 (limits) Fix storage limit trigger and e2e tests
This commit is contained in:
committed by
Baptiste Arnaud
parent
1e26703ad4
commit
30dff2d5d7
@@ -1,5 +1,6 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import {
|
||||
apiToken,
|
||||
createResults,
|
||||
createWebhook,
|
||||
importTypebotInDatabase,
|
||||
@@ -23,7 +24,7 @@ test.beforeAll(async () => {
|
||||
test('can list typebots', async ({ request }) => {
|
||||
expect((await request.get(`/api/typebots`)).status()).toBe(401)
|
||||
const response = await request.get(`/api/typebots`, {
|
||||
headers: { Authorization: 'Bearer userToken' },
|
||||
headers: { Authorization: `Bearer ${apiToken}` },
|
||||
})
|
||||
const { typebots } = await response.json()
|
||||
expect(typebots).toHaveLength(1)
|
||||
@@ -41,7 +42,7 @@ test('can get webhook blocks', async ({ request }) => {
|
||||
const response = await request.get(
|
||||
`/api/typebots/${typebotId}/webhookBlocks`,
|
||||
{
|
||||
headers: { Authorization: 'Bearer userToken' },
|
||||
headers: { Authorization: `Bearer ${apiToken}` },
|
||||
}
|
||||
)
|
||||
const { blocks } = await response.json()
|
||||
@@ -65,7 +66,7 @@ test('can subscribe webhook', async ({ request }) => {
|
||||
`/api/typebots/${typebotId}/blocks/webhookBlock/subscribeWebhook`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer userToken',
|
||||
Authorization: `Bearer ${apiToken}`,
|
||||
},
|
||||
data: { url: 'https://test.com' },
|
||||
}
|
||||
@@ -87,7 +88,7 @@ test('can unsubscribe webhook', async ({ request }) => {
|
||||
const response = await request.post(
|
||||
`/api/typebots/${typebotId}/blocks/webhookBlock/unsubscribeWebhook`,
|
||||
{
|
||||
headers: { Authorization: 'Bearer userToken' },
|
||||
headers: { Authorization: `Bearer ${apiToken}` },
|
||||
}
|
||||
)
|
||||
const body = await response.json()
|
||||
@@ -107,7 +108,7 @@ test('can get a sample result', async ({ request }) => {
|
||||
const response = await request.get(
|
||||
`/api/typebots/${typebotId}/blocks/webhookBlock/sampleResult`,
|
||||
{
|
||||
headers: { Authorization: 'Bearer userToken' },
|
||||
headers: { Authorization: `Bearer ${apiToken}` },
|
||||
}
|
||||
)
|
||||
const data = await response.json()
|
||||
@@ -128,7 +129,7 @@ test('can list results', async ({ request }) => {
|
||||
const response = await request.get(
|
||||
`/api/typebots/${typebotId}/results?limit=10`,
|
||||
{
|
||||
headers: { Authorization: 'Bearer userToken' },
|
||||
headers: { Authorization: `Bearer ${apiToken}` },
|
||||
}
|
||||
)
|
||||
const { results } = await response.json()
|
||||
|
||||
@@ -6,7 +6,6 @@ import { typebotViewer } from '../services/selectorUtils'
|
||||
import { createResults, importTypebotInDatabase } from '../services/database'
|
||||
import { readFileSync } from 'fs'
|
||||
import { isDefined } from 'utils'
|
||||
import { describe } from 'node:test'
|
||||
|
||||
const THREE_GIGABYTES = 3 * 1024 * 1024 * 1024
|
||||
|
||||
@@ -49,7 +48,7 @@ test('should work as expected', async ({ page, browser }) => {
|
||||
page.locator('text="Export"').click(),
|
||||
])
|
||||
const downloadPath = await download.path()
|
||||
expect(path).toBeDefined()
|
||||
expect(downloadPath).toBeDefined()
|
||||
const file = readFileSync(downloadPath as string).toString()
|
||||
const { data } = parse(file)
|
||||
expect(data).toHaveLength(2)
|
||||
@@ -86,7 +85,7 @@ test('should work as expected', async ({ page, browser }) => {
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
describe('Storage limit is reached', () => {
|
||||
test.describe('Storage limit is reached', () => {
|
||||
const typebotId = cuid()
|
||||
|
||||
test.beforeAll(async () => {
|
||||
|
||||
@@ -3,9 +3,6 @@ import path from 'path'
|
||||
import { importTypebotInDatabase } from '../services/database'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
import cuid from 'cuid'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
test('should work as expected', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import {
|
||||
createResults,
|
||||
freeWorkspaceId,
|
||||
importTypebotInDatabase,
|
||||
limitTestWorkspaceId,
|
||||
} from '../services/database'
|
||||
import cuid from 'cuid'
|
||||
import path from 'path'
|
||||
@@ -14,7 +14,7 @@ test('should not start if chat limit is reached', async ({ page }) => {
|
||||
{
|
||||
id: typebotId,
|
||||
publicId: `${typebotId}-public`,
|
||||
workspaceId: freeWorkspaceId,
|
||||
workspaceId: limitTestWorkspaceId,
|
||||
}
|
||||
)
|
||||
await createResults({ typebotId, count: 320 })
|
||||
|
||||
@@ -11,9 +11,6 @@ import {
|
||||
} from 'models'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
import cuid from 'cuid'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
test('Should correctly parse metadata', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
@@ -37,20 +34,20 @@ test('Should correctly parse metadata', async ({ page }) => {
|
||||
},
|
||||
])
|
||||
await page.goto(`/${typebotId}-public`)
|
||||
await expect(
|
||||
expect(
|
||||
await page.evaluate(`document.querySelector('title').textContent`)
|
||||
).toBe(customMetadata.title)
|
||||
await expect(
|
||||
expect(
|
||||
await page.evaluate(
|
||||
() => (document.querySelector('meta[name="description"]') as any).content
|
||||
)
|
||||
).toBe(customMetadata.description)
|
||||
await expect(
|
||||
expect(
|
||||
await page.evaluate(
|
||||
() => (document.querySelector('meta[property="og:image"]') as any).content
|
||||
)
|
||||
).toBe(customMetadata.imageUrl)
|
||||
await expect(
|
||||
expect(
|
||||
await page.evaluate(() =>
|
||||
(document.querySelector('link[rel="icon"]') as any).getAttribute('href')
|
||||
)
|
||||
|
||||
@@ -3,9 +3,6 @@ import { importTypebotInDatabase } from '../services/database'
|
||||
import cuid from 'cuid'
|
||||
import path from 'path'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
test('should correctly be injected', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
|
||||
@@ -7,9 +7,6 @@ import cuid from 'cuid'
|
||||
import path from 'path'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
import { SmtpCredentialsData } from 'models'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
const mockSmtpCredentials: SmtpCredentialsData = {
|
||||
from: {
|
||||
|
||||
@@ -10,9 +10,6 @@ import {
|
||||
defaultTextInputOptions,
|
||||
InputBlockType,
|
||||
} from 'models'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
test('Result should be in storage by default', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
|
||||
@@ -2,9 +2,6 @@ import test, { expect } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { importTypebotInDatabase } from '../services/database'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
test('should work as expected', async ({ page }) => {
|
||||
const typebotId = 'cl0ibhi7s0018n21aarlmg0cm'
|
||||
|
||||
@@ -4,9 +4,6 @@ import cuid from 'cuid'
|
||||
import path from 'path'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
import { HttpMethod } from 'models'
|
||||
import { mockSessionApiCalls } from 'playwright/services/browser'
|
||||
|
||||
test.beforeEach(({ page }) => mockSessionApiCalls(page))
|
||||
|
||||
test('should execute webhooks properly', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
|
||||
Reference in New Issue
Block a user