aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/msw/index.ts3
-rw-r--r--tests/msw/schema/index.ts38
-rw-r--r--tests/msw/schema/types/author.types.ts26
-rw-r--r--tests/msw/schema/types/common.types.ts36
-rw-r--r--tests/msw/schema/types/featured-image.types.ts24
-rw-r--r--tests/msw/schema/types/index.ts26
-rw-r--r--tests/msw/schema/types/post.types.ts72
-rw-r--r--tests/msw/schema/types/thematic.types.ts20
-rw-r--r--tests/msw/schema/types/topic.types.ts21
9 files changed, 266 insertions, 0 deletions
diff --git a/tests/msw/index.ts b/tests/msw/index.ts
new file mode 100644
index 0000000..997ae40
--- /dev/null
+++ b/tests/msw/index.ts
@@ -0,0 +1,3 @@
+import { setupServer } from 'msw/node';
+
+export const mswServer = setupServer(...[]);
diff --git a/tests/msw/schema/index.ts b/tests/msw/schema/index.ts
new file mode 100644
index 0000000..3763616
--- /dev/null
+++ b/tests/msw/schema/index.ts
@@ -0,0 +1,38 @@
+import { addResolversToSchema } from '@graphql-tools/schema';
+import type { IResolvers } from '@graphql-tools/utils';
+import { buildSchema } from 'graphql';
+import { types } from './types';
+
+/* eslint-disable camelcase -- We have no control on WP GraphQL types */
+const resolvers: IResolvers = {
+ Post_Acfposts_PostsInThematic: {
+ __resolveType() {
+ return 'Thematic';
+ },
+ },
+ Post_Acfposts_PostsInTopic: {
+ __resolveType() {
+ return 'Topic';
+ },
+ },
+ Thematic_Acfthematics_PostsInThematic: {
+ __resolveType() {
+ return 'Post';
+ },
+ },
+ Topic_Acftopics_PostsInTopic: {
+ __resolveType() {
+ return 'Post';
+ },
+ },
+};
+/* eslint-enable camelcase */
+
+// cSpell:ignore Acfposts Acfthematics Acftopics camelcase
+
+const schemaFromTypes = buildSchema(types.join('\n'));
+
+export const schema = addResolversToSchema({
+ schema: schemaFromTypes,
+ resolvers,
+});
diff --git a/tests/msw/schema/types/author.types.ts b/tests/msw/schema/types/author.types.ts
new file mode 100644
index 0000000..bbb50a4
--- /dev/null
+++ b/tests/msw/schema/types/author.types.ts
@@ -0,0 +1,26 @@
+export const authorTypes = `enum AvatarRatingEnum {
+ G
+ PG
+ R
+ X
+}
+
+type Avatar {
+ height: Int
+ url: String
+ width: Int
+}
+
+type User {
+ avatar(
+ forceDefault: Boolean
+ rating: AvatarRatingEnum
+ size: Int = 96
+ ): Avatar
+ databaseId: Int!
+ name: String
+ url: String
+}
+type NodeWithAuthorToUserConnectionEdge {
+ node: User!
+}`;
diff --git a/tests/msw/schema/types/common.types.ts b/tests/msw/schema/types/common.types.ts
new file mode 100644
index 0000000..23baeb3
--- /dev/null
+++ b/tests/msw/schema/types/common.types.ts
@@ -0,0 +1,36 @@
+export const commonTypes = `enum PostObjectFieldFormatEnum {
+ RAW
+ RENDERED
+}
+
+enum OrderEnum {
+ ASC
+ DESC
+}
+
+enum PostObjectsConnectionOrderbyEnum {
+ AUTHOR
+ COMMENT_COUNT
+ DATE
+ IN
+ MENU_ORDER
+ MODIFIED
+ NAME_IN
+ PARENT
+ SLUG
+ TITLE
+}
+
+type ContentPartsType {
+ afterMore(format: PostObjectFieldFormatEnum): String
+ beforeMore(format: PostObjectFieldFormatEnum): String
+}
+
+type InfoType {
+ wordsCount: Int
+}
+
+type PostTypeSEO {
+ metaDesc: String
+ title: String
+}`;
diff --git a/tests/msw/schema/types/featured-image.types.ts b/tests/msw/schema/types/featured-image.types.ts
new file mode 100644
index 0000000..788da5f
--- /dev/null
+++ b/tests/msw/schema/types/featured-image.types.ts
@@ -0,0 +1,24 @@
+export const featuredImageTypes = `type MediaDetails {
+ height: Int
+ width: Int
+}
+
+enum MediaItemSizeEnum {
+ LARGE
+ MEDIUM
+ MEDIUM_LARGE
+ THUMBNAIL
+ _1536X1536
+ _2048X2048
+}
+
+type MediaItem {
+ altText: String
+ mediaDetails: MediaDetails
+ sourceUrl(size: MediaItemSizeEnum): String
+ title(format: PostObjectFieldFormatEnum): String
+}
+
+type NodeWithFeaturedImageToMediaItemConnectionEdge {
+ node: MediaItem!
+}`;
diff --git a/tests/msw/schema/types/index.ts b/tests/msw/schema/types/index.ts
new file mode 100644
index 0000000..ea749be
--- /dev/null
+++ b/tests/msw/schema/types/index.ts
@@ -0,0 +1,26 @@
+import { authorTypes } from './author.types';
+import { commonTypes } from './common.types';
+import { featuredImageTypes } from './featured-image.types';
+import { postTypes } from './post.types';
+import { thematicTypes } from './thematic.types';
+import { topicTypes } from './topic.types';
+
+const rootQueryType = `type Query {
+ posts(
+ after: String
+ before: String
+ first: Int
+ last: Int
+ where: RootQueryToPostConnectionWhereArgs
+ ): RootQueryToPostConnection
+}`;
+
+export const types = [
+ authorTypes,
+ commonTypes,
+ featuredImageTypes,
+ postTypes,
+ thematicTypes,
+ topicTypes,
+ rootQueryType,
+];
diff --git a/tests/msw/schema/types/post.types.ts b/tests/msw/schema/types/post.types.ts
new file mode 100644
index 0000000..04c4f37
--- /dev/null
+++ b/tests/msw/schema/types/post.types.ts
@@ -0,0 +1,72 @@
+export const postTypes = `union Post_Acfposts_PostsInThematic = Thematic
+
+union Post_Acfposts_PostsInTopic = Topic
+
+type Post_Acfposts {
+ postsInThematic: [Post_Acfposts_PostsInThematic]
+ postsInTopic: [Post_Acfposts_PostsInTopic]
+}
+
+type Post {
+ acfPosts: Post_Acfposts
+ author: NodeWithAuthorToUserConnectionEdge
+ commentCount: Int
+ contentParts: ContentPartsType
+ databaseId: Int!
+ date: String
+ featuredImage: NodeWithFeaturedImageToMediaItemConnectionEdge
+ info: InfoType
+ modified: String!
+ seo: PostTypeSEO
+ slug: String
+ title(format: PostObjectFieldFormatEnum): String
+}
+
+enum PostStatusEnum {
+ ACF_DISABLED
+ AUTO_DRAFT
+ DRAFT
+ FUTURE
+ INHERIT
+ PENDING
+ PRIVATE
+ PUBLISH
+ REQUEST_COMPLETED
+ REQUEST_CONFIRMED
+ REQUEST_FAILED
+ REQUEST_PENDING
+ TRASH
+}
+
+input PostObjectsConnectionOrderbyInput {
+ field: PostObjectsConnectionOrderbyEnum!
+ order: OrderEnum!
+}
+
+input RootQueryToPostConnectionWhereArgs {
+ authorName: String
+ orderby: [PostObjectsConnectionOrderbyInput]
+ search: String
+ status: PostStatusEnum
+ title: String
+}
+
+type RootQueryToPostConnectionEdge {
+ cursor: String
+ node: Post!
+}
+
+type RootQueryToPostConnectionPageInfo {
+ endCursor: String
+ hasNextPage: Boolean!
+ hasPreviousPage: Boolean!
+ startCursor: String
+ total: Int
+}
+
+type RootQueryToPostConnection {
+ edges: [RootQueryToPostConnectionEdge!]!
+ pageInfo: RootQueryToPostConnectionPageInfo!
+}`;
+
+// cSpell:ignore Acfposts
diff --git a/tests/msw/schema/types/thematic.types.ts b/tests/msw/schema/types/thematic.types.ts
new file mode 100644
index 0000000..afa95c9
--- /dev/null
+++ b/tests/msw/schema/types/thematic.types.ts
@@ -0,0 +1,20 @@
+export const thematicTypes = `union Thematic_Acfthematics_PostsInThematic = Post
+
+type Thematic_Acfthematics {
+ postsInThematic: [Thematic_Acfthematics_PostsInThematic]
+}
+
+type Thematic {
+ acfThematics: Thematic_Acfthematics
+ contentParts: ContentPartsType
+ databaseId: Int!
+ date: String
+ featuredImage: NodeWithFeaturedImageToMediaItemConnectionEdge
+ info: InfoType
+ modified: String
+ seo: PostTypeSEO
+ slug: String
+ title(format: PostObjectFieldFormatEnum): String
+}`;
+
+// cSpell:ignore Acfthematics
diff --git a/tests/msw/schema/types/topic.types.ts b/tests/msw/schema/types/topic.types.ts
new file mode 100644
index 0000000..ba9abb7
--- /dev/null
+++ b/tests/msw/schema/types/topic.types.ts
@@ -0,0 +1,21 @@
+export const topicTypes = `union Topic_Acftopics_PostsInTopic = Post
+
+type Topic_Acftopics {
+ officialWebsite: String
+ postsInTopic: [Topic_Acftopics_PostsInTopic]
+}
+
+type Topic {
+ acfTopics: Topic_Acftopics
+ contentParts: ContentPartsType
+ databaseId: Int!
+ date: String
+ featuredImage: NodeWithFeaturedImageToMediaItemConnectionEdge
+ info: InfoType
+ modified: String
+ seo: PostTypeSEO
+ slug: String
+ title(format: PostObjectFieldFormatEnum): String
+}`;
+
+// cSpell:ignore Acftopics