From 6659d213f51ef71813e3f7a77139f22443c8de84 Mon Sep 17 00:00:00 2001 From: Mrika Llabani Date: Thu, 23 Nov 2023 14:48:40 +0100 Subject: [PATCH] N21-1494 move toolConfiguration status --- .../src/modules/tool/common/domain/index.ts | 2 +- .../tool-configuration-status.ts | 0 .../src/modules/tool/common/enum/index.ts | 2 +- .../service/tool-reference.service.spec.ts | 18 +++++++++-- .../api-test/tool-school.api.spec.ts | 32 ++++++++++++++++--- 5 files changed, 46 insertions(+), 8 deletions(-) rename apps/server/src/modules/tool/common/{enum => domain}/tool-configuration-status.ts (100%) diff --git a/apps/server/src/modules/tool/common/domain/index.ts b/apps/server/src/modules/tool/common/domain/index.ts index ae59ec3f2a3..155961be0d3 100644 --- a/apps/server/src/modules/tool/common/domain/index.ts +++ b/apps/server/src/modules/tool/common/domain/index.ts @@ -1,3 +1,3 @@ export * from './custom-parameter.do'; export * from './custom-parameter-entry.do'; -export * from '../enum/tool-configuration-status'; +export * from './tool-configuration-status'; diff --git a/apps/server/src/modules/tool/common/enum/tool-configuration-status.ts b/apps/server/src/modules/tool/common/domain/tool-configuration-status.ts similarity index 100% rename from apps/server/src/modules/tool/common/enum/tool-configuration-status.ts rename to apps/server/src/modules/tool/common/domain/tool-configuration-status.ts diff --git a/apps/server/src/modules/tool/common/enum/index.ts b/apps/server/src/modules/tool/common/enum/index.ts index 24628ac19f5..950593fc6b9 100644 --- a/apps/server/src/modules/tool/common/enum/index.ts +++ b/apps/server/src/modules/tool/common/enum/index.ts @@ -10,4 +10,4 @@ export * from './tool-context-type.enum'; export * from './custom-parameter-location.enum'; export * from './custom-parameter-scope.enum'; export * from './custom-parameter-type.enum'; -export * from './tool-configuration-status'; +export * from '../domain/tool-configuration-status'; diff --git a/apps/server/src/modules/tool/context-external-tool/service/tool-reference.service.spec.ts b/apps/server/src/modules/tool/context-external-tool/service/tool-reference.service.spec.ts index 1796b2f681d..22683f78c18 100644 --- a/apps/server/src/modules/tool/context-external-tool/service/tool-reference.service.spec.ts +++ b/apps/server/src/modules/tool/context-external-tool/service/tool-reference.service.spec.ts @@ -79,7 +79,15 @@ describe('ToolReferenceService', () => { contextExternalToolService.findById.mockResolvedValueOnce(contextExternalTool); schoolExternalToolService.findById.mockResolvedValueOnce(schoolExternalTool); externalToolService.findById.mockResolvedValueOnce(externalTool); - toolVersionService.determineToolConfigurationStatus.mockResolvedValue(ToolConfigurationStatus.OUTDATED); + toolVersionService.determineToolConfigurationStatus.mockResolvedValue( + new ToolConfigurationStatus({ + latest: false, + isDisabled: false, + isOutdatedOnScopeSchool: true, + isOutdatedOnScopeContext: false, + isUnkown: false, + }) + ); externalToolLogoService.buildLogoUrl.mockReturnValue(logoUrl); return { @@ -123,7 +131,13 @@ describe('ToolReferenceService', () => { logoUrl, displayName: contextExternalTool.displayName as string, openInNewTab: externalTool.openNewTab, - status: ToolConfigurationStatus.OUTDATED, + status: new ToolConfigurationStatus({ + latest: false, + isDisabled: false, + isOutdatedOnScopeSchool: true, + isOutdatedOnScopeContext: false, + isUnkown: false, + }), contextToolId: contextExternalToolId, }); }); diff --git a/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts b/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts index 274bd289edf..632456bdb9a 100644 --- a/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts +++ b/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts @@ -140,7 +140,13 @@ describe('ToolSchoolController (API)', () => { name: externalToolEntity.name, schoolId: postParams.schoolId, toolId: postParams.toolId, - status: ToolConfigurationStatusResponse.LATEST, + status: new ToolConfigurationStatusResponse({ + latest: true, + isDisabled: false, + isOutdatedOnScopeSchool: false, + isOutdatedOnScopeContext: false, + isUnkown: false, + }), toolVersion: postParams.version, parameters: [ { name: 'param1', value: 'value' }, @@ -297,7 +303,13 @@ describe('ToolSchoolController (API)', () => { name: externalToolEntity.name, schoolId: school.id, toolId: externalToolEntity.id, - status: ToolConfigurationStatusResponse.OUTDATED, + status: new ToolConfigurationStatusResponse({ + latest: false, + isDisabled: false, + isOutdatedOnScopeSchool: true, + isOutdatedOnScopeContext: false, + isUnkown: false, + }), toolVersion: schoolExternalToolEntity.toolVersion, parameters: [ { @@ -340,7 +352,13 @@ describe('ToolSchoolController (API)', () => { name: '', schoolId: school.id, toolId: externalToolEntity.id, - status: ToolConfigurationStatusResponse.UNKNOWN, + status: new ToolConfigurationStatusResponse({ + latest: false, + isDisabled: false, + isOutdatedOnScopeSchool: false, + isOutdatedOnScopeContext: false, + isUnkown: true, + }), toolVersion: schoolExternalToolEntity.toolVersion, parameters: [ { @@ -466,7 +484,13 @@ describe('ToolSchoolController (API)', () => { name: externalToolEntity.name, schoolId: postParamsUpdate.schoolId, toolId: postParamsUpdate.toolId, - status: ToolConfigurationStatusResponse.LATEST, + status: new ToolConfigurationStatusResponse({ + latest: true, + isDisabled: false, + isOutdatedOnScopeSchool: false, + isOutdatedOnScopeContext: false, + isUnkown: false, + }), toolVersion: postParamsUpdate.version, parameters: [ {