2
0
Files
bot/apps/builder/playwright/tests/account.spec.ts

49 lines
1.7 KiB
TypeScript
Raw Normal View History

import test, { expect } from '@playwright/test'
import { refreshUser } from '../services/browser'
import { Plan } from 'db'
import path from 'path'
2022-01-28 17:57:14 +01:00
import { updateUser } from '../services/database'
test.describe('Account page', () => {
test('should edit user info properly', async ({ page }) => {
await updateUser({ name: 'Default Name' })
await page.goto('/account')
const saveButton = page.locator('button:has-text("Save")')
await expect(saveButton).toBeHidden()
await expect(
page.locator('input[type="email"]').getAttribute('disabled')
).toBeDefined()
await page.fill('#name', 'John Doe')
expect(saveButton).toBeVisible()
await page.setInputFiles(
'input[type="file"]',
path.join(__dirname, '../fixtures/avatar.jpg')
)
2022-01-28 17:57:14 +01:00
await expect(page.locator('img')).toHaveAttribute(
'src',
new RegExp(
2022-01-28 17:57:14 +01:00
`https://s3.eu-west-3.amazonaws.com/typebot/users/${process.env.PLAYWRIGHT_USER_ID}/avatar`,
'gm'
)
)
await saveButton.click()
await expect(saveButton).toBeHidden()
})
test('should display valid plans', async ({ page }) => {
await updateUser({ plan: Plan.FREE, stripeId: null })
await page.goto('/account')
await expect(page.locator('text=Free plan')).toBeVisible()
await page.evaluate(refreshUser)
await page.reload()
const manageSubscriptionButton = page.locator(
'a:has-text("Manage my subscription")'
)
await expect(manageSubscriptionButton).toBeHidden()
await updateUser({ plan: Plan.PRO, stripeId: 'stripeId' })
await page.reload()
await expect(page.locator('text=Pro plan')).toBeVisible()
await expect(manageSubscriptionButton).toBeVisible()
})
})