2
0

📦 Upgrade packages

This commit is contained in:
Baptiste Arnaud
2022-11-02 19:45:46 +01:00
committed by GitHub
parent 48285479cc
commit 2c66c59dfc
64 changed files with 2518 additions and 3158 deletions

View File

@@ -5,27 +5,27 @@
"scripts": {
"dev": "ENVSH_ENV=.env.local bash ../../env.sh next dev -p 3001",
"build": "next build",
"start": "next start",
"start": "next start -p 3001",
"lint": "next lint",
"test": "pnpm playwright test",
"test:open": "PWDEBUG=1 pnpm playwright test"
"test:report": "pnpm playwright show-report"
},
"dependencies": {
"@sentry/nextjs": "7.15.0",
"aws-sdk": "2.1233.0",
"@sentry/nextjs": "7.17.3",
"aws-sdk": "2.1245.0",
"bot-engine": "*",
"cors": "2.8.5",
"cuid": "2.1.8",
"db": "workspace:*",
"google-spreadsheet": "3.3.0",
"got": "12.5.2",
"next": "12.3.1",
"next": "13.0.1",
"nodemailer": "6.8.0",
"qs": "6.11.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"sanitize-html": "2.7.2",
"stripe": "10.14.0"
"sanitize-html": "2.7.3",
"stripe": "10.15.0"
},
"devDependencies": {
"@babel/preset-env": "7.19.4",
@@ -33,26 +33,27 @@
"@playwright/test": "1.27.1",
"@types/cors": "2.8.12",
"@types/google-spreadsheet": "3.3.0",
"@types/node": "18.11.0",
"@types/node": "18.11.9",
"@types/nodemailer": "6.4.6",
"@types/papaparse": "5.3.5",
"@types/qs": "6.9.7",
"@types/react": "18.0.21",
"@types/react": "18.0.24",
"@types/sanitize-html": "2.6.2",
"@typescript-eslint/eslint-plugin": "5.40.0",
"@typescript-eslint/parser": "5.40.0",
"@typescript-eslint/eslint-plugin": "5.42.0",
"@typescript-eslint/parser": "5.42.0",
"dotenv": "16.0.3",
"emails": "workspace:*",
"eslint": "8.25.0",
"eslint-config-next": "12.3.1",
"eslint": "8.26.0",
"eslint-config-next": "13.0.1",
"eslint-plugin-react": "7.31.10",
"eslint-plugin-react-hooks": "4.6.0",
"google-auth-library": "8.5.2",
"google-auth-library": "8.6.0",
"models": "workspace:*",
"next-transpile-modules": "9.1.0",
"next-transpile-modules": "10.0.0",
"node-fetch": "^3.2.10",
"papaparse": "5.3.2",
"typescript": "4.8.4",
"utils": "workspace:*"
"utils": "workspace:*",
"configs": "workspace:*"
}
}

View File

@@ -1,38 +1,21 @@
import { devices, PlaywrightTestConfig } from '@playwright/test'
import { PlaywrightTestConfig } from '@playwright/test'
import path from 'path'
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('dotenv').config({
path: path.join(__dirname, 'playwright/.env'),
})
import { playwrightBaseConfig } from 'configs/playwright'
const config: PlaywrightTestConfig = {
globalSetup: require.resolve(path.join(__dirname, 'playwright/global-setup')),
...playwrightBaseConfig,
testDir: path.join(__dirname, 'playwright/tests'),
timeout: 10 * 2000,
expect: {
timeout: 5000,
},
retries: process.env.NO_RETRIES ? 0 : 1,
workers: process.env.CI ? 1 : 3,
reporter: 'html',
maxFailures: process.env.CI ? 10 : undefined,
webServer: process.env.CI
? {
...(playwrightBaseConfig.webServer as { command: string }),
port: 3001,
}
: undefined,
use: {
actionTimeout: 0,
baseURL: process.env.VIEWER_URL,
trace: 'on-first-retry',
video: 'retain-on-failure',
locale: 'en-US',
...playwrightBaseConfig.use,
baseURL: process.env.NEXT_PUBLIC_VIEWER_URL,
},
outputDir: path.join(__dirname, 'playwright/test-results/'),
projects: [
{
name: 'Chrome',
use: {
...devices['Desktop Chrome'],
viewport: { width: 1400, height: 1000 },
},
},
],
}
export default config

