ソースを参照

test(core): Improve typings of e2e test

Michael Bromley 2 年 前
コミット
990de00adf

+ 4 - 1
packages/core/e2e/custom-field-relations.e2e-spec.ts

@@ -1255,7 +1255,10 @@ describe('Custom field relations', () => {
             customEntity = await assertFound(
                 customEntityRepository.findOne({
                     where: { id: customEntityId },
-                    relations: ['customEntityListInverse', 'customEntityInverse'],
+                    relations: {
+                        customEntityInverse: true,
+                        customEntityListInverse: true,
+                    },
                 }),
             );
         });

+ 9 - 2
packages/core/e2e/fixtures/test-plugins/with-custom-entity.ts

@@ -2,18 +2,25 @@ import { Collection, PluginCommonModule, VendureEntity, VendurePlugin } from '@v
 import gql from 'graphql-tag';
 import { DeepPartial, Entity, ManyToMany, OneToMany } from 'typeorm';
 
+declare module '@vendure/core/dist/entity/custom-entity-fields' {
+    interface CustomCollectionFields {
+        customEntity: TestCustomEntity;
+        customEntityList: TestCustomEntity[];
+    }
+}
+
 @Entity()
 export class TestCustomEntity extends VendureEntity {
     constructor(input?: DeepPartial<TestCustomEntity>) {
         super(input);
     }
 
-    @ManyToMany(() => Collection, x => (x as any).customFields?.customEntityList, {
+    @ManyToMany(() => Collection, c => c.customFields?.customEntityList, {
         eager: true,
     })
     customEntityListInverse: Collection[];
 
-    @OneToMany(() => Collection, (a: Collection) => (a.customFields as any).customEntity)
+    @OneToMany(() => Collection, c => c.customFields.customEntity)
     customEntityInverse: Collection[];
 }