Skip to content

Commit

Permalink
chore: Move duplicated e2e definitions to shared file
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Sep 15, 2020
1 parent ff0d153 commit 657949e
Show file tree
Hide file tree
Showing 7 changed files with 534 additions and 910 deletions.
157 changes: 7 additions & 150 deletions packages/core/e2e/customer-channel.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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';
Expand Down Expand Up @@ -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
}
}
}
`;
74 changes: 6 additions & 68 deletions packages/core/e2e/customer-group.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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
}
}
}
`;
94 changes: 12 additions & 82 deletions packages/core/e2e/customer.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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
}
}
`;
Loading

0 comments on commit 657949e

Please sign in to comment.