Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
Browse files Browse the repository at this point in the history
…nto BC-7008-element-socket-actions
  • Loading branch information
hoeppner-dataport committed May 17, 2024
2 parents 9633df5 + 951b5d3 commit 028352b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ describe(ContextExternalToolService.name, () => {

await service.copyContextExternalTool(contextExternalTool, contextCopyId);

expect(contextExternalToolRepo.save).toHaveBeenCalledWith(contextExternalTool);
expect(contextExternalToolRepo.save).toHaveBeenCalledWith(
new ContextExternalTool({ ...contextExternalTool.getProps(), id: expect.any(String) })
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { SchoolExternalTool } from '../../school-external-tool/domain';
import { SchoolExternalToolService } from '../../school-external-tool/service';
import {
ContextExternalTool,
ContextExternalToolLaunchable,
ContextRef,
RestrictedContextMismatchLoggableException,
ContextExternalToolLaunchable,
} from '../domain';
import { ContextExternalToolQuery } from '../uc/dto/context-external-tool.types';

Expand Down Expand Up @@ -88,11 +88,8 @@ export class ContextExternalToolService {
contextCopyId: EntityId
): Promise<ContextExternalTool> {
const copy = new ContextExternalTool({
...contextExternalTool.getProps(),
id: new ObjectId().toHexString(),
schoolToolRef: contextExternalTool.schoolToolRef,
contextRef: contextExternalTool.contextRef,
displayName: contextExternalTool.displayName,
parameters: contextExternalTool.parameters,
});

copy.contextRef.id = contextCopyId;
Expand All @@ -113,11 +110,11 @@ export class ContextExternalToolService {

externalTool.parameters?.forEach((parameter: CustomParameter): void => {
if (parameter.isProtected) {
this.deleteProtectedValues(contextExternalTool, parameter.name);
this.deleteProtectedValues(copy, parameter.name);
}
});

const copiedTool: ContextExternalTool = await this.contextExternalToolRepo.save(contextExternalTool);
const copiedTool: ContextExternalTool = await this.contextExternalToolRepo.save(copy);

return copiedTool;
}
Expand Down

0 comments on commit 028352b

Please sign in to comment.