Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorCapCoder committed Nov 14, 2023
1 parent dc3bf1d commit 9e1c878
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import { ContextExternalTool } from '../../context-external-tool/domain';
import { ToolConfigurationStatus } from '../enum';
import { ToolVersion } from '../interface';

// TODO N21-1337 remove class when tool versioning is removed
@Injectable()
export class CommonToolService {
/**
* @deprecated use ToolVersionService
*/
determineToolConfigurationStatus(
externalTool: ExternalTool,
schoolExternalTool: SchoolExternalTool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,24 @@ describe('ToolVersionService', () => {
contextExternalTool
);

expect(schoolExternalToolValidationService.validate).toHaveBeenCalledWith(schoolExternalTool);
expect(contextExternalToolValidationService.validate).toHaveBeenCalledWith(contextExternalTool);
expect(status).toEqual(ToolConfigurationStatus.LATEST);
});

it('should call schoolExternalToolValidationService', async () => {
const { externalTool, schoolExternalTool, contextExternalTool } = setup();

await service.determineToolConfigurationStatus(externalTool, schoolExternalTool, contextExternalTool);

expect(schoolExternalToolValidationService.validate).toHaveBeenCalledWith(schoolExternalTool);
});

it('should call contextExternalToolValidationService', async () => {
const { externalTool, schoolExternalTool, contextExternalTool } = setup();

await service.determineToolConfigurationStatus(externalTool, schoolExternalTool, contextExternalTool);

expect(schoolExternalToolValidationService.validate).toHaveBeenCalledWith(schoolExternalTool);
});
});

describe('when FEATURE_COMPUTE_TOOL_STATUS_WITHOUT_VERSIONS_ENABLED is true and validation throws an error', () => {
Expand Down Expand Up @@ -159,9 +173,23 @@ describe('ToolVersionService', () => {
contextExternalTool
);

expect(status).toEqual(ToolConfigurationStatus.OUTDATED);
});

it('should call schoolExternalToolValidationService', async () => {
const { externalTool, schoolExternalTool, contextExternalTool } = setup();

await service.determineToolConfigurationStatus(externalTool, schoolExternalTool, contextExternalTool);

expect(schoolExternalToolValidationService.validate).toHaveBeenCalledWith(schoolExternalTool);
});

it('should call contextExternalToolValidationService', async () => {
const { externalTool, schoolExternalTool, contextExternalTool } = setup();

await service.determineToolConfigurationStatus(externalTool, schoolExternalTool, contextExternalTool);

expect(contextExternalToolValidationService.validate).toHaveBeenCalledWith(contextExternalTool);
expect(status).toEqual(ToolConfigurationStatus.OUTDATED);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('SchoolExternalToolService', () => {
toolFearures = module.get(ToolFeatures);
});

// TODO N21-1337 refactor setup into the describe blocks
const legacySetup = () => {
const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.build();
const externalTool: ExternalTool = externalToolFactory.buildWithId();
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/tool/tool-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface IToolFeatures {
ctlToolsTabEnabled: boolean;
ltiToolsTabEnabled: boolean;
contextConfigurationEnabled: boolean;
// TODO N21-1337
// TODO N21-1337 refactor after feature flag is removed
toolStatusWithoutVersions: boolean;
maxExternalToolLogoSizeInBytes: number;
backEndUrl: string;
Expand All @@ -17,7 +17,7 @@ export default class ToolConfiguration {
ctlToolsTabEnabled: Configuration.get('FEATURE_CTL_TOOLS_TAB_ENABLED') as boolean,
ltiToolsTabEnabled: Configuration.get('FEATURE_LTI_TOOLS_TAB_ENABLED') as boolean,
contextConfigurationEnabled: Configuration.get('FEATURE_CTL_CONTEXT_CONFIGURATION_ENABLED') as boolean,
// TODO N21-1337
// TODO N21-1337 refactor after feature flag is removed
toolStatusWithoutVersions: Configuration.get('FEATURE_COMPUTE_TOOL_STATUS_WITHOUT_VERSIONS_ENABLED') as boolean,
maxExternalToolLogoSizeInBytes: Configuration.get('CTL_TOOLS__EXTERNAL_TOOL_MAX_LOGO_SIZE_IN_BYTES') as number,
backEndUrl: Configuration.get('PUBLIC_BACKEND_URL') as string,
Expand Down

0 comments on commit 9e1c878

Please sign in to comment.