Allow single server instance in test suite (#7262)
* initial pass * reconfigureServer when needed * finish postgres tests * mongo tests * more tests * clean up * re-add skipped test * Fix transaction tests * handle batch * AuthenticationAdapter fix * More reconfiguration * clean up * properly terminate cli servers * handle Parse.Push * Flaky PushController * ensure reconfigureServer when changed * fix postgres tests * remove console.log * LiveQuery spec remove duplicates and listeners
This commit is contained in:
@@ -43,7 +43,7 @@ describe('ParseGraphQLServer', () => {
|
||||
let parseServer;
|
||||
let parseGraphQLServer;
|
||||
|
||||
beforeAll(async () => {
|
||||
beforeEach(async () => {
|
||||
parseServer = await global.reconfigureServer({});
|
||||
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
|
||||
graphQLPath: '/graphql',
|
||||
@@ -394,7 +394,7 @@ describe('ParseGraphQLServer', () => {
|
||||
objects.push(object1, object2, object3, object4);
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
beforeEach(async () => {
|
||||
const expressApp = express();
|
||||
httpServer = http.createServer(expressApp);
|
||||
expressApp.use('/parse', parseServer.app);
|
||||
@@ -436,14 +436,11 @@ describe('ParseGraphQLServer', () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(console, 'warn').and.callFake(() => {});
|
||||
spyOn(console, 'error').and.callFake(() => {});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
afterEach(async () => {
|
||||
await parseLiveQueryServer.server.close();
|
||||
await httpServer.close();
|
||||
});
|
||||
@@ -700,8 +697,12 @@ describe('ParseGraphQLServer', () => {
|
||||
});
|
||||
|
||||
describe('Relay Specific Types', () => {
|
||||
beforeAll(async () => {
|
||||
await resetGraphQLCache();
|
||||
let clearCache;
|
||||
beforeEach(async () => {
|
||||
if (!clearCache) {
|
||||
await resetGraphQLCache();
|
||||
clearCache = true;
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -2175,11 +2176,7 @@ describe('ParseGraphQLServer', () => {
|
||||
});
|
||||
|
||||
describe('Relay Spec', () => {
|
||||
beforeAll(async () => {
|
||||
await resetGraphQLCache();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
beforeEach(async () => {
|
||||
await resetGraphQLCache();
|
||||
});
|
||||
|
||||
@@ -10079,7 +10076,7 @@ describe('ParseGraphQLServer', () => {
|
||||
'X-Parse-Javascript-Key': 'test',
|
||||
};
|
||||
let apolloClient;
|
||||
beforeAll(async () => {
|
||||
beforeEach(async () => {
|
||||
const expressApp = express();
|
||||
httpServer = http.createServer(expressApp);
|
||||
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
|
||||
@@ -10112,7 +10109,7 @@ describe('ParseGraphQLServer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
afterEach(async () => {
|
||||
await httpServer.close();
|
||||
});
|
||||
|
||||
@@ -10203,97 +10200,99 @@ describe('ParseGraphQLServer', () => {
|
||||
};
|
||||
let apolloClient;
|
||||
|
||||
beforeAll(async () => {
|
||||
const expressApp = express();
|
||||
httpServer = http.createServer(expressApp);
|
||||
const TypeEnum = new GraphQLEnumType({
|
||||
name: 'TypeEnum',
|
||||
values: {
|
||||
human: { value: 'human' },
|
||||
robot: { value: 'robot' },
|
||||
},
|
||||
});
|
||||
const SomeClassType = new GraphQLObjectType({
|
||||
name: 'SomeClass',
|
||||
fields: {
|
||||
nameUpperCase: {
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
resolve: p => p.name.toUpperCase(),
|
||||
},
|
||||
type: { type: TypeEnum },
|
||||
language: {
|
||||
type: new GraphQLEnumType({
|
||||
name: 'LanguageEnum',
|
||||
values: {
|
||||
fr: { value: 'fr' },
|
||||
en: { value: 'en' },
|
||||
},
|
||||
}),
|
||||
resolve: () => 'fr',
|
||||
},
|
||||
beforeEach(async () => {
|
||||
if (!httpServer) {
|
||||
const expressApp = express();
|
||||
httpServer = http.createServer(expressApp);
|
||||
const TypeEnum = new GraphQLEnumType({
|
||||
name: 'TypeEnum',
|
||||
values: {
|
||||
human: { value: 'human' },
|
||||
robot: { value: 'robot' },
|
||||
},
|
||||
}),
|
||||
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
|
||||
graphQLPath: '/graphql',
|
||||
graphQLCustomTypeDefs: new GraphQLSchema({
|
||||
query: new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
fields: {
|
||||
customQuery: {
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
args: {
|
||||
message: { type: new GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (p, { message }) => message,
|
||||
},
|
||||
customQueryWithAutoTypeReturn: {
|
||||
type: SomeClassType,
|
||||
args: {
|
||||
id: { type: new GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: async (p, { id }) => {
|
||||
const obj = new Parse.Object('SomeClass');
|
||||
obj.id = id;
|
||||
await obj.fetch();
|
||||
return obj.toJSON();
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
types: [
|
||||
new GraphQLInputObjectType({
|
||||
name: 'CreateSomeClassFieldsInput',
|
||||
fields: {
|
||||
type: { type: TypeEnum },
|
||||
},
|
||||
}),
|
||||
new GraphQLInputObjectType({
|
||||
name: 'UpdateSomeClassFieldsInput',
|
||||
fields: {
|
||||
type: { type: TypeEnum },
|
||||
},
|
||||
}),
|
||||
SomeClassType,
|
||||
],
|
||||
}),
|
||||
});
|
||||
const SomeClassType = new GraphQLObjectType({
|
||||
name: 'SomeClass',
|
||||
fields: {
|
||||
nameUpperCase: {
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
resolve: p => p.name.toUpperCase(),
|
||||
},
|
||||
type: { type: TypeEnum },
|
||||
language: {
|
||||
type: new GraphQLEnumType({
|
||||
name: 'LanguageEnum',
|
||||
values: {
|
||||
fr: { value: 'fr' },
|
||||
en: { value: 'en' },
|
||||
},
|
||||
}),
|
||||
resolve: () => 'fr',
|
||||
},
|
||||
},
|
||||
}),
|
||||
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
|
||||
graphQLPath: '/graphql',
|
||||
graphQLCustomTypeDefs: new GraphQLSchema({
|
||||
query: new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
fields: {
|
||||
customQuery: {
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
args: {
|
||||
message: { type: new GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (p, { message }) => message,
|
||||
},
|
||||
customQueryWithAutoTypeReturn: {
|
||||
type: SomeClassType,
|
||||
args: {
|
||||
id: { type: new GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: async (p, { id }) => {
|
||||
const obj = new Parse.Object('SomeClass');
|
||||
obj.id = id;
|
||||
await obj.fetch();
|
||||
return obj.toJSON();
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
types: [
|
||||
new GraphQLInputObjectType({
|
||||
name: 'CreateSomeClassFieldsInput',
|
||||
fields: {
|
||||
type: { type: TypeEnum },
|
||||
},
|
||||
}),
|
||||
new GraphQLInputObjectType({
|
||||
name: 'UpdateSomeClassFieldsInput',
|
||||
fields: {
|
||||
type: { type: TypeEnum },
|
||||
},
|
||||
}),
|
||||
SomeClassType,
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
parseGraphQLServer.applyGraphQL(expressApp);
|
||||
await new Promise(resolve => httpServer.listen({ port: 13377 }, resolve));
|
||||
const httpLink = createUploadLink({
|
||||
uri: 'http://localhost:13377/graphql',
|
||||
fetch,
|
||||
headers,
|
||||
});
|
||||
apolloClient = new ApolloClient({
|
||||
link: httpLink,
|
||||
cache: new InMemoryCache(),
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'no-cache',
|
||||
parseGraphQLServer.applyGraphQL(expressApp);
|
||||
await new Promise(resolve => httpServer.listen({ port: 13377 }, resolve));
|
||||
const httpLink = createUploadLink({
|
||||
uri: 'http://localhost:13377/graphql',
|
||||
fetch,
|
||||
headers,
|
||||
});
|
||||
apolloClient = new ApolloClient({
|
||||
link: httpLink,
|
||||
cache: new InMemoryCache(),
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'no-cache',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -10393,31 +10392,33 @@ describe('ParseGraphQLServer', () => {
|
||||
};
|
||||
let apolloClient;
|
||||
|
||||
beforeAll(async () => {
|
||||
const expressApp = express();
|
||||
httpServer = http.createServer(expressApp);
|
||||
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
|
||||
graphQLPath: '/graphql',
|
||||
graphQLCustomTypeDefs: ({ autoSchema, stitchSchemas }) =>
|
||||
stitchSchemas({ subschemas: [autoSchema] }),
|
||||
});
|
||||
beforeEach(async () => {
|
||||
if (!httpServer) {
|
||||
const expressApp = express();
|
||||
httpServer = http.createServer(expressApp);
|
||||
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
|
||||
graphQLPath: '/graphql',
|
||||
graphQLCustomTypeDefs: ({ autoSchema, stitchSchemas }) =>
|
||||
stitchSchemas({ subschemas: [autoSchema] }),
|
||||
});
|
||||
|
||||
parseGraphQLServer.applyGraphQL(expressApp);
|
||||
await new Promise(resolve => httpServer.listen({ port: 13377 }, resolve));
|
||||
const httpLink = createUploadLink({
|
||||
uri: 'http://localhost:13377/graphql',
|
||||
fetch,
|
||||
headers,
|
||||
});
|
||||
apolloClient = new ApolloClient({
|
||||
link: httpLink,
|
||||
cache: new InMemoryCache(),
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'no-cache',
|
||||
parseGraphQLServer.applyGraphQL(expressApp);
|
||||
await new Promise(resolve => httpServer.listen({ port: 13377 }, resolve));
|
||||
const httpLink = createUploadLink({
|
||||
uri: 'http://localhost:13377/graphql',
|
||||
fetch,
|
||||
headers,
|
||||
});
|
||||
apolloClient = new ApolloClient({
|
||||
link: httpLink,
|
||||
cache: new InMemoryCache(),
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'no-cache',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
Reference in New Issue
Block a user