Yuki Takei 2 лет назад
Родитель
Сommit
cccdf6d205

+ 2 - 3
apps/app/src/features/growi-plugin/server/models/growi-plugin.ts

@@ -46,9 +46,8 @@ const growiPluginSchema = new Schema<IGrowiPluginDocument, IGrowiPluginModel>({
   meta: growiPluginMetaSchema,
 });
 
-
 growiPluginSchema.statics.findEnabledPlugins = async function(): Promise<IGrowiPlugin[]> {
-  return this.find({ isEnabled: true });
+  return this.find({ isEnabled: true }).lean();
 };
 
 growiPluginSchema.statics.findEnabledPluginsByType = async function<T extends GrowiPluginType>(
@@ -57,7 +56,7 @@ growiPluginSchema.statics.findEnabledPluginsByType = async function<T extends Gr
   return this.find({
     isEnabled: true,
     'meta.types': { $in: type },
-  });
+  }).lean();
 };
 
 growiPluginSchema.statics.activatePlugin = async function(id: Types.ObjectId): Promise<string> {

+ 7 - 5
apps/app/src/features/growi-plugin/server/services/growi-plugin/growi-plugin.integ.ts

@@ -82,11 +82,13 @@ describe('Installing a GROWI theme plugin', () => {
     const results = await growiPluginService.findThemePlugin('welcome-to-fumiya-room');
 
     // expect
-    // expect(results).not.toBeNull();
-    // assert(results != null);
-    // expect(results.growiPlugin).not.toBeNull();
-    // expect(results.themeMetadata).not.toBeNull();
-    // expect(results.themeHref).not.toBeNull();
+    expect(results).not.toBeNull();
+    assert(results != null);
+    expect(results.growiPlugin).not.toBeNull();
+    expect(results.themeMetadata).not.toBeNull();
+    expect(results.themeHref).not.toBeNull();
+    expect(results.themeHref
+      .startsWith('/static/plugins/weseek/growi-plugin-theme-welcome-to-fumiya-room/dist/assets/style.')).toBeTruthy();
   });
 
 });

+ 1 - 1
apps/app/src/features/growi-plugin/server/services/growi-plugin/growi-plugin.ts

@@ -325,7 +325,7 @@ export class GrowiPluginService implements IGrowiPluginService {
       const growiPlugins = await GrowiPlugin.findEnabledPluginsByType(GrowiPluginType.Theme);
 
       growiPlugins
-        .forEach(async(growiPlugin) => {
+        .forEach((growiPlugin) => {
           const themeMetadatas = growiPlugin.meta.themes;
           const themeMetadata = themeMetadatas.find(t => t.name === theme);