2
0

refactor: ♻️ Migrate from short-uuid to cuid lib

This commit is contained in:
Baptiste Arnaud
2022-03-18 12:30:42 +01:00
parent 64bafd15a1
commit 1423c14547
47 changed files with 120 additions and 132 deletions

View File

@ -6,7 +6,7 @@ import {
import { BubbleStepType, defaultImageBubbleContent } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import path from 'path'
import { generate } from 'short-uuid'
import cuid from 'cuid'
const unsplashImageSrc =
'https://images.unsplash.com/photo-1504297050568-910d24c426d3?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1287&q=80'
@ -14,7 +14,7 @@ const unsplashImageSrc =
test.describe.parallel('Image bubble step', () => {
test.describe('Content settings', () => {
test('should upload image file correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -42,7 +42,7 @@ test.describe.parallel('Image bubble step', () => {
})
test('should import image link correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -65,7 +65,7 @@ test.describe.parallel('Image bubble step', () => {
})
test('should import gifs correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -90,7 +90,7 @@ test.describe.parallel('Image bubble step', () => {
test.describe('Preview', () => {
test('should display correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { BubbleStepType, defaultTextBubbleContent } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Text bubble step', () => {
test('rich text features should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -9,7 +9,7 @@ import {
VideoBubbleContentType,
} from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
const videoSrc =
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4'
@ -19,7 +19,7 @@ const vimeoVideoSrc = 'https://vimeo.com/649301125'
test.describe.parallel('Video bubble step', () => {
test.describe('Content settings', () => {
test('should import video url correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -43,7 +43,7 @@ test.describe.parallel('Video bubble step', () => {
test.describe('Preview', () => {
test('should display video correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -65,7 +65,7 @@ test.describe.parallel('Video bubble step', () => {
})
test('should display youtube video correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -89,7 +89,7 @@ test.describe.parallel('Video bubble step', () => {
})
test('should display vimeo video correctly', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -1,10 +1,10 @@
import test, { expect } from '@playwright/test'
import cuid from 'cuid'
import { InputStepType, defaultTextInputOptions } from 'models'
import path from 'path'
import { generate } from 'short-uuid'
import { createTypebots, parseDefaultBlockWithStep } from '../services/database'
const typebotId = generate()
const typebotId = cuid()
test.beforeAll(async () => {
await createTypebots([

View File

@ -1,10 +1,10 @@
import test, { expect } from '@playwright/test'
import { InputStepType, defaultTextInputOptions } from 'models'
import { createTypebots, parseDefaultBlockWithStep } from '../services/database'
import { generate } from 'short-uuid'
import path from 'path'
import cuid from 'cuid'
const typebotId = generate()
const typebotId = cuid()
test.describe('Dashboard page', () => {
test('should be able to connect custom domain', async ({ page }) => {
await createTypebots([

View File

@ -1,6 +1,6 @@
import test, { expect, Page } from '@playwright/test'
import cuid from 'cuid'
import path from 'path'
import { generate } from 'short-uuid'
import { createFolders, createTypebots } from '../services/database'
import { deleteButtonInConfirmDialog } from '../services/selectorUtils'
@ -49,7 +49,7 @@ test.describe('Dashboard page', () => {
})
test('folders and typebots should be movable', async ({ page }) => {
const droppableFolderId = generate()
const droppableFolderId = cuid()
await createFolders([{ id: droppableFolderId, name: 'Droppable folder' }])
await createTypebots([{ name: 'Draggable typebot' }])
await page.goto('/typebots')

View File

@ -5,12 +5,12 @@ import {
parseDefaultBlockWithStep,
} from '../services/database'
import { defaultTextInputOptions, InputStepType } from 'models'
import { generate } from 'short-uuid'
import path from 'path'
import cuid from 'cuid'
test.describe.parallel('Editor', () => {
test('Edges connection should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -57,7 +57,7 @@ test.describe.parallel('Editor', () => {
expect(total).toBe(1)
})
test('Drag and drop steps and items should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/editor/buttonsDnd.json'),
{
@ -98,7 +98,7 @@ test.describe.parallel('Editor', () => {
)
})
test('Undo / Redo buttons should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultChoiceInputOptions, InputStepType, ItemType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe.parallel('Buttons input step', () => {
test('can edit button items', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultDateInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Date input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultEmailInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Email input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultNumberInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Number input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultPhoneInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Phone input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultTextInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe.parallel('Text input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,
@ -43,7 +43,7 @@ test.describe.parallel('Text input step', () => {
})
test('variable in URL should prefill the input', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -5,11 +5,11 @@ import {
} from '../../services/database'
import { defaultUrlInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Url input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -4,11 +4,11 @@ import {
parseDefaultBlockWithStep,
} from '../../services/database'
import { defaultGoogleAnalyticsOptions, IntegrationStepType } from 'models'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe('Google Analytics step', () => {
test('its configuration should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await createTypebots([
{
id: typebotId,

View File

@ -2,11 +2,11 @@ import test, { expect, Page } from '@playwright/test'
import { importTypebotInDatabase } from '../../services/database'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import cuid from 'cuid'
test.describe.parallel('Google sheets integration', () => {
test('Insert row should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(
__dirname,
@ -56,7 +56,7 @@ test.describe.parallel('Google sheets integration', () => {
})
test('Update row should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(
__dirname,
@ -106,7 +106,7 @@ test.describe.parallel('Google sheets integration', () => {
})
test('Get row should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(
__dirname,

View File

@ -1,10 +1,10 @@
import test, { expect } from '@playwright/test'
import { importTypebotInDatabase } from '../../services/database'
import path from 'path'
import { generate } from 'short-uuid'
import { typebotViewer } from '../../services/selectorUtils'
import cuid from 'cuid'
const typebotId = generate()
const typebotId = cuid()
test.describe('Send email step', () => {
test('its configuration should work', async ({ page }) => {

View File

@ -1,12 +1,12 @@
import test, { expect, Page } from '@playwright/test'
import { createWebhook, importTypebotInDatabase } from '../../services/database'
import path from 'path'
import { generate } from 'short-uuid'
import { HttpMethod } from 'models'
import cuid from 'cuid'
test.describe('Webhook step', () => {
test('easy configuration should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/integrations/webhook.json'),
{
@ -26,7 +26,7 @@ test.describe('Webhook step', () => {
)
})
test('Generated body should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/integrations/webhook.json'),
{
@ -51,7 +51,7 @@ test.describe('Webhook step', () => {
)
})
test('its configuration should work', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/integrations/webhook.json'),
{

View File

@ -2,9 +2,9 @@ import test, { expect } from '@playwright/test'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
import { importTypebotInDatabase } from '../../services/database'
import { generate } from 'short-uuid'
import cuid from 'cuid'
const typebotId = generate()
const typebotId = cuid()
test.describe('Code step', () => {
test('code should trigger', async ({ page }) => {

View File

@ -2,9 +2,9 @@ import test, { expect } from '@playwright/test'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
import { importTypebotInDatabase } from '../../services/database'
import { generate } from 'short-uuid'
import cuid from 'cuid'
const typebotId = generate()
const typebotId = cuid()
test.describe('Condition step', () => {
test('its configuration should work', async ({ page }) => {

View File

@ -2,9 +2,9 @@ import test, { expect } from '@playwright/test'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
import { importTypebotInDatabase } from '../../services/database'
import { generate } from 'short-uuid'
import cuid from 'cuid'
const typebotId = generate()
const typebotId = cuid()
test.describe('Redirect step', () => {
test('its configuration should work', async ({ page, context }) => {

View File

@ -2,9 +2,9 @@ import test, { expect } from '@playwright/test'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
import { importTypebotInDatabase } from '../../services/database'
import { generate } from 'short-uuid'
import cuid from 'cuid'
const typebotId = generate()
const typebotId = cuid()
test.describe('Set variable step', () => {
test('its configuration should work', async ({ page }) => {

View File

@ -1,12 +1,12 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import { importTypebotInDatabase } from '../../services/database'
import path from 'path'
import cuid from 'cuid'
test('should be configurable', async ({ page }) => {
const typebotId = generate()
const linkedTypebotId = generate()
const typebotId = cuid()
const linkedTypebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/logic/linkTypebots/1.json'),
{ id: typebotId }

View File

@ -1,9 +1,9 @@
import test, { expect, Page } from '@playwright/test'
import cuid from 'cuid'
import { readFileSync } from 'fs'
import { defaultTextInputOptions, InputStepType } from 'models'
import { parse } from 'papaparse'
import path from 'path'
import { generate } from 'short-uuid'
import {
createResults,
createTypebots,
@ -12,13 +12,13 @@ import {
} from '../services/database'
import { deleteButtonInConfirmDialog } from '../services/selectorUtils'
const typebotId = generate()
const typebotId = cuid()
test.describe('Results page', () => {
test('Submission table header should be parsed correctly', async ({
page,
}) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(
__dirname,

View File

@ -1,14 +1,14 @@
import test, { expect } from '@playwright/test'
import cuid from 'cuid'
import { defaultTextInputOptions } from 'models'
import path from 'path'
import { generate } from 'short-uuid'
import { importTypebotInDatabase } from '../services/database'
import { typebotViewer } from '../services/selectorUtils'
test.describe.parallel('Settings page', () => {
test.describe('General', () => {
test('should reflect change in real-time', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/settings.json'),
{
@ -48,7 +48,7 @@ test.describe.parallel('Settings page', () => {
test.describe('Typing emulation', () => {
test('should be fillable', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/settings.json'),
{

View File

@ -1,6 +1,6 @@
import test, { expect } from '@playwright/test'
import cuid from 'cuid'
import path from 'path'
import { generate } from 'short-uuid'
import { importTypebotInDatabase } from '../services/database'
import { typebotViewer } from '../services/selectorUtils'
@ -12,7 +12,7 @@ const guestAvatarUrl =
test.describe.parallel('Theme page', () => {
test.describe('General', () => {
test('should reflect change in real-time', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
const chatContainer = typebotViewer(page).locator(
'[data-testid="container"]'
)
@ -160,7 +160,7 @@ test.describe.parallel('Theme page', () => {
test.describe('Custom CSS', () => {
test('should reflect change in real-time', async ({ page }) => {
const typebotId = generate()
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/theme.json'),
{