|
@@ -1,7 +1,10 @@
|
|
|
import { GrowiDeploymentType, GrowiServiceType } from '@growi/core/dist/consts';
|
|
import { GrowiDeploymentType, GrowiServiceType } from '@growi/core/dist/consts';
|
|
|
import type { IGrowiInfo } from '@growi/core/dist/interfaces';
|
|
import type { IGrowiInfo } from '@growi/core/dist/interfaces';
|
|
|
import { GrowiWikiType } from '@growi/core/dist/interfaces';
|
|
import { GrowiWikiType } from '@growi/core/dist/interfaces';
|
|
|
-import { describe, test, expect } from 'vitest';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ describe, test, expect,
|
|
|
|
|
+} from 'vitest';
|
|
|
|
|
+import { mock } from 'vitest-mock-extended';
|
|
|
|
|
|
|
|
import { AttachmentMethodType } from '../../../../interfaces/attachment';
|
|
import { AttachmentMethodType } from '../../../../interfaces/attachment';
|
|
|
import type { IGrowiAppAdditionalInfo, IGrowiAppInfoLegacy } from '../../interfaces/growi-app-info';
|
|
import type { IGrowiAppAdditionalInfo, IGrowiAppInfoLegacy } from '../../interfaces/growi-app-info';
|
|
@@ -13,10 +16,17 @@ describe('convertToLegacyFormat', () => {
|
|
|
const growiInfoLegacy: IGrowiAppInfoLegacy = {
|
|
const growiInfoLegacy: IGrowiAppInfoLegacy = {
|
|
|
version: '1.0.0',
|
|
version: '1.0.0',
|
|
|
appSiteUrl: 'https://example.com',
|
|
appSiteUrl: 'https://example.com',
|
|
|
- appSiteUrlHashed: 'hashedUrl',
|
|
|
|
|
|
|
+ appSiteUrlHashed: '100680ad546ce6a577f42f52df33b4cfdca756859e664b8d7de329b150d09ce9',
|
|
|
|
|
+ serviceInstanceId: 'service-instance-id',
|
|
|
type: GrowiServiceType.cloud,
|
|
type: GrowiServiceType.cloud,
|
|
|
wikiType: GrowiWikiType.open,
|
|
wikiType: GrowiWikiType.open,
|
|
|
deploymentType: GrowiDeploymentType.others,
|
|
deploymentType: GrowiDeploymentType.others,
|
|
|
|
|
+ osInfo: {
|
|
|
|
|
+ type: 'Linux',
|
|
|
|
|
+ platform: 'linux',
|
|
|
|
|
+ arch: 'x64',
|
|
|
|
|
+ totalmem: 8589934592,
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
// legacy properties
|
|
// legacy properties
|
|
|
installedAt: new Date(),
|
|
installedAt: new Date(),
|
|
@@ -39,11 +49,16 @@ describe('convertToLegacyFormat', () => {
|
|
|
const growiInfo: IGrowiInfo<IGrowiAppAdditionalInfo> = {
|
|
const growiInfo: IGrowiInfo<IGrowiAppAdditionalInfo> = {
|
|
|
version: '1.0.0',
|
|
version: '1.0.0',
|
|
|
appSiteUrl: 'https://example.com',
|
|
appSiteUrl: 'https://example.com',
|
|
|
- appSiteUrlHashed: 'hashedUrl',
|
|
|
|
|
|
|
+ serviceInstanceId: 'service-instance-id',
|
|
|
type: GrowiServiceType.cloud,
|
|
type: GrowiServiceType.cloud,
|
|
|
wikiType: GrowiWikiType.open,
|
|
wikiType: GrowiWikiType.open,
|
|
|
deploymentType: GrowiDeploymentType.others,
|
|
deploymentType: GrowiDeploymentType.others,
|
|
|
-
|
|
|
|
|
|
|
+ osInfo: {
|
|
|
|
|
+ type: 'Linux',
|
|
|
|
|
+ platform: 'linux',
|
|
|
|
|
+ arch: 'x64',
|
|
|
|
|
+ totalmem: 8589934592,
|
|
|
|
|
+ },
|
|
|
additionalInfo: {
|
|
additionalInfo: {
|
|
|
installedAt: new Date(),
|
|
installedAt: new Date(),
|
|
|
installedAtByOldestUser: new Date(),
|
|
installedAtByOldestUser: new Date(),
|
|
@@ -60,10 +75,17 @@ describe('convertToLegacyFormat', () => {
|
|
|
const growiInfoLegacy: IGrowiAppInfoLegacy = {
|
|
const growiInfoLegacy: IGrowiAppInfoLegacy = {
|
|
|
version: '1.0.0',
|
|
version: '1.0.0',
|
|
|
appSiteUrl: 'https://example.com',
|
|
appSiteUrl: 'https://example.com',
|
|
|
- appSiteUrlHashed: 'hashedUrl',
|
|
|
|
|
|
|
+ appSiteUrlHashed: '100680ad546ce6a577f42f52df33b4cfdca756859e664b8d7de329b150d09ce9',
|
|
|
|
|
+ serviceInstanceId: 'service-instance-id',
|
|
|
type: GrowiServiceType.cloud,
|
|
type: GrowiServiceType.cloud,
|
|
|
wikiType: GrowiWikiType.open,
|
|
wikiType: GrowiWikiType.open,
|
|
|
deploymentType: GrowiDeploymentType.others,
|
|
deploymentType: GrowiDeploymentType.others,
|
|
|
|
|
+ osInfo: {
|
|
|
|
|
+ type: 'Linux',
|
|
|
|
|
+ platform: 'linux',
|
|
|
|
|
+ arch: 'x64',
|
|
|
|
|
+ totalmem: 8589934592,
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
// legacy properties
|
|
// legacy properties
|
|
|
installedAt: new Date(),
|
|
installedAt: new Date(),
|
|
@@ -80,4 +102,24 @@ describe('convertToLegacyFormat', () => {
|
|
|
const result = convertToLegacyFormat(newFormatData);
|
|
const result = convertToLegacyFormat(newFormatData);
|
|
|
expect(result).toStrictEqual(expected);
|
|
expect(result).toStrictEqual(expected);
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ test('should convert new format and omit appSiteUrl', () => {
|
|
|
|
|
+ // arrange
|
|
|
|
|
+ const growiInfo = mock<IGrowiInfo<IGrowiAppAdditionalInfo>>({
|
|
|
|
|
+ appSiteUrl: 'https://example.com',
|
|
|
|
|
+ additionalInfo: {
|
|
|
|
|
+ installedAt: new Date(),
|
|
|
|
|
+ installedAtByOldestUser: new Date(),
|
|
|
|
|
+ currentUsersCount: 1,
|
|
|
|
|
+ currentActiveUsersCount: 1,
|
|
|
|
|
+ attachmentType: AttachmentMethodType.local,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // act
|
|
|
|
|
+ const result = convertToLegacyFormat({ growiInfo }, true);
|
|
|
|
|
+
|
|
|
|
|
+ // assert
|
|
|
|
|
+ expect(result.growiInfo.appSiteUrl).toBeUndefined();
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|