Browse Source

chore: Move duplicated e2e definitions to shared file

Michael Bromley 5 years ago
parent
commit
657949e393

+ 7 - 150
packages/core/e2e/customer-channel.e2e-spec.ts

@@ -1,12 +1,10 @@
 /* tslint:disable:no-non-null-assertion */
 import { createTestEnvironment, E2E_DEFAULT_CHANNEL_TOKEN } from '@vendure/testing';
-import gql from 'graphql-tag';
 import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
 import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
 
-import { CUSTOMER_FRAGMENT } from './graphql/fragments';
 import {
     AddCustomersToGroup,
     CreateAddress,
@@ -26,12 +24,18 @@ import {
 } from './graphql/generated-e2e-admin-types';
 import { Register } from './graphql/generated-e2e-shop-types';
 import {
+    ADD_CUSTOMERS_TO_GROUP,
+    CREATE_ADDRESS,
     CREATE_CHANNEL,
+    CREATE_CUSTOMER,
     CREATE_CUSTOMER_GROUP,
-    CUSTOMER_GROUP_FRAGMENT,
+    DELETE_CUSTOMER,
+    GET_CUSTOMER_GROUP,
     GET_CUSTOMER_LIST,
     ME,
     REMOVE_CUSTOMERS_FROM_GROUP,
+    UPDATE_ADDRESS,
+    UPDATE_CUSTOMER,
 } from './graphql/shared-definitions';
 import { DELETE_ADDRESS, REGISTER_ACCOUNT } from './graphql/shop-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
@@ -338,150 +342,3 @@ describe('ChannelAware Customers', () => {
         });
     });
 });
-
-export const CREATE_ADDRESS = gql`
-    mutation CreateAddress($id: ID!, $input: CreateAddressInput!) {
-        createCustomerAddress(customerId: $id, input: $input) {
-            id
-            fullName
-            company
-            streetLine1
-            streetLine2
-            city
-            province
-            postalCode
-            country {
-                code
-                name
-            }
-            phoneNumber
-            defaultShippingAddress
-            defaultBillingAddress
-        }
-    }
-`;
-
-export const UPDATE_ADDRESS = gql`
-    mutation UpdateAddress($input: UpdateAddressInput!) {
-        updateCustomerAddress(input: $input) {
-            id
-            defaultShippingAddress
-            defaultBillingAddress
-            country {
-                code
-                name
-            }
-        }
-    }
-`;
-
-export const CREATE_CUSTOMER = gql`
-    mutation CreateCustomer($input: CreateCustomerInput!, $password: String) {
-        createCustomer(input: $input, password: $password) {
-            ...Customer
-        }
-    }
-    ${CUSTOMER_FRAGMENT}
-`;
-
-export const UPDATE_CUSTOMER = gql`
-    mutation UpdateCustomer($input: UpdateCustomerInput!) {
-        updateCustomer(input: $input) {
-            ...Customer
-        }
-    }
-    ${CUSTOMER_FRAGMENT}
-`;
-
-export const DELETE_CUSTOMER = gql`
-    mutation DeleteCustomer($id: ID!) {
-        deleteCustomer(id: $id) {
-            result
-        }
-    }
-`;
-
-export const UPDATE_CUSTOMER_NOTE = gql`
-    mutation UpdateCustomerNote($input: UpdateCustomerNoteInput!) {
-        updateCustomerNote(input: $input) {
-            id
-            data
-            isPublic
-        }
-    }
-`;
-
-export const DELETE_CUSTOMER_NOTE = gql`
-    mutation DeleteCustomerNote($id: ID!) {
-        deleteCustomerNote(id: $id) {
-            result
-            message
-        }
-    }
-`;
-
-export const UPDATE_CUSTOMER_GROUP = gql`
-    mutation UpdateCustomerGroup($input: UpdateCustomerGroupInput!) {
-        updateCustomerGroup(input: $input) {
-            ...CustomerGroup
-        }
-    }
-    ${CUSTOMER_GROUP_FRAGMENT}
-`;
-
-export const DELETE_CUSTOMER_GROUP = gql`
-    mutation DeleteCustomerGroup($id: ID!) {
-        deleteCustomerGroup(id: $id) {
-            result
-            message
-        }
-    }
-`;
-
-export const GET_CUSTOMER_GROUPS = gql`
-    query GetCustomerGroups($options: CustomerGroupListOptions) {
-        customerGroups(options: $options) {
-            items {
-                id
-                name
-            }
-            totalItems
-        }
-    }
-`;
-
-export const GET_CUSTOMER_GROUP = gql`
-    query GetCustomerGroup($id: ID!, $options: CustomerListOptions) {
-        customerGroup(id: $id) {
-            id
-            name
-            customers(options: $options) {
-                items {
-                    id
-                }
-                totalItems
-            }
-        }
-    }
-`;
-
-export const ADD_CUSTOMERS_TO_GROUP = gql`
-    mutation AddCustomersToGroup($groupId: ID!, $customerIds: [ID!]!) {
-        addCustomersToGroup(customerGroupId: $groupId, customerIds: $customerIds) {
-            ...CustomerGroup
-        }
-    }
-    ${CUSTOMER_GROUP_FRAGMENT}
-`;
-
-export const GET_CUSTOMER_WITH_GROUPS = gql`
-    query GetCustomerWithGroups($id: ID!) {
-        customer(id: $id) {
-            id
-            groups {
-                id
-                name
-            }
-        }
-    }
-`;

