Skip to content

Commit bbeef3d

Browse files
authored
Update some miscelaneous test (#4869)
1 parent d46a789 commit bbeef3d

11 files changed

+1214
-2089
lines changed

packages/graphql/tests/integration/filtering/advanced-filtering.int.test.ts

Lines changed: 678 additions & 1131 deletions
Large diffs are not rendered by default.

packages/graphql/tests/integration/filtering/filter-interface-relationship.int.test.ts

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,22 @@
1818
*/
1919

2020
import { faker } from "@faker-js/faker";
21-
import { graphql } from "graphql";
22-
import type { Driver, Session } from "neo4j-driver";
2321
import { generate } from "randomstring";
24-
import { Neo4jGraphQL } from "../../../src/classes";
25-
import { cleanNodesUsingSession } from "../../utils/clean-nodes";
26-
import { UniqueType } from "../../utils/graphql-types";
27-
import Neo4jHelper from "../neo4j";
22+
import type { UniqueType } from "../../utils/graphql-types";
23+
import { TestHelper } from "../utils/tests-helper";
2824

2925
describe("interface relationships", () => {
30-
let driver: Driver;
31-
let neo4j: Neo4jHelper;
32-
let session: Session;
33-
let neoSchema: Neo4jGraphQL;
26+
let testHelper: TestHelper;
3427

3528
let typeMovie: UniqueType;
3629
let typeSeries: UniqueType;
3730
let typeActor: UniqueType;
3831

39-
beforeAll(async () => {
40-
neo4j = new Neo4jHelper();
41-
driver = await neo4j.getDriver();
42-
});
43-
4432
beforeEach(async () => {
45-
typeMovie = new UniqueType("Movie");
46-
typeSeries = new UniqueType("Series");
47-
typeActor = new UniqueType("Actor");
48-
session = await neo4j.getSession();
33+
testHelper = new TestHelper();
34+
typeMovie = testHelper.createUniqueType("Movie");
35+
typeSeries = testHelper.createUniqueType("Series");
36+
typeActor = testHelper.createUniqueType("Actor");
4937

5038
const typeDefs = /* GraphQL */ `
5139
interface Production {
@@ -73,17 +61,13 @@ describe("interface relationships", () => {
7361
}
7462
`;
7563

76-
neoSchema = new Neo4jGraphQL({
64+
await testHelper.initNeo4jGraphQL({
7765
typeDefs,
7866
});
7967
});
8068

8169
afterEach(async () => {
82-
await cleanNodesUsingSession(session, [typeActor, typeMovie, typeSeries]);
83-
});
84-
85-
afterAll(async () => {
86-
await driver.close();
70+
await testHelper.close();
8771
});
8872

8973
test("should read and return interface relationship fields with interface relationship filter SOME", async () => {
@@ -131,7 +115,7 @@ describe("interface relationships", () => {
131115
}
132116
`;
133117

134-
await session.run(
118+
await testHelper.runCypher(
135119
`
136120
CREATE (a:${typeActor} { name: $actorName })
137121
CREATE (a)-[:ACTED_IN { screenTime: $movieScreenTime }]->(:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -152,10 +136,7 @@ describe("interface relationships", () => {
152136
}
153137
);
154138

155-
const gqlResult = await graphql({
156-
schema: await neoSchema.getSchema(),
157-
source: query,
158-
contextValue: neo4j.getContextValues(),
139+
const gqlResult = await testHelper.runGraphQL(query, {
159140
variableValues: { title: movieTitle2 },
160141
});
161142

@@ -217,7 +198,7 @@ describe("interface relationships", () => {
217198
}
218199
`;
219200

220-
await session.run(
201+
await testHelper.runCypher(
221202
`
222203
CREATE (a:${typeActor} { name: $actorName })
223204
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -239,10 +220,7 @@ describe("interface relationships", () => {
239220
}
240221
);
241222

242-
const gqlResult = await graphql({
243-
schema: await neoSchema.getSchema(),
244-
source: query,
245-
contextValue: neo4j.getContextValues(),
223+
const gqlResult = await testHelper.runGraphQL(query, {
246224
variableValues: { title: movieTitle },
247225
});
248226

@@ -308,7 +286,7 @@ describe("interface relationships", () => {
308286
}
309287
`;
310288

311-
await session.run(
289+
await testHelper.runCypher(
312290
`
313291
CREATE (a:${typeActor} { name: $actorName })
314292
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -329,10 +307,7 @@ describe("interface relationships", () => {
329307
}
330308
);
331309

332-
const gqlResult = await graphql({
333-
schema: await neoSchema.getSchema(),
334-
source: query,
335-
contextValue: neo4j.getContextValues(),
310+
const gqlResult = await testHelper.runGraphQL(query, {
336311
variableValues: { title: movieTitle },
337312
});
338313

@@ -388,7 +363,7 @@ describe("interface relationships", () => {
388363
}
389364
`;
390365

391-
await session.run(
366+
await testHelper.runCypher(
392367
`
393368
CREATE (a:${typeActor} { name: $actorName })
394369
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -411,10 +386,7 @@ describe("interface relationships", () => {
411386
}
412387
);
413388

414-
const gqlResult = await graphql({
415-
schema: await neoSchema.getSchema(),
416-
source: query,
417-
contextValue: neo4j.getContextValues(),
389+
const gqlResult = await testHelper.runGraphQL(query, {
418390
variableValues: { title: movieTitle2 },
419391
});
420392

@@ -484,7 +456,7 @@ describe("interface relationships", () => {
484456
}
485457
`;
486458

487-
await session.run(
459+
await testHelper.runCypher(
488460
`
489461
CREATE (a:${typeActor} { name: $actorName })
490462
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -507,10 +479,7 @@ describe("interface relationships", () => {
507479
}
508480
);
509481

510-
const gqlResult = await graphql({
511-
schema: await neoSchema.getSchema(),
512-
source: query,
513-
contextValue: neo4j.getContextValues(),
482+
const gqlResult = await testHelper.runGraphQL(query, {
514483
variableValues: { title: movieTitle2 },
515484
});
516485

packages/graphql/tests/integration/filtering/filter-union-relationship.int.test.ts

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,22 @@
1818
*/
1919

2020
import { faker } from "@faker-js/faker";
21-
import { graphql } from "graphql";
22-
import type { Driver, Session } from "neo4j-driver";
2321
import { generate } from "randomstring";
24-
import { Neo4jGraphQL } from "../../../src/classes";
25-
import { cleanNodesUsingSession } from "../../utils/clean-nodes";
26-
import { UniqueType } from "../../utils/graphql-types";
27-
import Neo4jHelper from "../neo4j";
22+
import type { UniqueType } from "../../utils/graphql-types";
23+
import { TestHelper } from "../utils/tests-helper";
2824

2925
describe("union relationships", () => {
30-
let driver: Driver;
31-
let neo4j: Neo4jHelper;
32-
let session: Session;
33-
let neoSchema: Neo4jGraphQL;
26+
let testHelper: TestHelper;
3427

3528
let typeMovie: UniqueType;
3629
let typeSeries: UniqueType;
3730
let typeActor: UniqueType;
3831

39-
beforeAll(async () => {
40-
neo4j = new Neo4jHelper();
41-
driver = await neo4j.getDriver();
42-
});
43-
4432
beforeEach(async () => {
45-
typeMovie = new UniqueType("Movie");
46-
typeSeries = new UniqueType("Series");
47-
typeActor = new UniqueType("Actor");
48-
session = await neo4j.getSession();
33+
testHelper = new TestHelper();
34+
typeMovie = testHelper.createUniqueType("Movie");
35+
typeSeries = testHelper.createUniqueType("Series");
36+
typeActor = testHelper.createUniqueType("Actor");
4937

5038
const typeDefs = /* GraphQL */ `
5139
type ${typeMovie} {
@@ -71,17 +59,13 @@ describe("union relationships", () => {
7159
}
7260
`;
7361

74-
neoSchema = new Neo4jGraphQL({
62+
await testHelper.initNeo4jGraphQL({
7563
typeDefs,
7664
});
7765
});
7866

7967
afterEach(async () => {
80-
await cleanNodesUsingSession(session, [typeActor, typeMovie, typeSeries]);
81-
});
82-
83-
afterAll(async () => {
84-
await driver.close();
68+
await testHelper.close();
8569
});
8670

8771
test("should read and return union relationship fields with union relationship filter SOME", async () => {
@@ -130,7 +114,7 @@ describe("union relationships", () => {
130114
}
131115
`;
132116

133-
await session.run(
117+
await testHelper.runCypher(
134118
`
135119
CREATE (a:${typeActor} { name: $actorName })
136120
CREATE (a)-[:ACTED_IN { screenTime: $movieScreenTime }]->(:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -151,10 +135,7 @@ describe("union relationships", () => {
151135
}
152136
);
153137

154-
const gqlResult = await graphql({
155-
schema: await neoSchema.getSchema(),
156-
source: query,
157-
contextValue: neo4j.getContextValues(),
138+
const gqlResult = await testHelper.runGraphQL(query, {
158139
variableValues: { title: movieTitle2 },
159140
});
160141

@@ -217,7 +198,7 @@ describe("union relationships", () => {
217198
}
218199
`;
219200

220-
await session.run(
201+
await testHelper.runCypher(
221202
`
222203
CREATE (a:${typeActor} { name: $actorName })
223204
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -238,10 +219,7 @@ describe("union relationships", () => {
238219
}
239220
);
240221

241-
const gqlResult = await graphql({
242-
schema: await neoSchema.getSchema(),
243-
source: query,
244-
contextValue: neo4j.getContextValues(),
222+
const gqlResult = await testHelper.runGraphQL(query, {
245223
variableValues: { title: movieTitle },
246224
});
247225

@@ -317,7 +295,7 @@ describe("union relationships", () => {
317295
}
318296
`;
319297

320-
await session.run(
298+
await testHelper.runCypher(
321299
`
322300
CREATE (a:${typeActor} { name: $actorName })
323301
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -339,10 +317,7 @@ describe("union relationships", () => {
339317
}
340318
);
341319

342-
const gqlResult = await graphql({
343-
schema: await neoSchema.getSchema(),
344-
source: query,
345-
contextValue: neo4j.getContextValues(),
320+
const gqlResult = await testHelper.runGraphQL(query, {
346321
variableValues: { title: movieTitle },
347322
});
348323

@@ -409,7 +384,7 @@ describe("union relationships", () => {
409384
}
410385
`;
411386

412-
await session.run(
387+
await testHelper.runCypher(
413388
`
414389
CREATE (a:${typeActor} { name: $actorName })
415390
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -430,10 +405,7 @@ describe("union relationships", () => {
430405
}
431406
);
432407

433-
const gqlResult = await graphql({
434-
schema: await neoSchema.getSchema(),
435-
source: query,
436-
contextValue: neo4j.getContextValues(),
408+
const gqlResult = await testHelper.runGraphQL(query, {
437409
variableValues: { title: movieTitle },
438410
});
439411

@@ -490,7 +462,7 @@ describe("union relationships", () => {
490462
}
491463
`;
492464

493-
await session.run(
465+
await testHelper.runCypher(
494466
`
495467
CREATE (a:${typeActor} { name: $actorName })
496468
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -513,10 +485,7 @@ describe("union relationships", () => {
513485
}
514486
);
515487

516-
const gqlResult = await graphql({
517-
schema: await neoSchema.getSchema(),
518-
source: query,
519-
contextValue: neo4j.getContextValues(),
488+
const gqlResult = await testHelper.runGraphQL(query, {
520489
variableValues: { title: movieTitle2 },
521490
});
522491

@@ -587,7 +556,7 @@ describe("union relationships", () => {
587556
}
588557
`;
589558

590-
await session.run(
559+
await testHelper.runCypher(
591560
`
592561
CREATE (a:${typeActor} { name: $actorName })
593562
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
@@ -610,10 +579,7 @@ describe("union relationships", () => {
610579
}
611580
);
612581

613-
const gqlResult = await graphql({
614-
schema: await neoSchema.getSchema(),
615-
source: query,
616-
contextValue: neo4j.getContextValues(),
582+
const gqlResult = await testHelper.runGraphQL(query, {
617583
variableValues: { title: movieTitle2 },
618584
});
619585

0 commit comments

Comments
 (0)