Skip to content

Commit

Permalink
📦 Update cuid to cuid2
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 10, 2023
1 parent 2dbf0fb commit 51f7670
Show file tree
Hide file tree
Showing 77 changed files with 254 additions and 250 deletions.
2 changes: 1 addition & 1 deletion apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"canvas-confetti": "1.6.0",
"chakra-react-select": "^4.4.3",
"codemirror": "6.0.1",
"cuid": "3.0.0",
"@paralleldrive/cuid2": "2.0.1",
"deep-object-diff": "1.1.9",
"dequal": "2.0.3",
"emails": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/TableList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Button, Fade, Flex, IconButton, Stack } from '@chakra-ui/react'
import { TrashIcon, PlusIcon } from '@/components/icons'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import React, { useState } from 'react'

type ItemWithId<T> = T & { id: string }
Expand Down Expand Up @@ -32,7 +32,7 @@ export const TableList = <T,>({
const [showDeleteIndex, setShowDeleteIndex] = useState<number | null>(null)

const createItem = () => {
const id = cuid()
const id = createId()
const newItem = { id } as ItemWithId<T>
setItems([...items, newItem])
onItemsChange([...items, newItem])
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/VariableSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@chakra-ui/react'
import { EditIcon, PlusIcon, TrashIcon } from '@/components/icons'
import { useTypebot } from '@/features/editor/providers/TypebotProvider/TypebotProvider'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { Variable } from 'models'
import React, { useState, useRef, ChangeEvent, useEffect } from 'react'
import { byId, isDefined, isNotDefined } from 'utils'
Expand Down Expand Up @@ -90,7 +90,7 @@ export const VariableSearchInput = ({

const handleCreateNewVariableClick = () => {
if (!inputValue || inputValue === '') return
const id = 'v' + cuid()
const id = 'v' + createId()
onSelectVariable({ id, name: inputValue })
createVariable({ id, name: inputValue })
inputRef.current?.blur()
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/analytics/analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { getTestAsset } from '@/test/utils/playwright'
import test, { expect } from '@playwright/test'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import {
importTypebotInDatabase,
injectFakeResults,
} from 'utils/playwright/databaseActions'
import { starterWorkspaceId } from 'utils/playwright/databaseSetup'

test('analytics are not available for non-pro workspaces', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await importTypebotInDatabase(
getTestAsset('typebots/results/submissionHeader.json'),
{
Expand Down
10 changes: 5 additions & 5 deletions apps/builder/src/features/billing/billing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createClaimableCustomPlan,
} from '@/test/utils/databaseActions'
import test, { expect } from '@playwright/test'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { Plan } from 'db'
import {
createTypebots,
Expand All @@ -12,10 +12,10 @@ import {
injectFakeResults,
} from 'utils/playwright/databaseActions'

const usageWorkspaceId = cuid()
const usageTypebotId = cuid()
const planChangeWorkspaceId = cuid()
const enterpriseWorkspaceId = cuid()
const usageWorkspaceId = createId()
const usageTypebotId = createId()
const planChangeWorkspaceId = createId()
const enterpriseWorkspaceId = createId()

test.beforeAll(async () => {
await createWorkspaces([
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/blocks/bubbles/audio/audio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import test, { expect } from '@playwright/test'
import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { BubbleBlockType, defaultAudioBubbleContent } from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
import { typebotViewer } from 'utils/playwright/testHelpers'

const audioSampleUrl =
'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3'

test('should work as expected', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
6 changes: 3 additions & 3 deletions apps/builder/src/features/blocks/bubbles/embed/embed.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test, { expect } from '@playwright/test'
import { BubbleBlockType, defaultEmbedBubbleContent } from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { typebotViewer } from 'utils/playwright/testHelpers'
Expand All @@ -11,7 +11,7 @@ const siteSrc = 'https://app.cal.com/baptistearno/15min'
test.describe.parallel('Embed bubble block', () => {
test.describe('Content settings', () => {
test('should import and parse embed correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand All @@ -31,7 +31,7 @@ test.describe.parallel('Embed bubble block', () => {

test.describe('Preview', () => {
test('should display embed correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
10 changes: 5 additions & 5 deletions apps/builder/src/features/blocks/bubbles/image/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test, { expect } from '@playwright/test'
import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { BubbleBlockType, defaultImageBubbleContent } from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { getTestAsset } from '@/test/utils/playwright'

Expand All @@ -12,7 +12,7 @@ const unsplashImageSrc =
test.describe.parallel('Image bubble block', () => {
test.describe('Content settings', () => {
test('should upload image file correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand All @@ -34,7 +34,7 @@ test.describe.parallel('Image bubble block', () => {
})

test('should import image link correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand All @@ -57,7 +57,7 @@ test.describe.parallel('Image bubble block', () => {
})

test('should import gifs correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down Expand Up @@ -102,7 +102,7 @@ test.describe.parallel('Image bubble block', () => {

test.describe('Preview', () => {
test('should display correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import test, { expect } from '@playwright/test'
import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { BubbleBlockType, defaultTextBubbleContent } from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { typebotViewer } from 'utils/playwright/testHelpers'

test.describe('Text bubble block', () => {
test('rich text features should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
10 changes: 5 additions & 5 deletions apps/builder/src/features/blocks/bubbles/video/video.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
defaultVideoBubbleContent,
VideoBubbleContentType,
} from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { typebotViewer } from 'utils/playwright/testHelpers'

const videoSrc =
Expand All @@ -17,7 +17,7 @@ const vimeoVideoSrc = 'https://vimeo.com/649301125'
test.describe.parallel('Video bubble block', () => {
test.describe('Content settings', () => {
test('should import video url correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand All @@ -41,7 +41,7 @@ test.describe.parallel('Video bubble block', () => {

test.describe('Preview', () => {
test('should display video correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand All @@ -63,7 +63,7 @@ test.describe.parallel('Video bubble block', () => {
})

test('should display youtube video correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand All @@ -87,7 +87,7 @@ test.describe.parallel('Video bubble block', () => {
})

test('should display vimeo video correctly', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
} from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultChoiceInputOptions, InputBlockType, ItemType } from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { getTestAsset } from '@/test/utils/playwright'

test.describe.parallel('Buttons input block', () => {
test('can edit button items', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down Expand Up @@ -75,7 +75,7 @@ test.describe.parallel('Buttons input block', () => {
})

test('Variable buttons should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await importTypebotInDatabase(
getTestAsset('typebots/inputs/variableButton.json'),
{
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/blocks/inputs/date/date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultDateInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'

test.describe('Date input block', () => {
test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultEmailInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'

test.describe('Email input block', () => {
test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultFileInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { freeWorkspaceId } from 'utils/playwright/databaseSetup'
import { getTestAsset } from '@/test/utils/playwright'

test.describe.configure({ mode: 'parallel' })

test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down Expand Up @@ -59,7 +59,7 @@ test('options should work', async ({ page }) => {

test.describe('Free workspace', () => {
test("shouldn't be able to publish typebot", async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/blocks/inputs/number/number.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultNumberInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'

test.describe('Number input block', () => {
test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import test, { expect } from '@playwright/test'
import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultPaymentInputOptions, InputBlockType } from 'models'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { stripePaymentForm } from '@/test/utils/selectorUtils'

test.describe('Payment input block', () => {
test('Can configure Stripe account', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/blocks/inputs/phone/phone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultPhoneInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'

test.describe('Phone input block', () => {
test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/features/blocks/inputs/rating/rating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultRatingInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'

const boxSvg = `<svg
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -19,7 +19,7 @@ const boxSvg = `<svg
</svg>`

test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createTypebots } from 'utils/playwright/databaseActions'
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
import { defaultTextInputOptions, InputBlockType } from 'models'
import { typebotViewer } from 'utils/playwright/testHelpers'
import cuid from 'cuid'
import { createId } from '@paralleldrive/cuid2'

test.describe.parallel('Text input block', () => {
test('options should work', async ({ page }) => {
const typebotId = cuid()
const typebotId = createId()
await createTypebots([
{
id: typebotId,
Expand Down
Loading

0 comments on commit 51f7670

Please sign in to comment.