+ 6 - 68
packages/core/e2e/customer-group.e2e-spec.ts

@@ -1,6 +1,5 @@
 import { pick } from '@vendure/common/lib/pick';
 import { createTestEnvironment } from '@vendure/testing';
-import gql from 'graphql-tag';
 import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
@@ -21,11 +20,16 @@ import {
 } from './graphql/generated-e2e-admin-types';
 import { DeletionResult } from './graphql/generated-e2e-shop-types';
 import {
+    ADD_CUSTOMERS_TO_GROUP,
     CREATE_CUSTOMER_GROUP,
-    CUSTOMER_GROUP_FRAGMENT,
+    DELETE_CUSTOMER_GROUP,
+    GET_CUSTOMER_GROUP,
+    GET_CUSTOMER_GROUPS,
     GET_CUSTOMER_HISTORY,
     GET_CUSTOMER_LIST,
+    GET_CUSTOMER_WITH_GROUPS,
     REMOVE_CUSTOMERS_FROM_GROUP,
+    UPDATE_CUSTOMER_GROUP,
 } from './graphql/shared-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 import { sortById } from './utils/test-order-utils';
@@ -282,69 +286,3 @@ describe('CustomerGroup resolver', () => {
         expect(customerGroups.totalItems).toBe(0);
     });
 });
-
-export const UPDATE_CUSTOMER_GROUP = gql`
-    mutation UpdateCustomerGroup($input: UpdateCustomerGroupInput!) {
-        updateCustomerGroup(input: $input) {
-            ...CustomerGroup
-        }
-    }
-    ${CUSTOMER_GROUP_FRAGMENT}
-`;
-
-export const DELETE_CUSTOMER_GROUP = gql`
-    mutation DeleteCustomerGroup($id: ID!) {
-        deleteCustomerGroup(id: $id) {
-            result
-            message
-        }
-    }
-`;
-
-export const GET_CUSTOMER_GROUPS = gql`
-    query GetCustomerGroups($options: CustomerGroupListOptions) {
-        customerGroups(options: $options) {
-            items {
-                id
-                name
-            }
-            totalItems
-        }
-    }
-`;
-
-export const GET_CUSTOMER_GROUP = gql`
-    query GetCustomerGroup($id: ID!, $options: CustomerListOptions) {
-        customerGroup(id: $id) {
-            id
-            name
-            customers(options: $options) {
-                items {
-                    id
-                }
-                totalItems
-            }
-        }
-    }
-`;
-
-export const ADD_CUSTOMERS_TO_GROUP = gql`
-    mutation AddCustomersToGroup($groupId: ID!, $customerIds: [ID!]!) {
-        addCustomersToGroup(customerGroupId: $groupId, customerIds: $customerIds) {
-            ...CustomerGroup
-        }
-    }
-    ${CUSTOMER_GROUP_FRAGMENT}
-`;
-
-export const GET_CUSTOMER_WITH_GROUPS = gql`
-    query GetCustomerWithGroups($id: ID!) {
-        customer(id: $id) {
-            id
-            groups {
-                id
-                name
-            }
-        }
-    }
-`;

+ 12 - 82
packages/core/e2e/customer.e2e-spec.ts

@@ -35,7 +35,18 @@ import {
     UpdateCustomerNote,
 } from './graphql/generated-e2e-admin-types';
 import { AddItemToOrder } from './graphql/generated-e2e-shop-types';
-import { GET_CUSTOMER, GET_CUSTOMER_HISTORY, GET_CUSTOMER_LIST } from './graphql/shared-definitions';
+import {
+    CREATE_ADDRESS,
+    CREATE_CUSTOMER,
+    DELETE_CUSTOMER,
+    DELETE_CUSTOMER_NOTE,
+    GET_CUSTOMER,
+    GET_CUSTOMER_HISTORY,
+    GET_CUSTOMER_LIST,
+    UPDATE_ADDRESS,
+    UPDATE_CUSTOMER,
+    UPDATE_CUSTOMER_NOTE,
+} from './graphql/shared-definitions';
 import { ADD_ITEM_TO_ORDER } from './graphql/shop-definitions';
 import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
 
