Browse Source

fix(core): Fix CollectionBreadcrumb.name error

Occurred when first requesting collection breadcrumbs after bootstrap. Root collection was correctly assigned to cache, but the un-translated version was being returned.

Fixes #97
Michael Bromley 6 years ago
parent
commit
5b6f93a756

+ 8 - 0
packages/core/e2e/collection.e2e-spec.ts

@@ -69,6 +69,14 @@ describe('Collection resolver', () => {
         await server.destroy();
     });
 
+    /**
+     * Test case for https://github.com/vendure-ecommerce/vendure/issues/97
+     */
+    it('collection breadcrumbs works after bootstrap', async () => {
+        const result = await client.query<GetCollectionBreadcrumbs.Query>(GET_COLLECTION_BREADCRUMBS, { id: 'T_1' });
+        expect(result.collection!.breadcrumbs[0].name).toBe(ROOT_COLLECTION_NAME);
+    });
+
     describe('createCollection', () => {
         it('creates a root collection', async () => {
             const result = await client.query<CreateCollection.Mutation, CreateCollection.Variables>(

+ 1 - 1
packages/core/src/service/services/collection.service.ts

@@ -464,7 +464,7 @@ export class CollectionService implements OnModuleInit {
 
         if (existingRoot) {
             this.rootCategories[ctx.channel.code] = translateDeep(existingRoot, ctx.languageCode);
-            return existingRoot;
+            return this.rootCategories[ctx.channel.code];
         }
 
         const rootTranslation = await this.connection.getRepository(CollectionTranslation).save(