Просмотр исходного кода

refs #124935: Fix quistionnaire answer
- Fix and add tests for questionnaire.

Tatsuya Ise 2 лет назад
Родитель
Сommit
6346465e02
1 измененных файлов с 23 добавлено и 1 удалено
  1. 23 1
      apps/app/test/integration/service/questionnaire.test.ts

+ 23 - 1
apps/app/test/integration/service/questionnaire.test.ts

@@ -30,6 +30,11 @@ describe('QuestionnaireService', () => {
     });
   });
 
+  afterAll(async() => {
+    delete process.env.FORCE_WIKI_MODE;
+    await crowi.setupConfigManager();
+  });
+
   describe('getGrowiInfo', () => {
     test('Should get correct GROWI info', async() => {
       const growiInfo = await crowi.questionnaireService.getGrowiInfo();
@@ -53,7 +58,7 @@ describe('QuestionnaireService', () => {
         deploymentType: 'growi-docker-compose',
         type: 'on-premise',
         version: crowi.version,
-        wikiType: 'open',
+        wikiType: 'closed',
       });
     });
 
@@ -70,6 +75,23 @@ describe('QuestionnaireService', () => {
         expect(growiInfo.appSiteUrlHashed).toBeTruthy();
       });
     });
+
+    test('WikiType is "open" when env value FORCE_WIKI_MODE is "public"', async() => {
+      process.env.FORCE_WIKI_MODE = 'public';
+      await crowi.setupConfigManager();
+
+      const growiInfo = await crowi.questionnaireService.getGrowiInfo();
+      expect(growiInfo.wikiType).toEqual('open');
+    });
+
+    test('WikiType is "close" when env value FORCE_WIKI_MODE is "private"', async() => {
+      process.env.FORCE_WIKI_MODE = 'private';
+      await crowi.setupConfigManager();
+
+      const growiInfo = await crowi.questionnaireService.getGrowiInfo();
+      expect(growiInfo.wikiType).toEqual('closed');
+    });
+
   });
 
   describe('getUserInfo', () => {