|
|
@@ -28,14 +28,14 @@ import {
|
|
|
SettleRefund,
|
|
|
UpdateProductVariants,
|
|
|
} from './graphql/generated-e2e-admin-types';
|
|
|
-import { AddItemToOrder } from './graphql/generated-e2e-shop-types';
|
|
|
+import { AddItemToOrder, GetActiveOrder } from './graphql/generated-e2e-shop-types';
|
|
|
import {
|
|
|
GET_CUSTOMER_LIST,
|
|
|
GET_PRODUCT_WITH_VARIANTS,
|
|
|
GET_STOCK_MOVEMENT,
|
|
|
UPDATE_PRODUCT_VARIANTS,
|
|
|
} from './graphql/shared-definitions';
|
|
|
-import { ADD_ITEM_TO_ORDER } from './graphql/shop-definitions';
|
|
|
+import { ADD_ITEM_TO_ORDER, GET_ACTIVE_ORDER } from './graphql/shop-definitions';
|
|
|
import { TestAdminClient, TestShopClient } from './test-client';
|
|
|
import { TestServer } from './test-server';
|
|
|
import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
|
|
|
@@ -52,7 +52,7 @@ describe('Orders resolver', () => {
|
|
|
const token = await server.init(
|
|
|
{
|
|
|
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
|
|
|
- customerCount: 2,
|
|
|
+ customerCount: 3,
|
|
|
},
|
|
|
{
|
|
|
paymentOptions: {
|
|
|
@@ -71,7 +71,7 @@ describe('Orders resolver', () => {
|
|
|
GET_CUSTOMER_LIST,
|
|
|
{
|
|
|
options: {
|
|
|
- take: 2,
|
|
|
+ take: 3,
|
|
|
},
|
|
|
},
|
|
|
);
|
|
|
@@ -1092,37 +1092,102 @@ describe('Orders resolver', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- it('addNoteToOrder', async () => {
|
|
|
- const { addNoteToOrder } = await adminClient.query<AddNoteToOrder.Mutation, AddNoteToOrder.Variables>(
|
|
|
- ADD_NOTE_TO_ORDER,
|
|
|
- {
|
|
|
+ describe('order notes', () => {
|
|
|
+ let orderId: string;
|
|
|
+
|
|
|
+ beforeAll(async () => {
|
|
|
+ const result = await createTestOrder(
|
|
|
+ adminClient,
|
|
|
+ shopClient,
|
|
|
+ customers[2].emailAddress,
|
|
|
+ password,
|
|
|
+ );
|
|
|
+
|
|
|
+ orderId = result.orderId;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('private note', async () => {
|
|
|
+ const { addNoteToOrder } = await adminClient.query<
|
|
|
+ AddNoteToOrder.Mutation,
|
|
|
+ AddNoteToOrder.Variables
|
|
|
+ >(ADD_NOTE_TO_ORDER, {
|
|
|
input: {
|
|
|
- id: 'T_4',
|
|
|
- note: 'A test note',
|
|
|
+ id: orderId,
|
|
|
+ note: 'A private note',
|
|
|
+ isPublic: false,
|
|
|
},
|
|
|
- },
|
|
|
- );
|
|
|
+ });
|
|
|
|
|
|
- expect(addNoteToOrder.id).toBe('T_4');
|
|
|
+ expect(addNoteToOrder.id).toBe(orderId);
|
|
|
|
|
|
- const { order } = await adminClient.query<GetOrderHistory.Query, GetOrderHistory.Variables>(
|
|
|
- GET_ORDER_HISTORY,
|
|
|
- {
|
|
|
- id: 'T_4',
|
|
|
- options: {
|
|
|
- skip: 2,
|
|
|
+ const { order } = await adminClient.query<GetOrderHistory.Query, GetOrderHistory.Variables>(
|
|
|
+ GET_ORDER_HISTORY,
|
|
|
+ {
|
|
|
+ id: orderId,
|
|
|
+ options: {
|
|
|
+ skip: 0,
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- );
|
|
|
+ );
|
|
|
|
|
|
- expect(order!.history.items.map(pick(['type', 'data']))).toEqual([
|
|
|
- {
|
|
|
- type: HistoryEntryType.ORDER_NOTE,
|
|
|
- data: {
|
|
|
- note: 'A test note',
|
|
|
+ expect(order!.history.items.map(pick(['type', 'data']))).toEqual([
|
|
|
+ {
|
|
|
+ type: HistoryEntryType.ORDER_NOTE,
|
|
|
+ data: {
|
|
|
+ note: 'A private note',
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- ]);
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
|
|
|
+
|
|
|
+ expect(activeOrder!.history.items.map(pick(['type', 'data']))).toEqual([]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('public note', async () => {
|
|
|
+ const { addNoteToOrder } = await adminClient.query<
|
|
|
+ AddNoteToOrder.Mutation,
|
|
|
+ AddNoteToOrder.Variables
|
|
|
+ >(ADD_NOTE_TO_ORDER, {
|
|
|
+ input: {
|
|
|
+ id: orderId,
|
|
|
+ note: 'A public note',
|
|
|
+ isPublic: true,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(addNoteToOrder.id).toBe(orderId);
|
|
|
+
|
|
|
+ const { order } = await adminClient.query<GetOrderHistory.Query, GetOrderHistory.Variables>(
|
|
|
+ GET_ORDER_HISTORY,
|
|
|
+ {
|
|
|
+ id: orderId,
|
|
|
+ options: {
|
|
|
+ skip: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(order!.history.items.map(pick(['type', 'data']))).toEqual([
|
|
|
+ {
|
|
|
+ type: HistoryEntryType.ORDER_NOTE,
|
|
|
+ data: {
|
|
|
+ note: 'A public note',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
|
|
|
+
|
|
|
+ expect(activeOrder!.history.items.map(pick(['type', 'data']))).toEqual([
|
|
|
+ {
|
|
|
+ type: HistoryEntryType.ORDER_NOTE,
|
|
|
+ data: {
|
|
|
+ note: 'A public note',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
|