Skip to content

Commit

Permalink
Update some miscelaneous test (neo4j#4869)
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala authored Mar 13, 2024
1 parent d46a789 commit bbeef3d
Show file tree
Hide file tree
Showing 11 changed files with 1,214 additions and 2,089 deletions.
1,809 changes: 678 additions & 1,131 deletions packages/graphql/tests/integration/filtering/advanced-filtering.int.test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,22 @@
*/

import { faker } from "@faker-js/faker";
import { graphql } from "graphql";
import type { Driver, Session } from "neo4j-driver";
import { generate } from "randomstring";
import { Neo4jGraphQL } from "../../../src/classes";
import { cleanNodesUsingSession } from "../../utils/clean-nodes";
import { UniqueType } from "../../utils/graphql-types";
import Neo4jHelper from "../neo4j";
import type { UniqueType } from "../../utils/graphql-types";
import { TestHelper } from "../utils/tests-helper";

describe("interface relationships", () => {
let driver: Driver;
let neo4j: Neo4jHelper;
let session: Session;
let neoSchema: Neo4jGraphQL;
let testHelper: TestHelper;

let typeMovie: UniqueType;
let typeSeries: UniqueType;
let typeActor: UniqueType;

beforeAll(async () => {
neo4j = new Neo4jHelper();
driver = await neo4j.getDriver();
});

beforeEach(async () => {
typeMovie = new UniqueType("Movie");
typeSeries = new UniqueType("Series");
typeActor = new UniqueType("Actor");
session = await neo4j.getSession();
testHelper = new TestHelper();
typeMovie = testHelper.createUniqueType("Movie");
typeSeries = testHelper.createUniqueType("Series");
typeActor = testHelper.createUniqueType("Actor");

const typeDefs = /* GraphQL */ `
interface Production {
Expand Down Expand Up @@ -73,17 +61,13 @@ describe("interface relationships", () => {
}
`;

neoSchema = new Neo4jGraphQL({
await testHelper.initNeo4jGraphQL({
typeDefs,
});
});

afterEach(async () => {
await cleanNodesUsingSession(session, [typeActor, typeMovie, typeSeries]);
});

afterAll(async () => {
await driver.close();
await testHelper.close();
});

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

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

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle2 },
});

Expand Down Expand Up @@ -217,7 +198,7 @@ describe("interface relationships", () => {
}
`;

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

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle },
});

Expand Down Expand Up @@ -308,7 +286,7 @@ describe("interface relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -329,10 +307,7 @@ describe("interface relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle },
});

Expand Down Expand Up @@ -388,7 +363,7 @@ describe("interface relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -411,10 +386,7 @@ describe("interface relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle2 },
});

Expand Down Expand Up @@ -484,7 +456,7 @@ describe("interface relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -507,10 +479,7 @@ describe("interface relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle2 },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,22 @@
*/

import { faker } from "@faker-js/faker";
import { graphql } from "graphql";
import type { Driver, Session } from "neo4j-driver";
import { generate } from "randomstring";
import { Neo4jGraphQL } from "../../../src/classes";
import { cleanNodesUsingSession } from "../../utils/clean-nodes";
import { UniqueType } from "../../utils/graphql-types";
import Neo4jHelper from "../neo4j";
import type { UniqueType } from "../../utils/graphql-types";
import { TestHelper } from "../utils/tests-helper";

describe("union relationships", () => {
let driver: Driver;
let neo4j: Neo4jHelper;
let session: Session;
let neoSchema: Neo4jGraphQL;
let testHelper: TestHelper;

let typeMovie: UniqueType;
let typeSeries: UniqueType;
let typeActor: UniqueType;

beforeAll(async () => {
neo4j = new Neo4jHelper();
driver = await neo4j.getDriver();
});

beforeEach(async () => {
typeMovie = new UniqueType("Movie");
typeSeries = new UniqueType("Series");
typeActor = new UniqueType("Actor");
session = await neo4j.getSession();
testHelper = new TestHelper();
typeMovie = testHelper.createUniqueType("Movie");
typeSeries = testHelper.createUniqueType("Series");
typeActor = testHelper.createUniqueType("Actor");

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

neoSchema = new Neo4jGraphQL({
await testHelper.initNeo4jGraphQL({
typeDefs,
});
});

afterEach(async () => {
await cleanNodesUsingSession(session, [typeActor, typeMovie, typeSeries]);
});

afterAll(async () => {
await driver.close();
await testHelper.close();
});

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

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

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle2 },
});

Expand Down Expand Up @@ -217,7 +198,7 @@ describe("union relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -238,10 +219,7 @@ describe("union relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle },
});

Expand Down Expand Up @@ -317,7 +295,7 @@ describe("union relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -339,10 +317,7 @@ describe("union relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle },
});

Expand Down Expand Up @@ -409,7 +384,7 @@ describe("union relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -430,10 +405,7 @@ describe("union relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle },
});

Expand Down Expand Up @@ -490,7 +462,7 @@ describe("union relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -513,10 +485,7 @@ describe("union relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle2 },
});

Expand Down Expand Up @@ -587,7 +556,7 @@ describe("union relationships", () => {
}
`;

await session.run(
await testHelper.runCypher(
`
CREATE (a:${typeActor} { name: $actorName })
CREATE (m:${typeMovie} { title: $movieTitle, runtime:$movieRuntime })
Expand All @@ -610,10 +579,7 @@ describe("union relationships", () => {
}
);

const gqlResult = await graphql({
schema: await neoSchema.getSchema(),
source: query,
contextValue: neo4j.getContextValues(),
const gqlResult = await testHelper.runGraphQL(query, {
variableValues: { title: movieTitle2 },
});

Expand Down
Loading

0 comments on commit bbeef3d

Please sign in to comment.