2
0

feat(user): Revokable API tokens

This commit is contained in:
Baptiste Arnaud
2022-06-03 13:20:19 +02:00
parent e5d7f1d1ce
commit a0929c492b
20 changed files with 472 additions and 43 deletions

View File

@ -62,6 +62,27 @@ export const createUsers = async () => {
email: 'pro-user@email.com',
name: 'Pro user',
graphNavigation: GraphNavigation.TRACKPAD,
apiTokens: {
createMany: {
data: [
{
name: 'Token 1',
token: 'jirowjgrwGREHEtoken1',
createdAt: new Date(2022, 1, 1),
},
{
name: 'Github',
token: 'jirowjgrwGREHEgdrgithub',
createdAt: new Date(2022, 1, 2),
},
{
name: 'N8n',
token: 'jirowjgrwGREHrgwhrwn8n',
createdAt: new Date(2022, 1, 3),
},
],
},
},
workspaces: {
create: {
role: WorkspaceRole.ADMIN,
@ -99,7 +120,7 @@ export const createUsers = async () => {
await prisma.workspace.create({
data: {
id: freeWorkspaceId,
name: 'Free Shared Workspace',
name: 'Free Shared workspace',
plan: Plan.FREE,
members: {
createMany: {
@ -114,7 +135,7 @@ export const createUsers = async () => {
return prisma.workspace.create({
data: {
id: sharedWorkspaceId,
name: 'Shared Workspace',
name: 'Shared workspace',
plan: Plan.TEAM,
members: {
createMany: {

View File

@ -26,3 +26,23 @@ test('should display user info properly', async ({ page }) => {
await page.click('text="Preferences"')
await expect(page.locator('text=Trackpad')).toBeVisible()
})
test('should be able to create and delete api tokens', async ({ page }) => {
await page.goto('/typebots')
await page.click('text=Settings & Members')
await expect(page.locator('text=Github')).toBeVisible()
await page.click('text="Create"')
await expect(page.locator('button >> text="Create token"')).toBeDisabled()
await page.fill('[placeholder="I.e. Zapier, Github, Make.com"]', 'CLI')
await expect(page.locator('button >> text="Create token"')).toBeEnabled()
await page.click('button >> text="Create token"')
await expect(page.locator('text=Please copy your token')).toBeVisible()
await expect(page.locator('button >> text="Copy"')).toBeVisible()
await page.click('button >> text="Done"')
await expect(page.locator('text=CLI')).toBeVisible()
await page.click('text="Delete" >> nth=2')
await expect(page.locator('strong >> text="Github"')).toBeVisible()
await page.click('button >> text="Delete" >> nth=-1')
await expect(page.locator('button >> text="Delete" >> nth=-1')).toBeEnabled()
await expect(page.locator('text="Github"')).toBeHidden()
})

View File

@ -80,8 +80,6 @@ test.describe('Dashboard page', () => {
})
test("create folder shouldn't be available", async ({ page }) => {
await page.goto('/typebots')
await page.click('text=Shared workspace')
await page.click('text=Free workspace')
await page.click('text=Create a folder')
await expect(page.locator('text=For solo creator')).toBeVisible()
})