custom-field-relations.e2e-spec.ts 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  1. import {
  2. assertFound,
  3. Asset,
  4. Collection,
  5. Country,
  6. CustomFields,
  7. DefaultLogger,
  8. defaultShippingCalculator,
  9. defaultShippingEligibilityChecker,
  10. Facet,
  11. FacetValue,
  12. LogLevel,
  13. manualFulfillmentHandler,
  14. mergeConfig,
  15. PluginCommonModule,
  16. Product,
  17. ProductOption,
  18. ProductOptionGroup,
  19. ProductVariant,
  20. RequestContext,
  21. ShippingMethod,
  22. TransactionalConnection,
  23. VendureEntity,
  24. VendurePlugin,
  25. } from '@vendure/core';
  26. import { createTestEnvironment } from '@vendure/testing';
  27. import gql from 'graphql-tag';
  28. import path from 'path';
  29. import { Repository } from 'typeorm';
  30. import { afterAll, beforeAll, describe, expect, it } from 'vitest';
  31. import { initialData } from '../../../e2e-common/e2e-initial-data';
  32. import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
  33. import { testSuccessfulPaymentMethod } from './fixtures/test-payment-methods';
  34. import { TestPlugin1636_1664 } from './fixtures/test-plugins/issue-1636-1664/issue-1636-1664-plugin';
  35. import { PluginIssue2453 } from './fixtures/test-plugins/issue-2453/plugin-issue2453';
  36. import { TestCustomEntity, WithCustomEntity } from './fixtures/test-plugins/with-custom-entity';
  37. import { AddItemToOrderMutationVariables } from './graphql/generated-e2e-shop-types';
  38. import { ADD_ITEM_TO_ORDER } from './graphql/shop-definitions';
  39. import { sortById } from './utils/test-order-utils';
  40. const entitiesWithCustomFields: Array<keyof CustomFields> = [
  41. 'Address',
  42. 'Administrator',
  43. 'Asset',
  44. 'Channel',
  45. 'Collection',
  46. 'Customer',
  47. 'CustomerGroup',
  48. 'Facet',
  49. 'FacetValue',
  50. 'Fulfillment',
  51. 'GlobalSettings',
  52. 'Order',
  53. 'OrderLine',
  54. 'PaymentMethod',
  55. 'Product',
  56. 'ProductOption',
  57. 'ProductOptionGroup',
  58. 'ProductVariant',
  59. 'Promotion',
  60. 'Region',
  61. 'Seller',
  62. 'ShippingMethod',
  63. 'TaxCategory',
  64. 'TaxRate',
  65. 'User',
  66. 'Zone',
  67. ];
  68. const customFieldConfig: CustomFields = {};
  69. for (const entity of entitiesWithCustomFields) {
  70. customFieldConfig[entity] = [
  71. { name: 'primitive', type: 'string', list: false, defaultValue: 'test' },
  72. { name: 'single', type: 'relation', entity: Asset, graphQLType: 'Asset', list: false },
  73. { name: 'multi', type: 'relation', entity: Asset, graphQLType: 'Asset', list: true },
  74. ];
  75. }
  76. customFieldConfig.Product?.push(
  77. { name: 'cfCollection', type: 'relation', entity: Collection, list: false },
  78. { name: 'cfCountry', type: 'relation', entity: Country, list: false },
  79. { name: 'cfFacetValue', type: 'relation', entity: FacetValue, list: false },
  80. { name: 'cfFacet', type: 'relation', entity: Facet, list: false },
  81. { name: 'cfProductOptionGroup', type: 'relation', entity: ProductOptionGroup, list: false },
  82. { name: 'cfProductOption', type: 'relation', entity: ProductOption, list: false },
  83. { name: 'cfProductVariant', type: 'relation', entity: ProductVariant, list: false },
  84. { name: 'cfProduct', type: 'relation', entity: Product, list: false },
  85. { name: 'cfShippingMethod', type: 'relation', entity: ShippingMethod, list: false },
  86. { name: 'cfInternalAsset', type: 'relation', entity: Asset, list: false, internal: true },
  87. );
  88. customFieldConfig.ProductVariant?.push({
  89. name: 'cfRelatedProducts',
  90. type: 'relation',
  91. entity: Product,
  92. list: true,
  93. internal: false,
  94. public: true,
  95. });
  96. const customConfig = mergeConfig(testConfig(), {
  97. paymentOptions: {
  98. paymentMethodHandlers: [testSuccessfulPaymentMethod],
  99. },
  100. // logger: new DefaultLogger({ level: LogLevel.Debug }),
  101. dbConnectionOptions: {
  102. timezone: 'Z',
  103. },
  104. customFields: customFieldConfig,
  105. plugins: [TestPlugin1636_1664, WithCustomEntity, PluginIssue2453],
  106. });
  107. describe('Custom field relations', () => {
  108. const { server, adminClient, shopClient } = createTestEnvironment(customConfig);
  109. beforeAll(async () => {
  110. await server.init({
  111. initialData,
  112. productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
  113. customerCount: 3,
  114. });
  115. await adminClient.asSuperAdmin();
  116. }, TEST_SETUP_TIMEOUT_MS);
  117. afterAll(async () => {
  118. await server.destroy();
  119. });
  120. it('customFieldConfig query returns entity and scalar fields', async () => {
  121. const { globalSettings } = await adminClient.query(gql`
  122. query {
  123. globalSettings {
  124. serverConfig {
  125. customFieldConfig {
  126. Customer {
  127. ... on RelationCustomFieldConfig {
  128. name
  129. entity
  130. scalarFields
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. `);
  138. const single = globalSettings.serverConfig.customFieldConfig.Customer[1];
  139. expect(single.entity).toBe('Asset');
  140. expect(single.scalarFields).toEqual([
  141. 'id',
  142. 'createdAt',
  143. 'updatedAt',
  144. 'name',
  145. 'type',
  146. 'fileSize',
  147. 'mimeType',
  148. 'width',
  149. 'height',
  150. 'source',
  151. 'preview',
  152. ]);
  153. });
  154. describe('special data resolution', () => {
  155. let productId: string;
  156. const productCustomFieldRelationsSelection = `
  157. id
  158. customFields {
  159. cfCollection {
  160. languageCode
  161. name
  162. }
  163. cfCountry {
  164. languageCode
  165. name
  166. }
  167. cfFacetValue {
  168. languageCode
  169. name
  170. }
  171. cfFacet {
  172. languageCode
  173. name
  174. }
  175. cfProductOptionGroup {
  176. languageCode
  177. name
  178. }
  179. cfProductOption {
  180. languageCode
  181. name
  182. }
  183. cfProductVariant {
  184. languageCode
  185. name
  186. }
  187. cfProduct {
  188. languageCode
  189. name
  190. }
  191. cfShippingMethod {
  192. languageCode
  193. name
  194. }
  195. }`;
  196. function assertTranslatableCustomFieldValues(product: { customFields: any }) {
  197. expect(product.customFields.cfCollection).toEqual({
  198. languageCode: 'en',
  199. name: '__root_collection__',
  200. });
  201. expect(product.customFields.cfCountry).toEqual({ languageCode: 'en', name: 'Australia' });
  202. expect(product.customFields.cfFacetValue).toEqual({
  203. languageCode: 'en',
  204. name: 'electronics',
  205. });
  206. expect(product.customFields.cfFacet).toEqual({ languageCode: 'en', name: 'category' });
  207. expect(product.customFields.cfProductOptionGroup).toEqual({
  208. languageCode: 'en',
  209. name: 'screen size',
  210. });
  211. expect(product.customFields.cfProductOption).toEqual({
  212. languageCode: 'en',
  213. name: '13 inch',
  214. });
  215. expect(product.customFields.cfProductVariant).toEqual({
  216. languageCode: 'en',
  217. name: 'Laptop 13 inch 8GB',
  218. });
  219. expect(product.customFields.cfProduct).toEqual({ languageCode: 'en', name: 'Laptop' });
  220. expect(product.customFields.cfShippingMethod).toEqual({
  221. languageCode: 'en',
  222. name: 'Standard Shipping',
  223. });
  224. }
  225. it('translatable entities get translated', async () => {
  226. const { createProduct } = await adminClient.query(gql`
  227. mutation {
  228. createProduct(
  229. input: {
  230. translations: [
  231. {
  232. languageCode: en
  233. name: "Test product"
  234. description: ""
  235. slug: "test-product"
  236. }
  237. ]
  238. customFields: {
  239. cfCollectionId: "T_1"
  240. cfCountryId: "T_1"
  241. cfFacetValueId: "T_1"
  242. cfFacetId: "T_1"
  243. cfProductOptionGroupId: "T_1"
  244. cfProductOptionId: "T_1"
  245. cfProductVariantId: "T_1"
  246. cfProductId: "T_1"
  247. cfShippingMethodId: "T_1"
  248. }
  249. }
  250. ) { ${productCustomFieldRelationsSelection} }
  251. }
  252. `);
  253. productId = createProduct.id;
  254. assertTranslatableCustomFieldValues(createProduct);
  255. });
  256. it('translatable entities get translated on findOneInChannel', async () => {
  257. const { product } = await adminClient.query(gql`
  258. query {
  259. product(id: "${productId}") { ${productCustomFieldRelationsSelection} }
  260. }
  261. `);
  262. assertTranslatableCustomFieldValues(product);
  263. });
  264. // https://github.com/vendure-ecommerce/vendure/issues/2453
  265. it('translatable eager-loaded relation works (issue 2453)', async () => {
  266. const { collections } = await adminClient.query(gql`
  267. query {
  268. collections(options: { sort: { name: DESC } }) {
  269. totalItems
  270. items {
  271. id
  272. name
  273. customFields {
  274. campaign {
  275. name
  276. languageCode
  277. }
  278. }
  279. }
  280. }
  281. }
  282. `);
  283. expect(collections.totalItems).toBe(3);
  284. expect(collections.items.find((c: any) => c.id === 'T_3')).toEqual({
  285. customFields: {
  286. campaign: {
  287. languageCode: 'en',
  288. name: 'Clearance Up to 70% Off frames',
  289. },
  290. },
  291. id: 'T_3',
  292. name: 'children collection',
  293. });
  294. });
  295. it('ProductVariant prices get resolved', async () => {
  296. const { product } = await adminClient.query(gql`
  297. query {
  298. product(id: "${productId}") {
  299. id
  300. customFields {
  301. cfProductVariant {
  302. price
  303. currencyCode
  304. priceWithTax
  305. }
  306. }
  307. }
  308. }`);
  309. expect(product.customFields.cfProductVariant).toEqual({
  310. price: 129900,
  311. currencyCode: 'USD',
  312. priceWithTax: 155880,
  313. });
  314. });
  315. });
  316. it('ProductVariant without a specified property value returns null', async () => {
  317. const { createProduct } = await adminClient.query(gql`
  318. mutation {
  319. createProduct(
  320. input: {
  321. translations: [
  322. {
  323. languageCode: en
  324. name: "Product with empty custom fields"
  325. description: ""
  326. slug: "product-with-empty-custom-fields"
  327. }
  328. ]
  329. }
  330. ) {
  331. id
  332. }
  333. }
  334. `);
  335. const { product } = await adminClient.query(gql`
  336. query {
  337. product(id: "${createProduct.id}") {
  338. id
  339. customFields {
  340. cfProductVariant{
  341. price
  342. currencyCode
  343. priceWithTax
  344. }
  345. }
  346. }
  347. }`);
  348. expect(product.customFields.cfProductVariant).toEqual(null);
  349. });
  350. describe('entity-specific implementation', () => {
  351. function assertCustomFieldIds(customFields: any, single: string, multi: string[]) {
  352. expect(customFields.single).toEqual({ id: single });
  353. expect(customFields.multi.sort(sortById)).toEqual(multi.map(id => ({ id })));
  354. }
  355. const customFieldsSelection = `
  356. customFields {
  357. primitive
  358. single {
  359. id
  360. }
  361. multi {
  362. id
  363. }
  364. }`;
  365. describe('Address entity', () => {
  366. it('admin createCustomerAddress', async () => {
  367. const { createCustomerAddress } = await adminClient.query(gql`
  368. mutation {
  369. createCustomerAddress(
  370. customerId: "T_1"
  371. input: {
  372. countryCode: "GB"
  373. streetLine1: "Test Street"
  374. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  375. }
  376. ) {
  377. id
  378. ${customFieldsSelection}
  379. }
  380. }
  381. `);
  382. assertCustomFieldIds(createCustomerAddress.customFields, 'T_1', ['T_1', 'T_2']);
  383. });
  384. it('shop createCustomerAddress', async () => {
  385. await shopClient.asUserWithCredentials('hayden.zieme12@hotmail.com', 'test');
  386. const { createCustomerAddress } = await shopClient.query(gql`
  387. mutation {
  388. createCustomerAddress(
  389. input: {
  390. countryCode: "GB"
  391. streetLine1: "Test Street"
  392. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  393. }
  394. ) {
  395. id
  396. ${customFieldsSelection}
  397. }
  398. }
  399. `);
  400. assertCustomFieldIds(createCustomerAddress.customFields, 'T_1', ['T_1', 'T_2']);
  401. });
  402. it('admin updateCustomerAddress', async () => {
  403. const { updateCustomerAddress } = await adminClient.query(gql`
  404. mutation {
  405. updateCustomerAddress(
  406. input: { id: "T_1", customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] } }
  407. ) {
  408. id
  409. ${customFieldsSelection}
  410. }
  411. }
  412. `);
  413. assertCustomFieldIds(updateCustomerAddress.customFields, 'T_2', ['T_3', 'T_4']);
  414. });
  415. it('shop updateCustomerAddress', async () => {
  416. const { updateCustomerAddress } = await shopClient.query(gql`
  417. mutation {
  418. updateCustomerAddress(
  419. input: { id: "T_1", customFields: { singleId: "T_3", multiIds: ["T_4", "T_2"] } }
  420. ) {
  421. id
  422. ${customFieldsSelection}
  423. }
  424. }
  425. `);
  426. assertCustomFieldIds(updateCustomerAddress.customFields, 'T_3', ['T_2', 'T_4']);
  427. });
  428. });
  429. describe('Collection entity', () => {
  430. let collectionId: string;
  431. it('admin createCollection', async () => {
  432. const { createCollection } = await adminClient.query(gql`
  433. mutation {
  434. createCollection(
  435. input: {
  436. translations: [
  437. { languageCode: en, name: "Test", description: "test", slug: "test" }
  438. ]
  439. filters: []
  440. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  441. }
  442. ) {
  443. id
  444. ${customFieldsSelection}
  445. }
  446. }
  447. `);
  448. assertCustomFieldIds(createCollection.customFields, 'T_1', ['T_1', 'T_2']);
  449. collectionId = createCollection.id;
  450. });
  451. it('admin updateCollection', async () => {
  452. const { updateCollection } = await adminClient.query(gql`
  453. mutation {
  454. updateCollection(
  455. input: {
  456. id: "${collectionId}"
  457. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  458. }
  459. ) {
  460. id
  461. ${customFieldsSelection}
  462. }
  463. }
  464. `);
  465. assertCustomFieldIds(updateCollection.customFields, 'T_2', ['T_3', 'T_4']);
  466. });
  467. // https://github.com/vendure-ecommerce/vendure/issues/2840
  468. it('updating custom field relation on Collection does not delete primitive values', async () => {
  469. const { updateCollection } = await adminClient.query(gql`
  470. mutation {
  471. updateCollection(
  472. input: {
  473. id: "${collectionId}"
  474. customFields: { singleId: "T_3" }
  475. }
  476. ) {
  477. id
  478. ${customFieldsSelection}
  479. }
  480. }
  481. `);
  482. expect(updateCollection.customFields.single).toEqual({ id: 'T_3' });
  483. expect(updateCollection.customFields.primitive).toBe('test');
  484. });
  485. });
  486. describe('Customer entity', () => {
  487. let customerId: string;
  488. it('admin createCustomer', async () => {
  489. const { createCustomer } = await adminClient.query(gql`
  490. mutation {
  491. createCustomer(
  492. input: {
  493. emailAddress: "test@test.com"
  494. firstName: "Test"
  495. lastName: "Person"
  496. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  497. }
  498. ) {
  499. ... on Customer {
  500. id
  501. ${customFieldsSelection}
  502. }
  503. }
  504. }
  505. `);
  506. assertCustomFieldIds(createCustomer.customFields, 'T_1', ['T_1', 'T_2']);
  507. customerId = createCustomer.id;
  508. });
  509. it('admin updateCustomer', async () => {
  510. const { updateCustomer } = await adminClient.query(gql`
  511. mutation {
  512. updateCustomer(
  513. input: {
  514. id: "${customerId}"
  515. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  516. }
  517. ) {
  518. ...on Customer {
  519. id
  520. ${customFieldsSelection}
  521. }
  522. }
  523. }
  524. `);
  525. assertCustomFieldIds(updateCustomer.customFields, 'T_2', ['T_3', 'T_4']);
  526. });
  527. it('shop updateCustomer', async () => {
  528. const { updateCustomer } = await shopClient.query(gql`
  529. mutation {
  530. updateCustomer(input: { customFields: { singleId: "T_4", multiIds: ["T_2", "T_4"] } }) {
  531. id
  532. ${customFieldsSelection}
  533. }
  534. }
  535. `);
  536. assertCustomFieldIds(updateCustomer.customFields, 'T_4', ['T_2', 'T_4']);
  537. });
  538. });
  539. describe('Facet entity', () => {
  540. let facetId: string;
  541. it('admin createFacet', async () => {
  542. const { createFacet } = await adminClient.query(gql`
  543. mutation {
  544. createFacet(
  545. input: {
  546. code: "test"
  547. isPrivate: false
  548. translations: [{ languageCode: en, name: "test" }]
  549. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  550. }
  551. ) {
  552. id
  553. ${customFieldsSelection}
  554. }
  555. }
  556. `);
  557. assertCustomFieldIds(createFacet.customFields, 'T_1', ['T_1', 'T_2']);
  558. facetId = createFacet.id;
  559. });
  560. it('admin updateFacet', async () => {
  561. const { updateFacet } = await adminClient.query(gql`
  562. mutation {
  563. updateFacet(
  564. input: {
  565. id: "${facetId}"
  566. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  567. }
  568. ) {
  569. id
  570. ${customFieldsSelection}
  571. }
  572. }
  573. `);
  574. assertCustomFieldIds(updateFacet.customFields, 'T_2', ['T_3', 'T_4']);
  575. });
  576. // https://github.com/vendure-ecommerce/vendure/issues/2840
  577. it('updating custom field relation on Facet does not delete primitive values', async () => {
  578. const { updateFacet } = await adminClient.query(gql`
  579. mutation {
  580. updateFacet(
  581. input: {
  582. id: "${facetId}"
  583. customFields: { singleId: "T_3" }
  584. }
  585. ) {
  586. id
  587. ${customFieldsSelection}
  588. }
  589. }
  590. `);
  591. expect(updateFacet.customFields.single).toEqual({ id: 'T_3' });
  592. expect(updateFacet.customFields.primitive).toBe('test');
  593. });
  594. });
  595. describe('FacetValue entity', () => {
  596. let facetValueId: string;
  597. it('admin createFacetValues', async () => {
  598. const { createFacetValues } = await adminClient.query(gql`
  599. mutation {
  600. createFacetValues(
  601. input: {
  602. code: "test"
  603. facetId: "T_1"
  604. translations: [{ languageCode: en, name: "test" }]
  605. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  606. }
  607. ) {
  608. id
  609. ${customFieldsSelection}
  610. }
  611. }
  612. `);
  613. assertCustomFieldIds(createFacetValues[0].customFields, 'T_1', ['T_1', 'T_2']);
  614. facetValueId = createFacetValues[0].id;
  615. });
  616. it('admin updateFacetValues', async () => {
  617. const { updateFacetValues } = await adminClient.query(gql`
  618. mutation {
  619. updateFacetValues(
  620. input: {
  621. id: "${facetValueId}"
  622. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  623. }
  624. ) {
  625. id
  626. ${customFieldsSelection}
  627. }
  628. }
  629. `);
  630. assertCustomFieldIds(updateFacetValues[0].customFields, 'T_2', ['T_3', 'T_4']);
  631. });
  632. // https://github.com/vendure-ecommerce/vendure/issues/2840
  633. it('updating custom field relation on FacetValue does not delete primitive values', async () => {
  634. const { updateFacetValues } = await adminClient.query(gql`
  635. mutation {
  636. updateFacetValues(
  637. input: {
  638. id: "${facetValueId}"
  639. customFields: { singleId: "T_3" }
  640. }
  641. ) {
  642. id
  643. ${customFieldsSelection}
  644. }
  645. }
  646. `);
  647. expect(updateFacetValues[0].customFields.single).toEqual({ id: 'T_3' });
  648. expect(updateFacetValues[0].customFields.primitive).toBe('test');
  649. });
  650. });
  651. describe('GlobalSettings entity', () => {
  652. it('admin updateGlobalSettings', async () => {
  653. const { updateGlobalSettings } = await adminClient.query(gql`
  654. mutation {
  655. updateGlobalSettings(
  656. input: {
  657. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  658. }
  659. ) {
  660. ... on GlobalSettings {
  661. id
  662. ${customFieldsSelection}
  663. }
  664. }
  665. }
  666. `);
  667. assertCustomFieldIds(updateGlobalSettings.customFields, 'T_2', ['T_3', 'T_4']);
  668. });
  669. });
  670. describe('Order entity', () => {
  671. let orderId: string;
  672. beforeAll(async () => {
  673. const { addItemToOrder } = await shopClient.query<any, AddItemToOrderMutationVariables>(
  674. ADD_ITEM_TO_ORDER,
  675. {
  676. productVariantId: 'T_1',
  677. quantity: 1,
  678. },
  679. );
  680. orderId = addItemToOrder.id;
  681. });
  682. it('shop setOrderCustomFields', async () => {
  683. const { setOrderCustomFields } = await shopClient.query(gql`
  684. mutation {
  685. setOrderCustomFields(
  686. input: {
  687. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  688. }
  689. ) {
  690. ... on Order {
  691. id
  692. ${customFieldsSelection}
  693. }
  694. }
  695. }
  696. `);
  697. assertCustomFieldIds(setOrderCustomFields.customFields, 'T_2', ['T_3', 'T_4']);
  698. });
  699. it('admin setOrderCustomFields', async () => {
  700. const { setOrderCustomFields } = await adminClient.query(gql`
  701. mutation {
  702. setOrderCustomFields(
  703. input: {
  704. id: "${orderId}"
  705. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  706. }
  707. ) {
  708. ... on Order {
  709. id
  710. ${customFieldsSelection}
  711. }
  712. }
  713. }
  714. `);
  715. assertCustomFieldIds(setOrderCustomFields.customFields, 'T_1', ['T_1', 'T_2']);
  716. });
  717. // https://github.com/vendure-ecommerce/vendure/issues/1664#issuecomment-1320872627
  718. it('admin order query with eager-loaded custom field relation', async () => {
  719. const { order } = await adminClient.query(gql`
  720. query {
  721. order(id: 1) {
  722. id
  723. customFields {
  724. productOwner {
  725. id
  726. }
  727. }
  728. }
  729. }
  730. `);
  731. // we're just making sure it does not throw here.
  732. expect(order).toEqual({
  733. customFields: {
  734. productOwner: null,
  735. },
  736. id: 'T_1',
  737. });
  738. });
  739. });
  740. describe('OrderLine entity', () => {
  741. it('shop addItemToOrder', async () => {
  742. const { addItemToOrder } = await shopClient.query(
  743. gql`mutation {
  744. addItemToOrder(productVariantId: "T_1", quantity: 1, customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }) {
  745. ... on Order {
  746. id
  747. ${customFieldsSelection}
  748. }
  749. }
  750. }`,
  751. );
  752. assertCustomFieldIds(addItemToOrder.customFields, 'T_1', ['T_1', 'T_2']);
  753. });
  754. });
  755. describe('Product, ProductVariant entity', () => {
  756. let productId: string;
  757. it('admin createProduct', async () => {
  758. const { createProduct } = await adminClient.query(gql`
  759. mutation {
  760. createProduct(
  761. input: {
  762. translations: [{ languageCode: en, name: "test" slug: "test" description: "test" }]
  763. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  764. }
  765. ) {
  766. id
  767. ${customFieldsSelection}
  768. }
  769. }
  770. `);
  771. assertCustomFieldIds(createProduct.customFields, 'T_1', ['T_1', 'T_2']);
  772. productId = createProduct.id;
  773. });
  774. it('admin updateProduct', async () => {
  775. const { updateProduct } = await adminClient.query(gql`
  776. mutation {
  777. updateProduct(
  778. input: {
  779. id: "${productId}"
  780. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  781. }
  782. ) {
  783. id
  784. ${customFieldsSelection}
  785. }
  786. }
  787. `);
  788. assertCustomFieldIds(updateProduct.customFields, 'T_2', ['T_3', 'T_4']);
  789. });
  790. // https://github.com/vendure-ecommerce/vendure/issues/2840
  791. it('updating custom field relation on Product does not delete primitive values', async () => {
  792. const { updateProduct } = await adminClient.query(gql`
  793. mutation {
  794. updateProduct(
  795. input: {
  796. id: "${productId}"
  797. customFields: { singleId: "T_3" }
  798. }
  799. ) {
  800. id
  801. ${customFieldsSelection}
  802. }
  803. }
  804. `);
  805. expect(updateProduct.customFields.single).toEqual({ id: 'T_3' });
  806. expect(updateProduct.customFields.primitive).toBe('test');
  807. });
  808. let productVariantId: string;
  809. it('admin createProductVariant', async () => {
  810. const { createProductVariants } = await adminClient.query(gql`
  811. mutation {
  812. createProductVariants(
  813. input: [{
  814. sku: "TEST01"
  815. productId: "${productId}"
  816. translations: [{ languageCode: en, name: "test" }]
  817. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  818. }]
  819. ) {
  820. id
  821. ${customFieldsSelection}
  822. }
  823. }
  824. `);
  825. assertCustomFieldIds(createProductVariants[0].customFields, 'T_1', ['T_1', 'T_2']);
  826. productVariantId = createProductVariants[0].id;
  827. });
  828. it('admin updateProductVariant', async () => {
  829. const { updateProductVariants } = await adminClient.query(gql`
  830. mutation {
  831. updateProductVariants(
  832. input: [{
  833. id: "${productVariantId}"
  834. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  835. }]
  836. ) {
  837. id
  838. ${customFieldsSelection}
  839. }
  840. }
  841. `);
  842. assertCustomFieldIds(updateProductVariants[0].customFields, 'T_2', ['T_3', 'T_4']);
  843. });
  844. // https://github.com/vendure-ecommerce/vendure/issues/2840
  845. it('updating custom field relation on ProductVariant does not delete primitive values', async () => {
  846. const { updateProductVariants } = await adminClient.query(gql`
  847. mutation {
  848. updateProductVariants(
  849. input: [{
  850. id: "${productVariantId}"
  851. customFields: { singleId: "T_3" }
  852. }]
  853. ) {
  854. id
  855. ${customFieldsSelection}
  856. }
  857. }
  858. `);
  859. expect(updateProductVariants[0].customFields.single).toEqual({ id: 'T_3' });
  860. expect(updateProductVariants[0].customFields.primitive).toBe('test');
  861. });
  862. describe('issue 1664', () => {
  863. // https://github.com/vendure-ecommerce/vendure/issues/1664
  864. it('successfully gets product by id with eager-loading custom field relation', async () => {
  865. const { product } = await shopClient.query(gql`
  866. query {
  867. product(id: "T_1") {
  868. id
  869. customFields {
  870. cfVendor {
  871. featuredProduct {
  872. id
  873. }
  874. }
  875. }
  876. }
  877. }
  878. `);
  879. expect(product).toBeDefined();
  880. });
  881. // https://github.com/vendure-ecommerce/vendure/issues/1664
  882. it('successfully gets product by id with nested eager-loading custom field relation', async () => {
  883. const { customer } = await adminClient.query(gql`
  884. query {
  885. customer(id: "T_1") {
  886. id
  887. firstName
  888. lastName
  889. emailAddress
  890. phoneNumber
  891. user {
  892. customFields {
  893. cfVendor {
  894. id
  895. }
  896. }
  897. }
  898. }
  899. }
  900. `);
  901. expect(customer).toBeDefined();
  902. });
  903. // https://github.com/vendure-ecommerce/vendure/issues/1664
  904. it('successfully gets product.variants with nested custom field relation', async () => {
  905. await adminClient.query(gql`
  906. mutation {
  907. updateProductVariants(
  908. input: [{ id: "T_1", customFields: { cfRelatedProductsIds: ["T_2"] } }]
  909. ) {
  910. id
  911. }
  912. }
  913. `);
  914. const { product } = await adminClient.query(gql`
  915. query {
  916. product(id: "T_1") {
  917. variants {
  918. id
  919. customFields {
  920. cfRelatedProducts {
  921. featuredAsset {
  922. id
  923. }
  924. }
  925. }
  926. }
  927. }
  928. }
  929. `);
  930. expect(product).toBeDefined();
  931. expect(product.variants[0].customFields.cfRelatedProducts).toEqual([
  932. {
  933. featuredAsset: { id: 'T_2' },
  934. },
  935. ]);
  936. });
  937. it('successfully gets product by slug with eager-loading custom field relation', async () => {
  938. const { product } = await shopClient.query(gql`
  939. query {
  940. product(slug: "laptop") {
  941. id
  942. customFields {
  943. cfVendor {
  944. featuredProduct {
  945. id
  946. }
  947. }
  948. }
  949. }
  950. }
  951. `);
  952. expect(product).toBeDefined();
  953. });
  954. it('does not error on custom field relation with eager custom field relation', async () => {
  955. const { product } = await adminClient.query(gql`
  956. query {
  957. product(slug: "laptop") {
  958. name
  959. customFields {
  960. owner {
  961. id
  962. code
  963. customFields {
  964. profile {
  965. id
  966. name
  967. }
  968. }
  969. }
  970. }
  971. }
  972. }
  973. `);
  974. expect(product).toBeDefined();
  975. });
  976. });
  977. });
  978. describe('ProductOptionGroup, ProductOption entity', () => {
  979. let productOptionGroupId: string;
  980. it('admin createProductOptionGroup', async () => {
  981. const { createProductOptionGroup } = await adminClient.query(gql`
  982. mutation {
  983. createProductOptionGroup(
  984. input: {
  985. code: "test"
  986. options: []
  987. translations: [{ languageCode: en, name: "test" }]
  988. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  989. }
  990. ) {
  991. id
  992. ${customFieldsSelection}
  993. }
  994. }
  995. `);
  996. assertCustomFieldIds(createProductOptionGroup.customFields, 'T_1', ['T_1', 'T_2']);
  997. productOptionGroupId = createProductOptionGroup.id;
  998. });
  999. it('admin updateProductOptionGroup', async () => {
  1000. const { updateProductOptionGroup } = await adminClient.query(gql`
  1001. mutation {
  1002. updateProductOptionGroup(
  1003. input: {
  1004. id: "${productOptionGroupId}"
  1005. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  1006. }
  1007. ) {
  1008. id
  1009. ${customFieldsSelection}
  1010. }
  1011. }
  1012. `);
  1013. assertCustomFieldIds(updateProductOptionGroup.customFields, 'T_2', ['T_3', 'T_4']);
  1014. });
  1015. // https://github.com/vendure-ecommerce/vendure/issues/2840
  1016. it('updating custom field relation on ProductOptionGroup does not delete primitive values', async () => {
  1017. const { updateProductOptionGroup } = await adminClient.query(gql`
  1018. mutation {
  1019. updateProductOptionGroup(
  1020. input: {
  1021. id: "${productOptionGroupId}"
  1022. customFields: { singleId: "T_3" }
  1023. }
  1024. ) {
  1025. id
  1026. ${customFieldsSelection}
  1027. }
  1028. }
  1029. `);
  1030. expect(updateProductOptionGroup.customFields.single).toEqual({ id: 'T_3' });
  1031. expect(updateProductOptionGroup.customFields.primitive).toBe('test');
  1032. });
  1033. let productOptionId: string;
  1034. it('admin createProductOption', async () => {
  1035. const { createProductOption } = await adminClient.query(gql`
  1036. mutation {
  1037. createProductOption(
  1038. input: {
  1039. productOptionGroupId: "${productOptionGroupId}"
  1040. code: "test-option"
  1041. translations: [{ languageCode: en, name: "test-option" }]
  1042. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  1043. }
  1044. ) {
  1045. id
  1046. ${customFieldsSelection}
  1047. }
  1048. }
  1049. `);
  1050. assertCustomFieldIds(createProductOption.customFields, 'T_1', ['T_1', 'T_2']);
  1051. productOptionId = createProductOption.id;
  1052. });
  1053. it('admin updateProductOption', async () => {
  1054. const { updateProductOption } = await adminClient.query(gql`
  1055. mutation {
  1056. updateProductOption(
  1057. input: {
  1058. id: "${productOptionId}"
  1059. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  1060. }
  1061. ) {
  1062. id
  1063. ${customFieldsSelection}
  1064. }
  1065. }
  1066. `);
  1067. assertCustomFieldIds(updateProductOption.customFields, 'T_2', ['T_3', 'T_4']);
  1068. });
  1069. // https://github.com/vendure-ecommerce/vendure/issues/2840
  1070. it('updating custom field relation on ProductOption does not delete primitive values', async () => {
  1071. const { updateProductOption } = await adminClient.query(gql`
  1072. mutation {
  1073. updateProductOption(
  1074. input: {
  1075. id: "${productOptionId}"
  1076. customFields: { singleId: "T_3" }
  1077. }
  1078. ) {
  1079. id
  1080. ${customFieldsSelection}
  1081. }
  1082. }
  1083. `);
  1084. expect(updateProductOption.customFields.single).toEqual({ id: 'T_3' });
  1085. expect(updateProductOption.customFields.primitive).toBe('test');
  1086. });
  1087. });
  1088. describe('ShippingMethod entity', () => {
  1089. let shippingMethodId: string;
  1090. it('admin createShippingMethod', async () => {
  1091. const { createShippingMethod } = await adminClient.query(gql`
  1092. mutation {
  1093. createShippingMethod(
  1094. input: {
  1095. code: "test"
  1096. calculator: {
  1097. code: "${defaultShippingCalculator.code}"
  1098. arguments: [
  1099. { name: "rate" value: "10"},
  1100. { name: "includesTax" value: "true"},
  1101. { name: "taxRate" value: "10"},
  1102. ]
  1103. }
  1104. checker: {
  1105. code: "${defaultShippingEligibilityChecker.code}"
  1106. arguments: [
  1107. { name: "orderMinimum" value: "0"},
  1108. ]
  1109. }
  1110. fulfillmentHandler: "${manualFulfillmentHandler.code}"
  1111. translations: [{ languageCode: en, name: "test" description: "test" }]
  1112. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
  1113. }
  1114. ) {
  1115. id
  1116. ${customFieldsSelection}
  1117. }
  1118. }
  1119. `);
  1120. assertCustomFieldIds(createShippingMethod.customFields, 'T_1', ['T_1', 'T_2']);
  1121. shippingMethodId = createShippingMethod.id;
  1122. });
  1123. it('admin updateShippingMethod', async () => {
  1124. const { updateShippingMethod } = await adminClient.query(gql`
  1125. mutation {
  1126. updateShippingMethod(
  1127. input: {
  1128. id: "${shippingMethodId}"
  1129. translations: []
  1130. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  1131. }
  1132. ) {
  1133. id
  1134. ${customFieldsSelection}
  1135. }
  1136. }
  1137. `);
  1138. assertCustomFieldIds(updateShippingMethod.customFields, 'T_2', ['T_3', 'T_4']);
  1139. });
  1140. // https://github.com/vendure-ecommerce/vendure/issues/2840
  1141. it('updating custom field relation on ShippingMethod does not delete primitive values', async () => {
  1142. const { updateShippingMethod } = await adminClient.query(gql`
  1143. mutation {
  1144. updateShippingMethod(
  1145. input: {
  1146. id: "${shippingMethodId}"
  1147. translations: []
  1148. customFields: { singleId: "T_3" }
  1149. }
  1150. ) {
  1151. id
  1152. ${customFieldsSelection}
  1153. }
  1154. }
  1155. `);
  1156. expect(updateShippingMethod.customFields.single).toEqual({ id: 'T_3' });
  1157. expect(updateShippingMethod.customFields.primitive).toBe('test');
  1158. });
  1159. it('shop eligibleShippingMethods (ShippingMethodQuote)', async () => {
  1160. const { eligibleShippingMethods } = await shopClient.query(gql`
  1161. query {
  1162. eligibleShippingMethods {
  1163. id
  1164. name
  1165. code
  1166. description
  1167. ${customFieldsSelection}
  1168. }
  1169. }
  1170. `);
  1171. const testShippingMethodQuote = eligibleShippingMethods.find(
  1172. (quote: any) => quote.code === 'test',
  1173. );
  1174. assertCustomFieldIds(testShippingMethodQuote.customFields, 'T_3', ['T_3', 'T_4']);
  1175. });
  1176. });
  1177. describe('PaymentMethod entity', () => {
  1178. let paymentMethodId: string;
  1179. it('admin createShippingMethod', async () => {
  1180. const { createPaymentMethod } = await adminClient.query(gql`
  1181. mutation {
  1182. createPaymentMethod(
  1183. input: {
  1184. code: "test"
  1185. enabled: true
  1186. handler: {
  1187. code: "${testSuccessfulPaymentMethod.code}"
  1188. arguments: []
  1189. }
  1190. customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] },
  1191. translations: [{ languageCode: en, name: "test" }]
  1192. }
  1193. ) {
  1194. id
  1195. ${customFieldsSelection}
  1196. }
  1197. }
  1198. `);
  1199. assertCustomFieldIds(createPaymentMethod.customFields, 'T_1', ['T_1', 'T_2']);
  1200. paymentMethodId = createPaymentMethod.id;
  1201. });
  1202. it('admin updatePaymentMethod', async () => {
  1203. const { updatePaymentMethod } = await adminClient.query(gql`
  1204. mutation {
  1205. updatePaymentMethod(
  1206. input: {
  1207. id: "${paymentMethodId}"
  1208. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] },
  1209. }
  1210. ) {
  1211. id
  1212. ${customFieldsSelection}
  1213. }
  1214. }
  1215. `);
  1216. assertCustomFieldIds(updatePaymentMethod.customFields, 'T_2', ['T_3', 'T_4']);
  1217. });
  1218. // https://github.com/vendure-ecommerce/vendure/issues/2840
  1219. it('updating custom field relation on PaymentMethod does not delete primitive values', async () => {
  1220. const { updatePaymentMethod } = await adminClient.query(gql`
  1221. mutation {
  1222. updatePaymentMethod(
  1223. input: {
  1224. id: "${paymentMethodId}"
  1225. customFields: { singleId: "T_3" }
  1226. }
  1227. ) {
  1228. id
  1229. ${customFieldsSelection}
  1230. }
  1231. }
  1232. `);
  1233. expect(updatePaymentMethod.customFields.single).toEqual({ id: 'T_3' });
  1234. expect(updatePaymentMethod.customFields.primitive).toBe('test');
  1235. });
  1236. it('shop eligiblePaymentMethods (PaymentMethodQuote)', async () => {
  1237. const { eligiblePaymentMethods } = await shopClient.query(gql`
  1238. query {
  1239. eligiblePaymentMethods {
  1240. id
  1241. name
  1242. description
  1243. ${customFieldsSelection}
  1244. }
  1245. }
  1246. `);
  1247. assertCustomFieldIds(eligiblePaymentMethods[0].customFields, 'T_3', ['T_3', 'T_4']);
  1248. });
  1249. });
  1250. describe('Asset entity', () => {
  1251. it('set custom field relations on Asset', async () => {
  1252. const { updateAsset } = await adminClient.query(gql`
  1253. mutation {
  1254. updateAsset(
  1255. input: {
  1256. id: "T_1",
  1257. customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
  1258. }
  1259. ) {
  1260. id
  1261. ${customFieldsSelection}
  1262. }
  1263. }
  1264. `);
  1265. assertCustomFieldIds(updateAsset.customFields, 'T_2', ['T_3', 'T_4']);
  1266. });
  1267. it('findOne on Asset', async () => {
  1268. const { asset } = await adminClient.query(gql`
  1269. query {
  1270. asset(id: "T_1") {
  1271. id
  1272. ${customFieldsSelection}
  1273. }
  1274. }
  1275. `);
  1276. expect(asset.customFields.single.id).toBe('T_2');
  1277. expect(asset.customFields.multi.length).toEqual(2);
  1278. });
  1279. // https://github.com/vendure-ecommerce/vendure/issues/1636
  1280. it('calling TransactionalConnection.findOneInChannel() returns custom field relations', async () => {
  1281. TestPlugin1636_1664.testResolverSpy.mockReset();
  1282. await shopClient.query(gql`
  1283. query {
  1284. getAssetTest(id: "T_1")
  1285. }
  1286. `);
  1287. const args = TestPlugin1636_1664.testResolverSpy.mock.calls[0];
  1288. expect(args[0].customFields.single.id).toEqual(2);
  1289. expect(args[0].customFields.multi.length).toEqual(2);
  1290. });
  1291. });
  1292. });
  1293. it('null values', async () => {
  1294. const { updateCustomerAddress } = await adminClient.query(gql`
  1295. mutation {
  1296. updateCustomerAddress(
  1297. input: { id: "T_1", customFields: { singleId: null, multiIds: ["T_1", "null"] } }
  1298. ) {
  1299. id
  1300. customFields {
  1301. single {
  1302. id
  1303. }
  1304. multi {
  1305. id
  1306. }
  1307. }
  1308. }
  1309. }
  1310. `);
  1311. expect(updateCustomerAddress.customFields.single).toEqual(null);
  1312. expect(updateCustomerAddress.customFields.multi).toEqual([{ id: 'T_1' }]);
  1313. });
  1314. describe('bi-direction relations', () => {
  1315. let customEntityRepository: Repository<TestCustomEntity>;
  1316. let customEntity: TestCustomEntity;
  1317. let collectionIdInternal: number;
  1318. beforeAll(async () => {
  1319. customEntityRepository = server.app
  1320. .get(TransactionalConnection)
  1321. .getRepository(RequestContext.empty(), TestCustomEntity);
  1322. const customEntityId = (await customEntityRepository.save({})).id;
  1323. const { createCollection } = await adminClient.query(gql`
  1324. mutation {
  1325. createCollection(
  1326. input: {
  1327. translations: [
  1328. { languageCode: en, name: "Test", description: "test", slug: "test" }
  1329. ]
  1330. filters: []
  1331. customFields: { customEntityListIds: [${customEntityId}] customEntityId: ${customEntityId} }
  1332. }
  1333. ) {
  1334. id
  1335. }
  1336. }
  1337. `);
  1338. collectionIdInternal = parseInt(createCollection.id.replace('T_', ''), 10);
  1339. customEntity = await assertFound(
  1340. customEntityRepository.findOne({
  1341. where: { id: customEntityId },
  1342. relations: {
  1343. customEntityInverse: true,
  1344. customEntityListInverse: true,
  1345. },
  1346. }),
  1347. );
  1348. });
  1349. it('can create inverse relation for list=false', () => {
  1350. expect(customEntity.customEntityInverse).toEqual([
  1351. expect.objectContaining({ id: collectionIdInternal }),
  1352. ]);
  1353. });
  1354. it('can create inverse relation for list=true', () => {
  1355. expect(customEntity.customEntityListInverse).toEqual([
  1356. expect.objectContaining({ id: collectionIdInternal }),
  1357. ]);
  1358. });
  1359. });
  1360. });