View File

@@ -1,4 +0,0 @@
VIEWER_URL=http://localhost:3001
BUILDER_URL=http://localhost:3000
DATABASE_URL=postgresql://postgres:typebot@localhost:5432/typebot
ENCRYPTION_SECRET=SgVkYp2s5v8y/B?E(H+MbQeThWmZq4t6 #256-bits secret (can be generated here: https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx)

View File

@@ -1,11 +0,0 @@
import { FullConfig } from '@playwright/test'
import { setupDatabase, teardownDatabase } from 'utils/playwright/databaseSetup'
async function globalSetup(config: FullConfig) {
const { baseURL } = config.projects[0].use
if (!baseURL) throw new Error('baseURL is missing')
await teardownDatabase()
await setupDatabase()
}
export default globalSetup

View File

@@ -1,7 +1,7 @@
import { CredentialsType, SmtpCredentialsData } from 'models'
import { PrismaClient } from 'db'
import { encrypt } from 'utils/api'
import { freeWorkspaceId } from 'utils/playwright/databaseSetup'
import { proWorkspaceId } from 'utils/playwright/databaseSetup'
const prisma = new PrismaClient()
@@ -17,7 +17,7 @@ export const createSmtpCredentials = (
iv,
name: smtpData.from.email as string,
type: CredentialsType.SMTP,
workspaceId: freeWorkspaceId,
workspaceId: proWorkspaceId,
},
})
}

View File

