-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
117 lines (114 loc) · 3.16 KB
/
cypress.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import { defineConfig } from 'cypress'
import { session2 } from './cypress/fixtures/otherSessions.json'
import session from './cypress/fixtures/session.json'
import { prisma } from '@/prisma/client'
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
viewportHeight: 1080,
viewportWidth: 1920,
setupNodeEvents(on) {
on('task', {
async 'db:seed-user'() {
// seed test user data
const result = await prisma.user.createMany({
data: [session.user, session2.user],
})
return result
},
async 'db:seed-session'() {
// seed test user's session data
const result = await prisma.session.createMany({
data: [
{
sessionToken: session.sessionToken,
userId: session.user.id,
expires: new Date(session.expires),
},
{
sessionToken: session2.sessionToken,
userId: session2.user.id,
expires: new Date(session2.expires),
},
],
})
return result
},
async 'db:reset-user'() {
// delete test user data
const result = await prisma.user.deleteMany({
where: {
OR: [
{
id: session.user.id,
},
{
email: session.user.email,
},
{
id: session2.user.id,
},
{
email: session2.user.email,
},
],
},
})
return result
},
async 'db:find-user'(userId) {
const result = await prisma.user.findUnique({
where: {
id: userId,
},
})
return result
},
async 'db:reset-task'() {
// delete test user's tasks
const result = await prisma.task.deleteMany({
where: {
userId: session.user.id,
},
})
return result
},
async 'db:seed-task'(input) {
const result = await prisma.task.create({
data: {
userId: input.userId,
title: input.title,
content: input.content,
done: input.done || false,
due: input.due,
start: input.start,
end: input.end,
group: input.group,
type: input.type,
priority: input.priority,
archived: input.archived || false,
createdAt: new Date(),
},
})
return result
},
async 'db:find-tasks'(userId) {
const result = await prisma.task.findMany({
where: {
userId: userId,
},
})
return result
},
async 'db:find-task'(taskId) {
const result = await prisma.task.findUnique({
where: {
id: taskId,
},
})
return result
},
})
},
},
})