2
0

ci(e2e): 💚 Incomplete results

This commit is contained in:
Baptiste Arnaud
2022-02-14 20:40:55 +01:00
parent 714f7c8ce5
commit e6f6e2523c
3 changed files with 4 additions and 3 deletions

View File

@ -29,7 +29,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
typebotId, typebotId,
typebot: { ownerId: user.id }, typebot: { ownerId: user.id },
answers: { some: {} }, answers: { some: {} },
isCompleted: isFreePlan(user), isCompleted: isFreePlan(user) ? false : undefined,
}, },
orderBy: { orderBy: {
createdAt: 'desc', createdAt: 'desc',

View File

@ -98,13 +98,14 @@ export const createResults = async ({ typebotId }: { typebotId: string }) => {
data: [ data: [
...Array.from(Array(200)).map((_, idx) => { ...Array.from(Array(200)).map((_, idx) => {
const today = new Date() const today = new Date()
const rand = Math.random()
return { return {
id: `result${idx}`, id: `result${idx}`,
typebotId, typebotId,
createdAt: new Date( createdAt: new Date(
today.setTime(today.getTime() + 1000 * 60 * 60 * 24 * idx) today.setTime(today.getTime() + 1000 * 60 * 60 * 24 * idx)
), ),
isCompleted: false, isCompleted: rand > 0.5,
} }
}), }),
], ],

View File

@ -94,7 +94,7 @@ test.describe('Results page', () => {
}) })
test("Incomplete results shouldn't be displayed", async ({ page }) => { test("Incomplete results shouldn't be displayed", async ({ page }) => {
await page.goto(`/typebots/${typebotId}/results`) await page.goto(`/typebots/${typebotId}/results`)
await page.click('text=Unlock 200 results') await page.click('text=Unlock')
await expect(page.locator('text=Upgrade now')).toBeVisible() await expect(page.locator('text=Upgrade now')).toBeVisible()
}) })
}) })