+1
.graphqlrc.yaml
+1
.graphqlrc.yaml
+3
-1
packages/api/package.json
+3
-1
packages/api/package.json
···
97
97
},
98
98
"devDependencies": {
99
99
"@clack/prompts": "^0.7.0",
100
+
"@orangeopensource/hurl": "^4.3.2",
100
101
"@tsconfig/esm": "^1.0.5",
101
102
"@tsconfig/node18": "^18.2.4",
102
103
"@tsconfig/strictest": "^2.0.5",
···
164
165
"add-search-support": "tsx ./scripts/add-search-support.ts",
165
166
"modules-import-graph": "tsx ./scripts/modules-import-graph.ts --exclude global --png",
166
167
"migration": "yarn run -T migration",
167
-
"watch-barrels": "nodemon --exec 'yarn barrelize' --watch src/modules -e ts --ignore 'src/modules/**/index.ts'"
168
+
"watch-barrels": "nodemon --exec 'yarn barrelize' --watch src/modules -e ts --ignore 'src/modules/**/index.ts'",
169
+
"test": "echo Logging in… && http post :4000/graphql query='mutation { login(email: \"versairea\", password: \"a\") { ...on MutationLoginSuccess { data { token } } } }' | jq -r .data.login.data.token | xargs -I@ hurl --parallel --test --variable token=@ --variable host=http://localhost:4000 --glob src/modules/*/tests/*.hurl"
168
170
},
169
171
"type": "module",
170
172
"volta": {
+4
packages/api/scripts/generate-barrelsby-config.ts
+4
packages/api/scripts/generate-barrelsby-config.ts
+31
packages/api/src/modules/users/tests/login.hurl
+31
packages/api/src/modules/users/tests/login.hurl
···
1
+
POST {{host}}/graphql
2
+
```graphql
3
+
mutation {
4
+
login(email: "versairea", password: "a") {
5
+
...on MutationLoginSuccess {
6
+
data { token }
7
+
}
8
+
...on Error { message }
9
+
}
10
+
}
11
+
```
12
+
13
+
HTTP 200
14
+
[Asserts]
15
+
jsonpath "$.data.login.data.token" != null
16
+
[Captures]
17
+
token: jsonpath "$.data.login.data.token"
18
+
19
+
POST {{host}}/graphql
20
+
Authorization: Bearer {{token}}
21
+
```graphql
22
+
{
23
+
me {
24
+
fullName
25
+
}
26
+
}
27
+
```
28
+
29
+
HTTP 200
30
+
[Asserts]
31
+
jsonpath "$.data.me.fullName" == "Annie Versaire"
+36
packages/api/src/modules/users/tests/search.hurl
+36
packages/api/src/modules/users/tests/search.hurl
···
1
+
POST {{host}}/graphql
2
+
3
+
```graphql
4
+
{
5
+
searchUsers(q: "test") {
6
+
user {
7
+
fullName
8
+
}
9
+
}
10
+
}
11
+
```
12
+
13
+
HTTP 200
14
+
15
+
[Asserts]
16
+
jsonpath "$.errors[0]" exists
17
+
jsonpath "$.data" == null
18
+
19
+
# Succeeds when logged in
20
+
21
+
POST {{host}}/graphql
22
+
Authorization: Bearer {{token}}
23
+
```graphql
24
+
{
25
+
searchUsers(q: "annie") {
26
+
user {
27
+
fullName
28
+
}
29
+
}
30
+
}
31
+
```
32
+
33
+
HTTP 200
34
+
35
+
[Asserts]
36
+
jsonpath "$.data.searchUsers[0].user.fullName" == "Annie Versaire"
+68
packages/api/src/modules/users/tests/user.hurl
+68
packages/api/src/modules/users/tests/user.hurl
···
1
+
# fails when loggedout
2
+
3
+
POST {{host}}/graphql
4
+
```graphql
5
+
{
6
+
user(uid: "versairea") {
7
+
fullName
8
+
}
9
+
}
10
+
```
11
+
12
+
HTTP 200
13
+
14
+
[Asserts]
15
+
jsonpath "$.data" == null
16
+
jsonpath "$.errors[0]" exists
17
+
18
+
POST {{host}}/graphql
19
+
Authorization: Bearer {{token}}
20
+
```graphql
21
+
{
22
+
user(uid: "versairea") {
23
+
fullName
24
+
firstName
25
+
lastName
26
+
bot
27
+
admin
28
+
}
29
+
}
30
+
```
31
+
32
+
HTTP 200
33
+
[Asserts]
34
+
jsonpath "$.data.user.fullName" == "Annie Versaire"
35
+
jsonpath "$.data.user.firstName" == "Annie"
36
+
jsonpath "$.data.user.lastName" == "Versaire"
37
+
jsonpath "$.data.user.bot" == false
38
+
jsonpath "$.data.user.admin" == true
39
+
40
+
# fails with external users
41
+
POST {{host}}/graphql
42
+
43
+
```graphql
44
+
mutation {
45
+
login(email: "exte", password: "a") {
46
+
...on MutationLoginSuccess {data{token}}
47
+
}
48
+
}
49
+
```
50
+
51
+
HTTP 200
52
+
[Captures]
53
+
external_token: jsonpath "$.data.login.data.token"
54
+
55
+
POST {{host}}/graphql
56
+
Authorization: Bearer {{external_token}}
57
+
```graphql
58
+
{
59
+
user(uid: "versairea") {
60
+
fullName
61
+
}
62
+
}
63
+
```
64
+
65
+
HTTP 200
66
+
[Asserts]
67
+
jsonpath "$.data" == null
68
+
jsonpath "$.errors[0]" exists
+3
-2
packages/db/seed/index.ts
+3
-2
packages/db/seed/index.ts
···
414
414
});
415
415
416
416
//User rigolo de l'ancienne DB de test, que personne y touche on en est fier.
417
-
const usersData = [
417
+
const usersData: Array<Partial<Prisma.UserCreateInput>> = [
418
418
{ firstName: 'Annie', lastName: 'Versaire', admin: true }, //Unique compte de la DB qui possède les droits admin
419
419
{ firstName: 'Bernard', lastName: 'Tichaut' },
420
420
{ firstName: 'Camille', lastName: 'Honnête' },
···
441
441
{ firstName: 'Yvon', lastName: 'Enbavé' },
442
442
{ firstName: 'Zinédine', lastName: 'Pacesoir' },
443
443
{ firstName: 'Rick', lastName: 'Astley' }, //https://www.youtube.com/watch?v=dQw4w9WgXcQ
444
+
{ uid: "exte", firstName: "Jaipa", lastName: "Dékol", minor: {}, major:{} } // Compte exté
444
445
];
445
446
446
447
//création d'une liste des réseaux sociaux qu'on peut ref sur son profil churros
···
471
472
472
473
const { uid } = await prisma.user.create({
473
474
data: {
474
-
...data,
475
475
uid: await createUid(data),
476
476
email: faker.internet.email({ firstName: data.firstName, lastName: data.lastName }),
477
477
description: faker.lorem.paragraph({ min: 0, max: 50 }),
···
509
509
minor: { connect: { id: minor.id } },
510
510
credentials: { create: { type: CredentialType.Password, value: await hash('a') } },
511
511
canAccessDocuments: true,
512
+
...data,
512
513
},
513
514
});
514
515