♻️ Add shared eslint config
This commit is contained in:
4
packages/utils/.eslintrc.js
Normal file
4
packages/utils/.eslintrc.js
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['custom'],
|
||||
}
|
@ -11,11 +11,12 @@
|
||||
"aws-sdk": "2.1254.0",
|
||||
"cuid": "2.1.8",
|
||||
"db": "workspace:*",
|
||||
"dotenv": "16.0.3",
|
||||
"models": "workspace:*",
|
||||
"next": "13.0.3",
|
||||
"nodemailer": "6.8.0",
|
||||
"typescript": "4.8.4",
|
||||
"tsconfig": "workspace:*"
|
||||
"tsconfig": "workspace:*",
|
||||
"typescript": "4.8.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"aws-sdk": "2.1152.0",
|
||||
|
51
packages/utils/playwright/baseConfig.ts
Normal file
51
packages/utils/playwright/baseConfig.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { PlaywrightTestConfig } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
|
||||
const builderLocalEnvPath = path.join(
|
||||
__dirname,
|
||||
'../../../apps/builder/.env.local'
|
||||
)
|
||||
const localViewerEnvPath = path.join(
|
||||
__dirname,
|
||||
'../../../apps/viewer/.env.local'
|
||||
)
|
||||
if (fs.existsSync(builderLocalEnvPath))
|
||||
require('dotenv').config({
|
||||
path: builderLocalEnvPath,
|
||||
})
|
||||
|
||||
if (fs.existsSync(localViewerEnvPath))
|
||||
require('dotenv').config({
|
||||
path: localViewerEnvPath,
|
||||
})
|
||||
|
||||
export const playwrightBaseConfig: PlaywrightTestConfig = {
|
||||
globalSetup: require.resolve(path.join(__dirname, 'globalSetup')),
|
||||
timeout: process.env.CI ? 50 * 1000 : 20 * 1000,
|
||||
expect: {
|
||||
timeout: process.env.CI ? 10 * 1000 : 5 * 1000,
|
||||
},
|
||||
retries: process.env.NO_RETRIES ? 0 : 1,
|
||||
workers: process.env.CI ? 2 : 3,
|
||||
reporter: [
|
||||
[process.env.CI ? 'github' : 'list'],
|
||||
['html', { outputFolder: 'src/test/reporters' }],
|
||||
],
|
||||
maxFailures: process.env.CI ? 10 : undefined,
|
||||
webServer: process.env.CI
|
||||
? {
|
||||
command: 'pnpm run start',
|
||||
timeout: 60_000,
|
||||
reuseExistingServer: true,
|
||||
}
|
||||
: undefined,
|
||||
outputDir: './src/test/results',
|
||||
use: {
|
||||
trace: 'on-first-retry',
|
||||
video: 'retain-on-failure',
|
||||
locale: 'en-US',
|
||||
browserName: 'chromium',
|
||||
viewport: { width: 1400, height: 1000 },
|
||||
},
|
||||
}
|
11
packages/utils/playwright/globalSetup.ts
Normal file
11
packages/utils/playwright/globalSetup.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { FullConfig } from '@playwright/test'
|
||||
import { setupDatabase, teardownDatabase } from './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
|
@ -169,7 +169,7 @@ const europeanUnionExclusiveLanguageCodes = [
|
||||
]
|
||||
|
||||
export const guessIfUserIsEuropean = () =>
|
||||
navigator.languages.some((language) => {
|
||||
window.navigator.languages.some((language) => {
|
||||
const [languageCode, countryCode] = language.split('-')
|
||||
return countryCode
|
||||
? europeanUnionCountryCodes.includes(countryCode)
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
Answer,
|
||||
VariableWithValue,
|
||||
Typebot,
|
||||
ResultWithAnswersInput,
|
||||
} from 'models'
|
||||
import { isInputBlock, isDefined, byId } from './utils'
|
||||
|
||||
@ -177,14 +178,16 @@ export const parseAnswers =
|
||||
createdAt,
|
||||
answers,
|
||||
variables: resultVariables,
|
||||
}: Pick<ResultWithAnswers, 'answers' | 'variables'> & {
|
||||
createdAt: string
|
||||
}: Pick<ResultWithAnswersInput, 'answers' | 'variables'> & {
|
||||
// TODO: remove once we are using 100% tRPC
|
||||
createdAt: Date | string
|
||||
}): {
|
||||
[key: string]: string
|
||||
} => {
|
||||
const header = parseResultHeader(typebot, linkedTypebots)
|
||||
return {
|
||||
submittedAt: createdAt,
|
||||
submittedAt:
|
||||
typeof createdAt === 'string' ? createdAt : createdAt.toISOString(),
|
||||
...[...answers, ...resultVariables].reduce<{
|
||||
[key: string]: string
|
||||
}>((o, answerOrVariable) => {
|
||||
|
Reference in New Issue
Block a user