@@ -593,42 +604,6 @@ const GET_CUSTOMER_WITH_USER = gql`
     }
 `;
 
-export const CREATE_ADDRESS = gql`
-    mutation CreateAddress($id: ID!, $input: CreateAddressInput!) {
-        createCustomerAddress(customerId: $id, input: $input) {
-            id
-            fullName
-            company
-            streetLine1
-            streetLine2
-            city
-            province
-            postalCode
-            country {
-                code
-                name
-            }
-            phoneNumber
-            defaultShippingAddress
-            defaultBillingAddress
-        }
-    }
-`;
-
-export const UPDATE_ADDRESS = gql`
-    mutation UpdateAddress($input: UpdateAddressInput!) {
-        updateCustomerAddress(input: $input) {
-            id
-            defaultShippingAddress
-            defaultBillingAddress
-            country {
-                code
-                name
-            }
-        }
-    }
-`;
-
 const GET_CUSTOMER_ORDERS = gql`
     query GetCustomerOrders($id: ID!) {
         customer(id: $id) {
@@ -642,32 +617,6 @@ const GET_CUSTOMER_ORDERS = gql`
     }
 `;
 
-export const CREATE_CUSTOMER = gql`
-    mutation CreateCustomer($input: CreateCustomerInput!, $password: String) {
-        createCustomer(input: $input, password: $password) {
-            ...Customer
-        }
-    }
-    ${CUSTOMER_FRAGMENT}
-`;
-
-export const UPDATE_CUSTOMER = gql`
-    mutation UpdateCustomer($input: UpdateCustomerInput!) {
-        updateCustomer(input: $input) {
-            ...Customer
-        }
-    }
-    ${CUSTOMER_FRAGMENT}
-`;
-
-export const DELETE_CUSTOMER = gql`
-    mutation DeleteCustomer($id: ID!) {
-        deleteCustomer(id: $id) {
-            result
-        }
-    }
-`;
-
 const ADD_NOTE_TO_CUSTOMER = gql`
     mutation AddNoteToCustomer($input: AddNoteToCustomerInput!) {
         addNoteToCustomer(input: $input) {
@@ -676,22 +625,3 @@ const ADD_NOTE_TO_CUSTOMER = gql`
     }
     ${CUSTOMER_FRAGMENT}
 `;
-
-export const UPDATE_CUSTOMER_NOTE = gql`
-    mutation UpdateCustomerNote($input: UpdateCustomerNoteInput!) {
-        updateCustomerNote(input: $input) {
-            id
-            data
-            isPublic
-        }
-    }
-`;
-
-export const DELETE_CUSTOMER_NOTE = gql`
-    mutation DeleteCustomerNote($id: ID!) {
-        deleteCustomerNote(id: $id) {
-            result
-            message
-        }
-    }
-`;

+ 0 - 10
packages/core/e2e/fulfillment-process.e2e-spec.ts

@@ -230,13 +230,3 @@ describe('Fulfillment process', () => {
         });
     });
 });
-
-export const ADMIN_TRANSITION_TO_STATE = gql`
-    mutation AdminTransition($id: ID!, $state: String!) {
-        transitionOrderToState(id: $id, state: $state) {
-            id
-            state
-            nextStates
-        }
-    }
-`;

File diff suppressed because it is too large
+ 345 - 581
packages/core/e2e/graphql/generated-e2e-admin-types.ts


+ 157 - 0
packages/core/e2e/graphql/shared-definitions.ts

@@ -487,3 +487,160 @@ export const GET_ORDERS_LIST = gql`
     }
     ${ORDER_FRAGMENT}
 `;