@@ -28,7 +28,7 @@ test('should work as expected', async ({ page, browser }) => {
await expect(
typebotViewer(page).locator(`text="3 files uploaded"`)
).toBeVisible()
await page.goto(`${process.env.BUILDER_URL}/typebots/${typebotId}/results`)
await page.goto(`${process.env.NEXTAUTH_URL}/typebots/${typebotId}/results`)
await expect(page.locator('text="api.json"')).toHaveAttribute(
'href',
/.+\/api\.json/
@@ -52,7 +52,7 @@ test('should work as expected', async ({ page, browser }) => {
const file = readFileSync(downloadPath as string).toString()
const { data } = parse(file)
expect(data).toHaveLength(2)
expect((data[1] as unknown[])[1]).toContain('http://localhost:9000')
expect((data[1] as unknown[])[1]).toContain(process.env.S3_ENDPOINT)
const urls = (
await Promise.all(
@@ -72,17 +72,7 @@ test('should work as expected', async ({ page, browser }) => {
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('span:has-text("The specified key does not exist.")')
).toBeVisible()
await page2.goto(urls[1])
await expect(
page2.locator('span:has-text("The specified key does not exist.")')
).toBeVisible()
await page2.goto(urls[2])
await expect(
page2.locator('span:has-text("The specified key does not exist.")')
).toBeVisible()
await expect(page2.locator('pre')).toBeHidden()
})
// TODO: uncomment on 1st of November
@@ -124,7 +114,7 @@ test('should work as expected', async ({ page, browser }) => {
// await page.evaluate(() =>
// window.localStorage.setItem('workspaceId', 'starterWorkspace')
// )
// await page.goto(`${process.env.BUILDER_URL}/typebots/${typebotId}/results`)
// await page.goto(`${process.env.NEXTAUTH_URL}/typebots/${typebotId}/results`)
// await expect(page.locator('text="150%"')).toBeVisible()
// await expect(page.locator('text="api.json"')).toBeHidden()
// })

View File

@@ -16,7 +16,7 @@ test('should work as expected', async ({ page }) => {
await typebotViewer(page).locator('input').fill('26')
await typebotViewer(page).locator('input').press('Enter')
await typebotViewer(page).locator('button >> text=Yes').click()
await page.goto(`${process.env.BUILDER_URL}/typebots/${typebotId}/results`)
await page.goto(`${process.env.NEXTAUTH_URL}/typebots/${typebotId}/results`)
await expect(page.locator('text="Baptiste"')).toBeVisible()
await expect(page.locator('text="26"')).toBeVisible()
await expect(page.locator('text="Yes"')).toBeVisible()

View File

@@ -17,10 +17,17 @@ const mockSmtpCredentials: SmtpCredentialsData = {
password: 'yXZChpPy25Qa5yBbeH',
}
test.beforeAll(async () => {
try {
const credentialsId = 'send-email-credentials'
await createSmtpCredentials(credentialsId, mockSmtpCredentials)
} catch (err) {
console.error(err)
}
})
test('should send an email', async ({ page }) => {
const typebotId = cuid()
const credentialsId = 'send-email-credentials'
await createSmtpCredentials(credentialsId, mockSmtpCredentials)
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/sendEmail.json'),
{ id: typebotId, publicId: `${typebotId}-public` }
@@ -41,7 +48,7 @@ test('should send an email', async ({ page }) => {
await expect(
page.locator('text="<baptiste.arnaud95@gmail.com>" >> nth=0')
).toBeVisible()
await page.goto(`${process.env.BUILDER_URL}/typebots/${typebotId}/results`)
await page.goto(`${process.env.NEXTAUTH_URL}/typebots/${typebotId}/results`)
await page.click('text="See logs"')
await expect(page.locator('text="Email successfully sent"')).toBeVisible()
})

View File

@@ -3,18 +3,25 @@ import path from 'path'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { typebotViewer } from 'utils/playwright/testHelpers'
test('should work as expected', async ({ page }) => {
const typebotId = 'cl0ibhi7s0018n21aarlmg0cm'
const linkedTypebotId = 'cl0ibhv8d0130n21aw8doxhj5'
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/linkTypebots/1.json'),
{ id: typebotId, publicId: `${typebotId}-public` }
)
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/linkTypebots/2.json'),
{ id: linkedTypebotId, publicId: `${linkedTypebotId}-public` }
)
const typebotId = 'cl0ibhi7s0018n21aarlmg0cm'
const linkedTypebotId = 'cl0ibhv8d0130n21aw8doxhj5'
test.beforeAll(async () => {
try {
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/linkTypebots/1.json'),
{ id: typebotId, publicId: `${typebotId}-public` }
)
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/linkTypebots/2.json'),
{ id: linkedTypebotId, publicId: `${linkedTypebotId}-public` }
)
} catch (err) {
console.error(err)
}
})
test('should work as expected', async ({ page }) => {
await page.goto(`/${typebotId}-public`)
await typebotViewer(page).locator('input').fill('Hello there!')
await Promise.all([
@@ -26,6 +33,6 @@ test('should work as expected', async ({ page }) => {
),
typebotViewer(page).locator('input').press('Enter'),
])
await page.goto(`${process.env.BUILDER_URL}/typebots/${typebotId}/results`)
await page.goto(`${process.env.NEXTAUTH_URL}/typebots/${typebotId}/results`)
await expect(page.locator('text=Hello there!')).toBeVisible()
})

View File

@@ -4,12 +4,15 @@ import path from 'path'
import { HttpMethod } from 'models'
import {
createWebhook,
deleteTypebots,
deleteWebhooks,
importTypebotInDatabase,
} from 'utils/playwright/databaseActions'
import { typebotViewer } from 'utils/playwright/testHelpers'
test('should execute webhooks properly', async ({ page }) => {
const typebotId = cuid()
const typebotId = cuid()
test.beforeEach(async () => {
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/webhook.json'),
{ id: typebotId, publicId: `${typebotId}-public` }
@@ -38,7 +41,18 @@ test('should execute webhooks properly', async ({ page }) => {
method: HttpMethod.POST,
body: `{{Full body}}`,
})
})
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()
await typebotViewer(page)