feat: ✨ Add collaboration
This commit is contained in:
@ -6,7 +6,11 @@
|
||||
"localStorage": [
|
||||
{
|
||||
"name": "authenticatedUser",
|
||||
"value": "{\"id\":\"freeUser\",\"name\":\"John Smith\",\"email\":\"john@smith.fr\",\"emailVerified\":null,\"image\":\"https://avatars.githubusercontent.com/u/16015833?v=4\",\"plan\":\"FREE\",\"stripeId\":null}"
|
||||
"value": "{\"id\":\"freeUser\",\"name\":\"Free user\",\"email\":\"free-user@email.com\",\"emailVerified\":null,\"image\":\"https://avatars.githubusercontent.com/u/16015833?v=4\",\"plan\":\"FREE\",\"stripeId\":null}"
|
||||
},
|
||||
{
|
||||
"name": "typebot-20-modal",
|
||||
"value": "hide"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -6,7 +6,11 @@
|
||||
"localStorage": [
|
||||
{
|
||||
"name": "authenticatedUser",
|
||||
"value": "{\"id\":\"proUser\",\"name\":\"John Smith\",\"email\":\"john@smith.com\",\"emailVerified\":null,\"image\":\"https://avatars.githubusercontent.com/u/16015833?v=4\",\"plan\":\"PRO\",\"stripeId\":null}"
|
||||
"value": "{\"id\":\"proUser\",\"name\":\"Pro user\",\"email\":\"pro-user@email.com\",\"emailVerified\":null,\"image\":\"https://avatars.githubusercontent.com/u/16015833?v=4\",\"plan\":\"PRO\",\"stripeId\":null}"
|
||||
},
|
||||
{
|
||||
"name": "typebot-20-modal",
|
||||
"value": "hide"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
Step,
|
||||
Typebot,
|
||||
} from 'models'
|
||||
import { DashboardFolder, PrismaClient, User } from 'db'
|
||||
import { CollaborationType, DashboardFolder, PrismaClient, User } from 'db'
|
||||
import { readFileSync } from 'fs'
|
||||
import { encrypt } from 'utils'
|
||||
|
||||
@ -39,6 +39,13 @@ export const createUsers = () =>
|
||||
],
|
||||
})
|
||||
|
||||
export const createCollaboration = (
|
||||
userId: string,
|
||||
typebotId: string,
|
||||
type: CollaborationType
|
||||
) =>
|
||||
prisma.collaboratorsOnTypebots.create({ data: { userId, typebotId, type } })
|
||||
|
||||
export const getSignedInUser = (email: string) =>
|
||||
prisma.user.findFirst({ where: { email } })
|
||||
|
||||
|
71
apps/builder/playwright/tests/collaboration.spec.ts
Normal file
71
apps/builder/playwright/tests/collaboration.spec.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import { InputStepType, defaultTextInputOptions } from 'models'
|
||||
import path from 'path'
|
||||
import { generate } from 'short-uuid'
|
||||
import { createTypebots, parseDefaultBlockWithStep } from '../services/database'
|
||||
|
||||
const typebotId = generate()
|
||||
|
||||
test.beforeAll(async () => {
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
name: 'Shared typebot',
|
||||
ownerId: 'freeUser',
|
||||
...parseDefaultBlockWithStep({
|
||||
type: InputStepType.TEXT,
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
test.describe('Typebot owner', () => {
|
||||
test.use({
|
||||
storageState: path.join(__dirname, '../freeUser.json'),
|
||||
})
|
||||
test('Can invite collaborators', async ({ page }) => {
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('button[aria-label="Show collaboration menu"]')
|
||||
await expect(page.locator('text=Free user')).toBeHidden()
|
||||
await page.fill(
|
||||
'input[placeholder="colleague@company.com"]',
|
||||
'guest@email.com'
|
||||
)
|
||||
await page.click('text=Can view')
|
||||
await page.click('text=Can edit')
|
||||
await page.click('text=Invite')
|
||||
await expect(page.locator('text=Pending')).toBeVisible()
|
||||
await expect(page.locator('text=Free user')).toBeHidden()
|
||||
await page.fill(
|
||||
'input[placeholder="colleague@company.com"]',
|
||||
'pro-user@email.com'
|
||||
)
|
||||
await page.click('text=Can edit')
|
||||
await page.click('text=Can view')
|
||||
await page.click('text=Invite')
|
||||
await expect(page.locator('text=Free user')).toBeVisible()
|
||||
await expect(page.locator('text=Pro user')).toBeVisible()
|
||||
await page.click('text="guest@email.com"')
|
||||
await page.click('text="Remove"')
|
||||
await expect(page.locator('text="guest@email.com"')).toBeHidden()
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('Collaborator', () => {
|
||||
test('should display shared typebots', async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
await expect(page.locator('text=Shared')).toBeVisible()
|
||||
await page.click('text=Shared')
|
||||
await page.waitForNavigation()
|
||||
expect(page.url()).toMatch('/typebots/shared')
|
||||
await expect(page.locator('text="Shared typebot"')).toBeVisible()
|
||||
await page.click('text=Shared typebot')
|
||||
await page.click('button[aria-label="Show collaboration menu"]')
|
||||
await page.click('text=Pro user')
|
||||
await expect(page.locator('text="Remove"')).toBeHidden()
|
||||
await expect(page.locator('text=Free user')).toBeVisible()
|
||||
await page.click('text=Block #1', { force: true })
|
||||
await expect(page.locator('input[value="Block #1"]')).toBeHidden()
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user