Skip to content

Commit cd09af3

Browse files
committed
[tests] Migrate gql docs to graphql()
1 parent bdd6573 commit cd09af3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2827
-2496
lines changed

test/authentication.e2e-spec.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { jest } from '@jest/globals';
33
import { EmailService } from '@seedcompany/nestjs-email';
44
import { Connection } from 'cypher-query-builder';
55
import { isValidId } from '~/common';
6+
import { graphql } from '~/graphql';
67
import {
78
createSession,
89
createTestApp,
910
fragments,
1011
generateRegisterInput,
11-
gql,
1212
login,
1313
logout,
1414
registerUser,
@@ -38,13 +38,13 @@ describe('Authentication e2e', () => {
3838
// create user first
3939
await registerUser(app, fakeUser);
4040
await app.graphql.mutate(
41-
gql`
41+
graphql(`
4242
mutation forgotPassword($email: String!) {
4343
forgotPassword(email: $email) {
4444
__typename
4545
}
4646
}
47-
`,
47+
`),
4848
{
4949
email: email,
5050
},
@@ -59,13 +59,13 @@ describe('Authentication e2e', () => {
5959
const token = tokenRes ? tokenRes.token : '';
6060
const newPassword = faker.internet.password();
6161
await app.graphql.mutate(
62-
gql`
62+
graphql(`
6363
mutation resetPassword($input: ResetPasswordInput!) {
6464
resetPassword(input: $input) {
6565
__typename
6666
}
6767
}
68-
`,
68+
`),
6969
{
7070
input: {
7171
token: token,
@@ -90,14 +90,16 @@ describe('Authentication e2e', () => {
9090

9191
await login(app, { email: fakeUser.email, password: fakeUser.password });
9292
const result = await app.graphql.query(
93-
gql`
94-
query user($id: ID!) {
95-
user(id: $id) {
96-
...user
93+
graphql(
94+
`
95+
query user($id: ID!) {
96+
user(id: $id) {
97+
...user
98+
}
9799
}
98-
}
99-
${fragments.user}
100-
`,
100+
`,
101+
[fragments.user],
102+
),
101103
{
102104
id: user.id,
103105
},
@@ -125,13 +127,13 @@ describe('Authentication e2e', () => {
125127

126128
const newPassword = faker.internet.password();
127129
await app.graphql.mutate(
128-
gql`
130+
graphql(`
129131
mutation changePassword($oldPassword: String!, $newPassword: String!) {
130132
changePassword(oldPassword: $oldPassword, newPassword: $newPassword) {
131133
__typename
132134
}
133135
}
134-
`,
136+
`),
135137
{
136138
oldPassword: fakeUser.password,
137139
newPassword: newPassword,

test/education.e2e-spec.ts

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { faker } from '@faker-js/faker';
22
import { times } from 'lodash';
33
import { isValidId, Role } from '~/common';
4+
import { graphql } from '~/graphql';
45
import { type User } from '../src/components/user/dto';
56
import { type Education } from '../src/components/user/education/dto';
67
import {
78
createEducation,
89
createSession,
910
createTestApp,
10-
gql,
1111
registerUser,
1212
type TestApp,
1313
} from './utility';
@@ -36,14 +36,16 @@ describe('Education e2e', () => {
3636
const education = await createEducation(app, { userId: user.id });
3737

3838
const { education: actual } = await app.graphql.query(
39-
gql`
40-
query education($id: ID!) {
41-
education(id: $id) {
42-
...education
39+
graphql(
40+
`
41+
query education($id: ID!) {
42+
education(id: $id) {
43+
...education
44+
}
4345
}
44-
}
45-
${fragments.education}
46-
`,
46+
`,
47+
[fragments.education],
48+
),
4749
{
4850
id: education.id,
4951
},
@@ -60,16 +62,18 @@ describe('Education e2e', () => {
6062
const newInstitution = faker.company.name();
6163

6264
const result = await app.graphql.mutate(
63-
gql`
64-
mutation updateEducation($input: UpdateEducationInput!) {
65-
updateEducation(input: $input) {
66-
education {
67-
...education
65+
graphql(
66+
`
67+
mutation updateEducation($input: UpdateEducationInput!) {
68+
updateEducation(input: $input) {
69+
education {
70+
...education
71+
}
6872
}
6973
}
70-
}
71-
${fragments.education}
72-
`,
74+
`,
75+
[fragments.education],
76+
),
7377
{
7478
input: {
7579
education: {
@@ -90,13 +94,13 @@ describe('Education e2e', () => {
9094
const education = await createEducation(app, { userId: user.id });
9195

9296
const result = await app.graphql.mutate(
93-
gql`
97+
graphql(`
9498
mutation deleteEducation($id: ID!) {
9599
deleteEducation(id: $id) {
96100
__typename
97101
}
98102
}
99-
`,
103+
`),
100104
{
101105
id: education.id,
102106
},
@@ -114,20 +118,22 @@ describe('Education e2e', () => {
114118
);
115119

116120
const result = await app.graphql.query(
117-
gql`
118-
query UserEducation($id: ID!) {
119-
user(id: $id) {
120-
education {
121-
items {
122-
...education
121+
graphql(
122+
`
123+
query UserEducation($id: ID!) {
124+
user(id: $id) {
125+
education {
126+
items {
127+
...education
128+
}
129+
hasMore
130+
total
123131
}
124-
hasMore
125-
total
126132
}
127133
}
128-
}
129-
${fragments.education}
130-
`,
134+
`,
135+
[fragments.education],
136+
),
131137
{
132138
id: user.id,
133139
},

0 commit comments

Comments
 (0)