Преглед изворни кода

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

Tatsuya Ise пре 2 година
родитељ
комит
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', () => {
   describe('getGrowiInfo', () => {
     test('Should get correct GROWI info', async() => {
     test('Should get correct GROWI info', async() => {
       const growiInfo = await crowi.questionnaireService.getGrowiInfo();
       const growiInfo = await crowi.questionnaireService.getGrowiInfo();
@@ -53,7 +58,7 @@ describe('QuestionnaireService', () => {
         deploymentType: 'growi-docker-compose',
         deploymentType: 'growi-docker-compose',
         type: 'on-premise',
         type: 'on-premise',
         version: crowi.version,
         version: crowi.version,
-        wikiType: 'open',
+        wikiType: 'closed',
       });
       });
     });
     });
 
 
@@ -70,6 +75,23 @@ describe('QuestionnaireService', () => {
         expect(growiInfo.appSiteUrlHashed).toBeTruthy();
         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', () => {
   describe('getUserInfo', () => {