+
+export const CREATE_ADDRESS = gql`
+    mutation CreateAddress($id: ID!, $input: CreateAddressInput!) {
+        createCustomerAddress(customerId: $id, input: $input) {
+            id
+            fullName
+            company
+            streetLine1
+            streetLine2
+            city
+            province
+            postalCode
+            country {
+                code
+                name
+            }
+            phoneNumber
+            defaultShippingAddress
+            defaultBillingAddress
+        }
+    }
+`;
+
+export const UPDATE_ADDRESS = gql`
+    mutation UpdateAddress($input: UpdateAddressInput!) {
+        updateCustomerAddress(input: $input) {
+            id
+            defaultShippingAddress
+            defaultBillingAddress
+            country {
+                code
+                name
+            }
+        }
+    }
+`;
+
+export const CREATE_CUSTOMER = gql`
+    mutation CreateCustomer($input: CreateCustomerInput!, $password: String) {
+        createCustomer(input: $input, password: $password) {
+            ...Customer
+        }
+    }
+    ${CUSTOMER_FRAGMENT}
+`;
+
+export const UPDATE_CUSTOMER = gql`
+    mutation UpdateCustomer($input: UpdateCustomerInput!) {
+        updateCustomer(input: $input) {
+            ...Customer
+        }
+    }
+    ${CUSTOMER_FRAGMENT}
+`;
+
+export const DELETE_CUSTOMER = gql`
+    mutation DeleteCustomer($id: ID!) {
+        deleteCustomer(id: $id) {
+            result
+        }
+    }
+`;
+
+export const UPDATE_CUSTOMER_NOTE = gql`
+    mutation UpdateCustomerNote($input: UpdateCustomerNoteInput!) {
+        updateCustomerNote(input: $input) {
+            id
+            data
+            isPublic
+        }
+    }
+`;
+
+export const DELETE_CUSTOMER_NOTE = gql`
+    mutation DeleteCustomerNote($id: ID!) {
+        deleteCustomerNote(id: $id) {
+            result
+            message
+        }
+    }
+`;
+
+export const UPDATE_CUSTOMER_GROUP = gql`
+    mutation UpdateCustomerGroup($input: UpdateCustomerGroupInput!) {
+        updateCustomerGroup(input: $input) {
+            ...CustomerGroup
+        }
+    }
+    ${CUSTOMER_GROUP_FRAGMENT}
+`;
+
+export const DELETE_CUSTOMER_GROUP = gql`
+    mutation DeleteCustomerGroup($id: ID!) {
+        deleteCustomerGroup(id: $id) {
+            result
+            message
+        }
+    }
+`;
+
+export const GET_CUSTOMER_GROUPS = gql`
+    query GetCustomerGroups($options: CustomerGroupListOptions) {
+        customerGroups(options: $options) {
+            items {
+                id
+                name
+            }
+            totalItems
+        }
+    }
+`;
+
+export const GET_CUSTOMER_GROUP = gql`
+    query GetCustomerGroup($id: ID!, $options: CustomerListOptions) {
+        customerGroup(id: $id) {
+            id
+            name
+            customers(options: $options) {
+                items {
+                    id
+                }
+                totalItems
+            }
+        }
+    }
+`;
+
+export const ADD_CUSTOMERS_TO_GROUP = gql`
+    mutation AddCustomersToGroup($groupId: ID!, $customerIds: [ID!]!) {
+        addCustomersToGroup(customerGroupId: $groupId, customerIds: $customerIds) {
+            ...CustomerGroup
+        }
+    }
+    ${CUSTOMER_GROUP_FRAGMENT}
+`;
+
+export const GET_CUSTOMER_WITH_GROUPS = gql`
+    query GetCustomerWithGroups($id: ID!) {
+        customer(id: $id) {
+            id
+            groups {
+                id
+                name
+            }
+        }
+    }
+`;
+
+export const ADMIN_TRANSITION_TO_STATE = gql`
+    mutation AdminTransition($id: ID!, $state: String!) {
+        transitionOrderToState(id: $id, state: $state) {
+            id
+            state
+            nextStates
+        }
+    }
+`;

+ 1 - 12
packages/core/e2e/order-process.e2e-spec.ts

@@ -1,7 +1,6 @@
 /* tslint:disable:no-non-null-assertion */
 import { CustomOrderProcess, mergeConfig, OrderState } from '@vendure/core';
 import { createTestEnvironment } from '@vendure/testing';
-import gql from 'graphql-tag';
 import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
@@ -18,7 +17,7 @@ import {
     SetShippingMethod,
     TransitionToState,
 } from './graphql/generated-e2e-shop-types';
-import { GET_ORDER } from './graphql/shared-definitions';
+import { ADMIN_TRANSITION_TO_STATE, GET_ORDER } from './graphql/shared-definitions';
 import {
     ADD_ITEM_TO_ORDER,
     ADD_PAYMENT,
@@ -400,13 +399,3 @@ describe('Order process', () => {
         });
     });
 });
-
-export const ADMIN_TRANSITION_TO_STATE = gql`
-    mutation AdminTransition($id: ID!, $state: String!) {
-        transitionOrderToState(id: $id, state: $state) {
-            id
-            state
-            nextStates
-        }
-    }
-`;

Some files were not shown because too many files changed in this diff