order.e2e-spec.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. import gql from 'graphql-tag';
  2. import { CreateAddressInput, GetCustomerList } from 'shared/generated-types';
  3. import { GET_CUSTOMER_LIST } from '../../admin-ui/src/app/data/definitions/customer-definitions';
  4. import { PaymentMethodHandler } from '../src/config/payment-method/payment-method-handler';
  5. import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
  6. import { TestClient } from './test-client';
  7. import { TestServer } from './test-server';
  8. describe('Orders', () => {
  9. const client = new TestClient();
  10. const server = new TestServer();
  11. beforeAll(async () => {
  12. const token = await server.init(
  13. {
  14. productCount: 10,
  15. customerCount: 2,
  16. },
  17. {
  18. paymentOptions: {
  19. paymentMethodHandlers: [testPaymentMethod, testFailingPaymentMethod],
  20. },
  21. },
  22. );
  23. await client.init();
  24. }, TEST_SETUP_TIMEOUT_MS);
  25. afterAll(async () => {
  26. await server.destroy();
  27. });
  28. describe('as anonymous user', () => {
  29. let firstOrderItemId: string;
  30. beforeAll(async () => {
  31. await client.asAnonymousUser();
  32. });
  33. it('addItemToOrder starts with no session token', () => {
  34. expect(client.getAuthToken()).toBe('');
  35. });
  36. it('activeOrder returns null before any items have been added', async () => {
  37. const result = await client.query(GET_ACTIVE_ORDER);
  38. expect(result.activeOrder).toBeNull();
  39. });
  40. it('activeOrder creates an anonymous session', () => {
  41. expect(client.getAuthToken()).not.toBe('');
  42. });
  43. it('addItemToOrder creates a new Order with an item', async () => {
  44. const result = await client.query(ADD_ITEM_TO_ORDER, {
  45. productVariantId: 'T_1',
  46. quantity: 1,
  47. });
  48. expect(result.addItemToOrder.lines.length).toBe(1);
  49. expect(result.addItemToOrder.lines[0].quantity).toBe(1);
  50. expect(result.addItemToOrder.lines[0].productVariant.id).toBe('T_1');
  51. expect(result.addItemToOrder.lines[0].id).toBe('T_1');
  52. firstOrderItemId = result.addItemToOrder.lines[0].id;
  53. });
  54. it('addItemToOrder errors with an invalid productVariantId', async () => {
  55. try {
  56. await client.query(ADD_ITEM_TO_ORDER, {
  57. productVariantId: 'T_999',
  58. quantity: 1,
  59. });
  60. fail('Should have thrown');
  61. } catch (err) {
  62. expect(err.message).toEqual(
  63. expect.stringContaining(`No ProductVariant with the id '999' could be found`),
  64. );
  65. }
  66. });
  67. it('addItemToOrder errors with a negative quantity', async () => {
  68. try {
  69. await client.query(ADD_ITEM_TO_ORDER, {
  70. productVariantId: 'T_999',
  71. quantity: -3,
  72. });
  73. fail('Should have thrown');
  74. } catch (err) {
  75. expect(err.message).toEqual(
  76. expect.stringContaining(`-3 is not a valid quantity for an OrderItem`),
  77. );
  78. }
  79. });
  80. it('addItemToOrder with an existing productVariantId adds quantity to the existing OrderLine', async () => {
  81. const result = await client.query(ADD_ITEM_TO_ORDER, {
  82. productVariantId: 'T_1',
  83. quantity: 2,
  84. });
  85. expect(result.addItemToOrder.lines.length).toBe(1);
  86. expect(result.addItemToOrder.lines[0].quantity).toBe(3);
  87. });
  88. it('adjustItemQuantity adjusts the quantity', async () => {
  89. const result = await client.query(ADJUST_ITEM_QUENTITY, {
  90. orderItemId: firstOrderItemId,
  91. quantity: 50,
  92. });
  93. expect(result.adjustItemQuantity.lines.length).toBe(1);
  94. expect(result.adjustItemQuantity.lines[0].quantity).toBe(50);
  95. });
  96. it('adjustItemQuantity errors with a negative quantity', async () => {
  97. try {
  98. await client.query(ADJUST_ITEM_QUENTITY, {
  99. orderItemId: firstOrderItemId,
  100. quantity: -3,
  101. });
  102. fail('Should have thrown');
  103. } catch (err) {
  104. expect(err.message).toEqual(
  105. expect.stringContaining(`-3 is not a valid quantity for an OrderItem`),
  106. );
  107. }
  108. });
  109. it('adjustItemQuantity errors with an invalid orderItemId', async () => {
  110. try {
  111. await client.query(ADJUST_ITEM_QUENTITY, {
  112. orderItemId: 'T_999',
  113. quantity: 5,
  114. });
  115. fail('Should have thrown');
  116. } catch (err) {
  117. expect(err.message).toEqual(
  118. expect.stringContaining(`This order does not contain an OrderLine with the id 999`),
  119. );
  120. }
  121. });
  122. it('removeItemFromOrder removes the correct item', async () => {
  123. const result1 = await client.query(ADD_ITEM_TO_ORDER, {
  124. productVariantId: 'T_3',
  125. quantity: 3,
  126. });
  127. expect(result1.addItemToOrder.lines.length).toBe(2);
  128. expect(result1.addItemToOrder.lines.map(i => i.productVariant.id)).toEqual(['T_1', 'T_3']);
  129. const result2 = await client.query(REMOVE_ITEM_FROM_ORDER, {
  130. orderItemId: firstOrderItemId,
  131. });
  132. expect(result2.removeItemFromOrder.lines.length).toBe(1);
  133. expect(result2.removeItemFromOrder.lines.map(i => i.productVariant.id)).toEqual(['T_3']);
  134. });
  135. it('removeItemFromOrder errors with an invalid orderItemId', async () => {
  136. try {
  137. await client.query(REMOVE_ITEM_FROM_ORDER, {
  138. orderItemId: 'T_999',
  139. });
  140. fail('Should have thrown');
  141. } catch (err) {
  142. expect(err.message).toEqual(
  143. expect.stringContaining(`This order does not contain an OrderLine with the id 999`),
  144. );
  145. }
  146. });
  147. it('nextOrderStates returns next valid states', async () => {
  148. const result = await client.query(gql`
  149. query {
  150. nextOrderStates
  151. }
  152. `);
  153. expect(result.nextOrderStates).toEqual(['ArrangingPayment']);
  154. });
  155. it('transitionOrderToState throws for an invalid state', async () => {
  156. try {
  157. await client.query(TRANSITION_TO_STATE, { state: 'Completed' });
  158. fail('Should have thrown');
  159. } catch (err) {
  160. expect(err.message).toEqual(
  161. expect.stringContaining(`Cannot transition Order from "AddingItems" to "Completed"`),
  162. );
  163. }
  164. });
  165. it('transitionOrderToState transitions Order to the next valid state', async () => {
  166. const result = await client.query(TRANSITION_TO_STATE, { state: 'ArrangingPayment' });
  167. expect(result.transitionOrderToState).toEqual({ id: 'T_1', state: 'ArrangingPayment' });
  168. });
  169. });
  170. describe('as authenticated user', () => {
  171. let firstOrderItemId: string;
  172. let activeOrder: any;
  173. let authenticatedUserEmailAddress: string;
  174. let customers: GetCustomerList.Items[];
  175. const password = 'test';
  176. beforeAll(async () => {
  177. await client.asSuperAdmin();
  178. const result = await client.query<GetCustomerList.Query, GetCustomerList.Variables>(
  179. GET_CUSTOMER_LIST,
  180. {
  181. options: {
  182. take: 2,
  183. },
  184. },
  185. );
  186. customers = result.customers.items;
  187. authenticatedUserEmailAddress = customers[0].emailAddress;
  188. await client.asUserWithCredentials(authenticatedUserEmailAddress, password);
  189. });
  190. it('activeOrder returns null before any items have been added', async () => {
  191. const result = await client.query(GET_ACTIVE_ORDER);
  192. expect(result.activeOrder).toBeNull();
  193. });
  194. it('addItemToOrder creates a new Order with an item', async () => {
  195. const result = await client.query(ADD_ITEM_TO_ORDER, {
  196. productVariantId: 'T_1',
  197. quantity: 1,
  198. });
  199. expect(result.addItemToOrder.lines.length).toBe(1);
  200. expect(result.addItemToOrder.lines[0].quantity).toBe(1);
  201. expect(result.addItemToOrder.lines[0].productVariant.id).toBe('T_1');
  202. activeOrder = result.addItemToOrder;
  203. firstOrderItemId = result.addItemToOrder.lines[0].id;
  204. });
  205. it('activeOrder returns order after item has been added', async () => {
  206. const result = await client.query(GET_ACTIVE_ORDER);
  207. expect(result.activeOrder.id).toBe(activeOrder.id);
  208. expect(result.activeOrder.state).toBe('AddingItems');
  209. });
  210. it('addItemToOrder with an existing productVariantId adds quantity to the existing OrderLine', async () => {
  211. const result = await client.query(ADD_ITEM_TO_ORDER, {
  212. productVariantId: 'T_1',
  213. quantity: 2,
  214. });
  215. expect(result.addItemToOrder.lines.length).toBe(1);
  216. expect(result.addItemToOrder.lines[0].quantity).toBe(3);
  217. });
  218. it('adjustItemQuantity adjusts the quantity', async () => {
  219. const result = await client.query(ADJUST_ITEM_QUENTITY, {
  220. orderItemId: firstOrderItemId,
  221. quantity: 50,
  222. });
  223. expect(result.adjustItemQuantity.lines.length).toBe(1);
  224. expect(result.adjustItemQuantity.lines[0].quantity).toBe(50);
  225. });
  226. it('removeItemFromOrder removes the correct item', async () => {
  227. const result1 = await client.query(ADD_ITEM_TO_ORDER, {
  228. productVariantId: 'T_3',
  229. quantity: 3,
  230. });
  231. expect(result1.addItemToOrder.lines.length).toBe(2);
  232. expect(result1.addItemToOrder.lines.map(i => i.productVariant.id)).toEqual(['T_1', 'T_3']);
  233. const result2 = await client.query(REMOVE_ITEM_FROM_ORDER, {
  234. orderItemId: firstOrderItemId,
  235. });
  236. expect(result2.removeItemFromOrder.lines.length).toBe(1);
  237. expect(result2.removeItemFromOrder.lines.map(i => i.productVariant.id)).toEqual(['T_3']);
  238. });
  239. it('nextOrderStates returns next valid states', async () => {
  240. const result = await client.query(GET_NEXT_STATES);
  241. expect(result.nextOrderStates).toEqual(['ArrangingPayment']);
  242. });
  243. it('logging out and back in again resumes the last active order', async () => {
  244. await client.asAnonymousUser();
  245. const result1 = await client.query(GET_ACTIVE_ORDER);
  246. expect(result1.activeOrder).toBeNull();
  247. await client.asUserWithCredentials(authenticatedUserEmailAddress, password);
  248. const result2 = await client.query(GET_ACTIVE_ORDER);
  249. expect(result2.activeOrder.id).toBe(activeOrder.id);
  250. });
  251. describe('shipping', () => {
  252. let shippingMethods: any;
  253. it('setOrderShippingAddress sets shipping address', async () => {
  254. const address: CreateAddressInput = {
  255. fullName: 'name',
  256. company: 'company',
  257. streetLine1: '12 the street',
  258. streetLine2: 'line 2',
  259. city: 'foo',
  260. province: 'bar',
  261. postalCode: '123456',
  262. country: 'baz',
  263. phoneNumber: '4444444',
  264. };
  265. const result = await client.query(SET_SHIPPING_ADDRESS, {
  266. input: address,
  267. });
  268. expect(result.setOrderShippingAddress.shippingAddress).toEqual(address);
  269. });
  270. it('eligibleShippingMethods lists shipping methods', async () => {
  271. const result = await client.query(GET_ELIGIBLE_SHIPPING_METHODS);
  272. shippingMethods = result.eligibleShippingMethods;
  273. expect(shippingMethods).toEqual([
  274. { id: 'T_1', price: 500, description: 'Standard Shipping' },
  275. { id: 'T_2', price: 1000, description: 'Express Shipping' },
  276. ]);
  277. });
  278. it('shipping is initially unset', async () => {
  279. const result = await client.query(GET_ACTIVE_ORDER);
  280. expect(result.activeOrder.shipping).toEqual(0);
  281. expect(result.activeOrder.shippingMethod).toEqual(null);
  282. });
  283. it('setOrderShippingMethod sets the shipping method', async () => {
  284. const result = await client.query(SET_SHIPPING_METHOD, {
  285. id: shippingMethods[1].id,
  286. });
  287. const activeOrderResult = await client.query(GET_ACTIVE_ORDER);
  288. const order = activeOrderResult.activeOrder;
  289. expect(order.shipping).toBe(shippingMethods[1].price);
  290. expect(order.shippingMethod.id).toBe(shippingMethods[1].id);
  291. expect(order.shippingMethod.description).toBe(shippingMethods[1].description);
  292. });
  293. it('shipping method is preserved after adjustItemQuantity', async () => {
  294. const activeOrderResult = await client.query(GET_ACTIVE_ORDER);
  295. activeOrder = activeOrderResult.activeOrder;
  296. const result = await client.query(ADJUST_ITEM_QUENTITY, {
  297. orderItemId: activeOrder.lines[0].id,
  298. quantity: 10,
  299. });
  300. expect(result.adjustItemQuantity.shipping).toBe(shippingMethods[1].price);
  301. expect(result.adjustItemQuantity.shippingMethod.id).toBe(shippingMethods[1].id);
  302. expect(result.adjustItemQuantity.shippingMethod.description).toBe(
  303. shippingMethods[1].description,
  304. );
  305. });
  306. });
  307. describe('payment', () => {
  308. it('attempting add a Payment throws error when in AddingItems state', async () => {
  309. try {
  310. await client.query(ADD_PAYMENT, {
  311. input: {
  312. method: testPaymentMethod.code,
  313. metadata: {},
  314. },
  315. });
  316. fail('Should have thrown');
  317. } catch (err) {
  318. expect(err.message).toEqual(
  319. expect.stringContaining(
  320. `A Payment may only be added when Order is in "ArrangingPayment" state`,
  321. ),
  322. );
  323. }
  324. });
  325. it('transitions to the ArrangingPayment state', async () => {
  326. const result = await client.query(TRANSITION_TO_STATE, { state: 'ArrangingPayment' });
  327. expect(result.transitionOrderToState).toEqual({
  328. id: activeOrder.id,
  329. state: 'ArrangingPayment',
  330. });
  331. });
  332. it('attempting to add an item throws error when in ArrangingPayment state', async () => {
  333. try {
  334. const result = await client.query(ADD_ITEM_TO_ORDER, {
  335. productVariantId: 'T_4',
  336. quantity: 1,
  337. });
  338. fail('Should have thrown');
  339. } catch (err) {
  340. expect(err.message).toEqual(
  341. expect.stringContaining(
  342. `Order contents may only be modified when in the "AddingItems" state`,
  343. ),
  344. );
  345. }
  346. });
  347. it('attempting to modify item quantity throws error when in ArrangingPayment state', async () => {
  348. try {
  349. const result = await client.query(ADJUST_ITEM_QUENTITY, {
  350. orderItemId: activeOrder.lines[0].id,
  351. quantity: 12,
  352. });
  353. fail('Should have thrown');
  354. } catch (err) {
  355. expect(err.message).toEqual(
  356. expect.stringContaining(
  357. `Order contents may only be modified when in the "AddingItems" state`,
  358. ),
  359. );
  360. }
  361. });
  362. it('attempting to remove an item throws error when in ArrangingPayment state', async () => {
  363. try {
  364. const result = await client.query(REMOVE_ITEM_FROM_ORDER, {
  365. orderItemId: activeOrder.lines[0].id,
  366. });
  367. fail('Should have thrown');
  368. } catch (err) {
  369. expect(err.message).toEqual(
  370. expect.stringContaining(
  371. `Order contents may only be modified when in the "AddingItems" state`,
  372. ),
  373. );
  374. }
  375. });
  376. it('attempting to setOrderShippingMethod throws error when in ArrangingPayment state', async () => {
  377. const shippingMethodsResult = await client.query(GET_ELIGIBLE_SHIPPING_METHODS);
  378. const shippingMethods = shippingMethodsResult.eligibleShippingMethods;
  379. try {
  380. await client.query(SET_SHIPPING_METHOD, {
  381. id: shippingMethods[0].id,
  382. });
  383. fail('Should have thrown');
  384. } catch (err) {
  385. expect(err.message).toEqual(
  386. expect.stringContaining(
  387. `Order contents may only be modified when in the "AddingItems" state`,
  388. ),
  389. );
  390. }
  391. });
  392. it('adds a declined payment', async () => {
  393. const result = await client.query(ADD_PAYMENT, {
  394. input: {
  395. method: testFailingPaymentMethod.code,
  396. metadata: {
  397. foo: 'bar',
  398. },
  399. },
  400. });
  401. const payment = result.addPaymentToOrder.payments[0];
  402. expect(result.addPaymentToOrder.payments.length).toBe(1);
  403. expect(payment.method).toBe(testFailingPaymentMethod.code);
  404. expect(payment.state).toBe('Declined');
  405. expect(payment.transactionId).toBe(null);
  406. expect(payment.metadata).toEqual({
  407. foo: 'bar',
  408. });
  409. });
  410. it('adds a successful payment and transitions Order state', async () => {
  411. const result = await client.query(ADD_PAYMENT, {
  412. input: {
  413. method: testPaymentMethod.code,
  414. metadata: {
  415. baz: 'quux',
  416. },
  417. },
  418. });
  419. const payment = result.addPaymentToOrder.payments[0];
  420. expect(result.addPaymentToOrder.state).toBe('PaymentSettled');
  421. expect(result.addPaymentToOrder.active).toBe(false);
  422. expect(result.addPaymentToOrder.payments.length).toBe(1);
  423. expect(payment.method).toBe(testPaymentMethod.code);
  424. expect(payment.state).toBe('Settled');
  425. expect(payment.transactionId).toBe('12345');
  426. expect(payment.metadata).toEqual({
  427. baz: 'quux',
  428. });
  429. });
  430. });
  431. describe('orderByCode', () => {
  432. it('works for own Order', async () => {
  433. const result = await client.query(GET_ORDER_BY_CODE, {
  434. code: activeOrder.code,
  435. });
  436. expect(result.orderByCode.id).toBe(activeOrder.id);
  437. });
  438. it("throws error for another user's Order", async () => {
  439. authenticatedUserEmailAddress = customers[1].emailAddress;
  440. await client.asUserWithCredentials(authenticatedUserEmailAddress, password);
  441. try {
  442. await client.query(GET_ORDER_BY_CODE, {
  443. code: activeOrder.code,
  444. });
  445. fail('Should have thrown');
  446. } catch (err) {
  447. expect(err.message).toEqual(expect.stringContaining(`This action is forbidden`));
  448. }
  449. });
  450. it('throws error when not logged in', async () => {
  451. await client.asAnonymousUser();
  452. try {
  453. await client.query(GET_ORDER_BY_CODE, {
  454. code: activeOrder.code,
  455. });
  456. fail('Should have thrown');
  457. } catch (err) {
  458. expect(err.message).toEqual(expect.stringContaining(`This action is forbidden`));
  459. }
  460. });
  461. });
  462. });
  463. });
  464. const testPaymentMethod = new PaymentMethodHandler({
  465. code: 'test-payment-method',
  466. name: 'Test Payment Method',
  467. args: {},
  468. createPayment: (order, args, metadata) => {
  469. return {
  470. amount: order.total,
  471. state: 'Settled',
  472. transactionId: '12345',
  473. metadata,
  474. };
  475. },
  476. });
  477. const testFailingPaymentMethod = new PaymentMethodHandler({
  478. code: 'test-failing-payment-method',
  479. name: 'Test Failing Payment Method',
  480. args: {},
  481. createPayment: (order, args, metadata) => {
  482. return {
  483. amount: order.total,
  484. state: 'Declined',
  485. metadata,
  486. };
  487. },
  488. });
  489. const TEST_ORDER_FRAGMENT = gql`
  490. fragment TestOrderFragment on Order {
  491. id
  492. code
  493. state
  494. active
  495. lines {
  496. id
  497. quantity
  498. productVariant {
  499. id
  500. }
  501. }
  502. shipping
  503. shippingMethod {
  504. id
  505. code
  506. description
  507. }
  508. }
  509. `;
  510. const GET_ACTIVE_ORDER = gql`
  511. query {
  512. activeOrder {
  513. ...TestOrderFragment
  514. }
  515. }
  516. ${TEST_ORDER_FRAGMENT}
  517. `;
  518. const ADD_ITEM_TO_ORDER = gql`
  519. mutation AddItemToOrder($productVariantId: ID!, $quantity: Int!) {
  520. addItemToOrder(productVariantId: $productVariantId, quantity: $quantity) {
  521. ...TestOrderFragment
  522. }
  523. }
  524. ${TEST_ORDER_FRAGMENT}
  525. `;
  526. const ADJUST_ITEM_QUENTITY = gql`
  527. mutation AdjustItemQuantity($orderItemId: ID!, $quantity: Int!) {
  528. adjustItemQuantity(orderItemId: $orderItemId, quantity: $quantity) {
  529. ...TestOrderFragment
  530. }
  531. }
  532. ${TEST_ORDER_FRAGMENT}
  533. `;
  534. const REMOVE_ITEM_FROM_ORDER = gql`
  535. mutation RemoveItemFromOrder($orderItemId: ID!) {
  536. removeItemFromOrder(orderItemId: $orderItemId) {
  537. ...TestOrderFragment
  538. }
  539. }
  540. ${TEST_ORDER_FRAGMENT}
  541. `;
  542. const GET_NEXT_STATES = gql`
  543. query {
  544. nextOrderStates
  545. }
  546. `;
  547. const TRANSITION_TO_STATE = gql`
  548. mutation TransitionToState($state: String!) {
  549. transitionOrderToState(state: $state) {
  550. id
  551. state
  552. }
  553. }
  554. `;
  555. const GET_ELIGIBLE_SHIPPING_METHODS = gql`
  556. query {
  557. eligibleShippingMethods {
  558. id
  559. price
  560. description
  561. }
  562. }
  563. `;
  564. const SET_SHIPPING_ADDRESS = gql`
  565. mutation SetShippingAddress($input: CreateAddressInput!) {
  566. setOrderShippingAddress(input: $input) {
  567. shippingAddress {
  568. fullName
  569. company
  570. streetLine1
  571. streetLine2
  572. city
  573. province
  574. postalCode
  575. country
  576. phoneNumber
  577. }
  578. }
  579. }
  580. `;
  581. const SET_SHIPPING_METHOD = gql`
  582. mutation SetShippingMethod($id: ID!) {
  583. setOrderShippingMethod(shippingMethodId: $id) {
  584. shipping
  585. shippingMethod {
  586. id
  587. code
  588. description
  589. }
  590. }
  591. }
  592. `;
  593. const ADD_PAYMENT = gql`
  594. mutation AddPaymentToOrder($input: PaymentInput!) {
  595. addPaymentToOrder(input: $input) {
  596. ...TestOrderFragment
  597. payments {
  598. id
  599. transactionId
  600. method
  601. amount
  602. state
  603. metadata
  604. }
  605. }
  606. }
  607. ${TEST_ORDER_FRAGMENT}
  608. `;
  609. const GET_ORDER_BY_CODE = gql`
  610. query GetOrderByCode($code: String!) {
  611. orderByCode(code: $code) {
  612. ...TestOrderFragment
  613. }
  614. }
  615. ${TEST_ORDER_FRAGMENT}
  616. `;