Skip to content

Commit

Permalink
fix dependency unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorCapCoder committed Nov 27, 2023
1 parent 25745b1 commit 7df6b85
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {
} from '@shared/testing';
import { ServerTestModule } from '@modules/server';
import { Response } from 'supertest';
import { ToolContextType } from '../../../common/enum';
import {
CustomParameterLocation,
CustomParameterScope,
CustomParameterType,
ToolContextType,
} from '../../../common/enum';
import { ExternalToolEntity } from '../../../external-tool/entity';
import { SchoolExternalToolEntity } from '../../../school-external-tool/entity';
import { ContextExternalToolEntity, ContextExternalToolType } from '../../entity';
Expand Down Expand Up @@ -114,6 +119,24 @@ describe('ToolReferenceController (API)', () => {
const course: Course = courseFactory.buildWithId({ school, teachers: [adminUser] });
const externalToolEntity: ExternalToolEntity = externalToolEntityFactory.buildWithId({
logoBase64: 'logoBase64',
parameters: [
{
name: 'schoolMockParameter',
displayName: 'MockParameter',
scope: CustomParameterScope.SCHOOL,
type: CustomParameterType.STRING,
location: CustomParameterLocation.PATH,
isOptional: false,
},
{
name: 'contextMockParameter',
displayName: 'MockParameter',
scope: CustomParameterScope.CONTEXT,
type: CustomParameterType.STRING,
location: CustomParameterLocation.PATH,
isOptional: false,
},
],
});
const schoolExternalToolEntity: SchoolExternalToolEntity = schoolExternalToolEntityFactory.buildWithId({
school,
Expand Down Expand Up @@ -233,6 +256,24 @@ describe('ToolReferenceController (API)', () => {
const course: Course = courseFactory.buildWithId({ school, teachers: [adminUser] });
const externalToolEntity: ExternalToolEntity = externalToolEntityFactory.buildWithId({
logoBase64: 'logoBase64',
parameters: [
{
name: 'schoolMockParameter',
displayName: 'MockParameter',
scope: CustomParameterScope.SCHOOL,
type: CustomParameterType.STRING,
location: CustomParameterLocation.PATH,
isOptional: false,
},
{
name: 'contextMockParameter',
displayName: 'MockParameter',
scope: CustomParameterScope.CONTEXT,
type: CustomParameterType.STRING,
location: CustomParameterLocation.PATH,
isOptional: false,
},
],
});
const schoolExternalToolEntity: SchoolExternalToolEntity = schoolExternalToolEntityFactory.buildWithId({
school,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ describe('ExternalToolConfigurationUc', () => {
externalToolConfigurationService.filterForAvailableExternalTools.mockReturnValue([
{ externalTool: usedTool, schoolExternalTool: usedSchoolExternalTool },
]);
externalToolConfigurationService.filterForContextRestrictions.mockReturnValue([
{ externalTool: usedTool, schoolExternalTool: usedSchoolExternalTool },
]);

return {
toolIds,
Expand Down Expand Up @@ -368,6 +371,7 @@ describe('ExternalToolConfigurationUc', () => {
unusedSchoolExternalTool,
]);
externalToolConfigurationService.filterForAvailableExternalTools.mockReturnValue([]);
externalToolConfigurationService.filterForContextRestrictions.mockReturnValue([]);

return {};
};
Expand Down Expand Up @@ -409,6 +413,9 @@ describe('ExternalToolConfigurationUc', () => {
externalToolConfigurationService.filterForAvailableExternalTools.mockReturnValue([
{ externalTool: usedTool, schoolExternalTool: usedSchoolExternalTool },
]);
externalToolConfigurationService.filterForContextRestrictions.mockReturnValue([
{ externalTool: usedTool, schoolExternalTool: usedSchoolExternalTool },
]);

return {
usedTool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import { SchoolExternalToolEntity } from '../../../school-external-tool/entity';
import { LaunchRequestMethod } from '../../types';
import { ToolLaunchRequestResponse, ToolLaunchParams } from '../dto';
import { ContextExternalToolEntity, ContextExternalToolType } from '../../../context-external-tool/entity';
import { ExternalToolEntity } from '../../../external-tool/entity';
import {
CustomParameterLocation,
CustomParameterScope,
CustomParameterType,
ExternalToolEntity,
} from '../../../external-tool/entity';
import { ToolConfigType } from '../../../common/enum';

describe('ToolLaunchController (API)', () => {
Expand Down Expand Up @@ -64,6 +69,24 @@ describe('ToolLaunchController (API)', () => {
const externalToolEntity: ExternalToolEntity = externalToolEntityFactory.buildWithId({
config: basicToolConfigFactory.build({ baseUrl: 'https://mockurl.de', type: ToolConfigType.BASIC }),
version: 0,
parameters: [
{
name: 'schoolMockParameter',
displayName: 'MockParameter',
scope: CustomParameterScope.SCHOOL,
type: CustomParameterType.STRING,
location: CustomParameterLocation.PATH,
isOptional: false,
},
{
name: 'contextMockParameter',
displayName: 'MockParameter',
scope: CustomParameterScope.CONTEXT,
type: CustomParameterType.STRING,
location: CustomParameterLocation.PATH,
isOptional: false,
},
],
});
const schoolExternalToolEntity: SchoolExternalToolEntity = schoolExternalToolEntityFactory.buildWithId({
tool: externalToolEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const contextExternalToolEntityFactory = BaseFactory.define<
contextType: ContextExternalToolType.COURSE,
displayName: 'My Course Tool 1',
schoolTool: schoolExternalToolEntityFactory.buildWithId(),
parameters: [new CustomParameterEntryEntity({ name: 'mockParamater', value: 'mockValue' })],
parameters: [new CustomParameterEntryEntity({ name: 'contextMockParameter', value: 'mockValue' })],
toolVersion: 1,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const schoolExternalToolEntityFactory = BaseFactory.define<
return {
tool: externalToolEntityFactory.buildWithId(),
school: schoolFactory.buildWithId(),
schoolParameters: [{ name: 'mockParamater', value: 'mockValue' }],
schoolParameters: [{ name: 'schoolMockParameter', value: 'mockValue' }],
toolVersion: 0,
};
});

0 comments on commit 7df6b85

Please sign in to comment.