Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EW-1060 common cartridge export via cc-microservice #5351

Merged
merged 79 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
cc5da6f
EW-1060 testing the new export via a test endpoint
Fshmit Nov 7, 2024
7729acc
EW-1060 moved linked task to lesson dto
Fshmit Nov 7, 2024
414b696
EW-1060 implemented new cc export service via microservice
Fshmit Nov 11, 2024
cf66e8f
EW-1060 resolved dependecy of the new cc mapper
Fshmit Nov 11, 2024
b456cb8
EW-1060 deleted testing dto of cc export
Fshmit Nov 11, 2024
4eb2890
EW-1060 created some classes instead of interfaces
Fshmit Nov 12, 2024
c403e2e
Regenerate lesson api client.
mkreuzkam-cap Nov 12, 2024
a531b70
EW-1060 implemented new mapping of lesson content
Fshmit Nov 13, 2024
718f309
EW-1060 modified mapper
Fshmit Nov 13, 2024
f980547
Merge branch 'main' into EW-1060
Fshmit Nov 13, 2024
4d198a5
EW-1060 modified mapper of lesson dto
Fshmit Nov 13, 2024
0d53c29
EW-1060 removed items from api property
Fshmit Nov 13, 2024
224c556
Regenerate lesson client.
mkreuzkam-cap Nov 13, 2024
ef5334b
regen lesson api.
mkreuzkam-cap Nov 13, 2024
3e2a730
EW-1060 modified mapper of lesson content
Fshmit Nov 13, 2024
709ea25
EW-1060 edited common cartridge mapper
Fshmit Nov 13, 2024
fc5d3e3
EW-1060 added control options of course element
Fshmit Nov 14, 2024
0a0815b
Merge branch 'main' into EW-1060
Fshmit Nov 14, 2024
d12111c
EW-1060 changed endpoint name of new export
Fshmit Nov 14, 2024
8f7f5b8
EW-1060 changed export endpoint to POST
Fshmit Nov 15, 2024
794c806
EW-1060 modified mapping of some cc elements
Fshmit Nov 15, 2024
02cc85c
EW-1060 deleted the old export endpoint of cc- microservice
Fshmit Nov 15, 2024
0f4a3be
Merge branch 'main' into EW-1060
Fshmit Nov 18, 2024
e81ff22
EW-1060 fixed export of cards
Fshmit Nov 19, 2024
ae156b7
EW-1060 changed showen title of a card
Fshmit Nov 21, 2024
62fa3b6
EW-1060 modified test of export uc
Fshmit Nov 22, 2024
1f13353
EW-1060 added some logs
Fshmit Nov 22, 2024
1a2323c
Merge branch 'main' into EW-1060
Fshmit Nov 22, 2024
f799b1d
EW-1060 added test for cc controller
Fshmit Nov 25, 2024
d6102ef
EW-1060 changed some variables name
Fshmit Nov 27, 2024
e50495d
EW-1060 added logger module to imports
Fshmit Nov 27, 2024
485741c
EW-1060 merge main into 1060
Fshmit Nov 27, 2024
131bf44
EW-1060 merge main
Fshmit Nov 27, 2024
0599ed3
EW-1060 added tests for cc export service
Fshmit Nov 27, 2024
0dc4646
EW-1060 removed files client from cc service
Fshmit Nov 28, 2024
436f23e
EW-1060 removed error logger from cc service
Fshmit Nov 28, 2024
5f48ca9
EW-1060 added axios error to global filter
Fshmit Nov 28, 2024
5849561
EW-1060 added test for axios loggable
Fshmit Nov 28, 2024
ae4e4bc
Merge branch 'main' into EW-1060
Fshmit Nov 29, 2024
ea64b51
EW-1060 fixed cc service test
Fshmit Nov 29, 2024
ee6937c
EW-1060 fixed mapping of lernstore component
Fshmit Nov 29, 2024
1b83a8e
Merge branch 'main' into EW-1060
Fshmit Nov 29, 2024
b8db891
EW-1060 changed some variables to constants
Fshmit Nov 29, 2024
346caba
EW-1060 covered lernstore elements of a lesson by a test
Fshmit Nov 29, 2024
2583f28
EW-1060 modified test of lesson client adapter
Fshmit Nov 29, 2024
d82f0eb
EW-1060 added dtos fatory for cc & modified card response
Fshmit Dec 2, 2024
f03855f
EW-1060 added test factories for cc export
Fshmit Dec 3, 2024
d7bbbeb
EW-1060 merge main
Fshmit Dec 3, 2024
056869e
EW-1060 some changes
Fshmit Dec 3, 2024
451b7e0
EW-1060 some changes
Fshmit Dec 4, 2024
afc4f78
EW-1060 review changes
Fshmit Dec 4, 2024
892d729
EW-1060 deleted checks of exported elements
Fshmit Dec 4, 2024
341aff9
EW-1060 fixed lint errors
Fshmit Dec 4, 2024
e1a6c99
EW-1060 fixed lint errors
Fshmit Dec 4, 2024
1876734
EW-1060 fixed more lint errors
Fshmit Dec 4, 2024
68c3dc4
EW-1060 fixed card mapper test
Fshmit Dec 4, 2024
7b95ddb
Merge branch 'main' into EW-1060
Fshmit Dec 5, 2024
dc1589f
EW-1060 modifed test of lesson dto mapper
Fshmit Dec 5, 2024
43fbd5a
EW-1060 added common cartridge export mapper
Fshmit Dec 5, 2024
7accdc5
EW-1060 completed test coverage for cc mapper
Fshmit Dec 6, 2024
d91df6a
Merge branch 'main' into EW-1060
Fshmit Dec 6, 2024
6263299
Merge branch 'main' into EW-1060
Fshmit Dec 10, 2024
2de9df6
EW-1060 coverage of tests
Fshmit Dec 10, 2024
d243f2d
EW-1060 deleted check for axios error from domain handelr
Fshmit Dec 10, 2024
e2d3e0b
EW-1060 review changes
Fshmit Dec 11, 2024
2b389b6
EW-1060 fixed typo
Fshmit Dec 11, 2024
48da5f3
Merge branch 'main' into EW-1060
Fshmit Dec 11, 2024
70ab327
EW-1060 added accessibility modifier
Fshmit Dec 13, 2024
6c07050
EW-1060 merge main
Fshmit Dec 13, 2024
5de498b
EW-1060 fixed deep imports and add separate factories
Fshmit Dec 13, 2024
9b5e8f7
EW-1060 modified imports of CC mapper
Fshmit Dec 13, 2024
7ae761d
EW-1060 modified deep imports of some dtos
Fshmit Dec 13, 2024
01d36c3
EW-1060 covered code with tests
Fshmit Dec 13, 2024
2d480a2
EW-1060 modified linked task of topic
Fshmit Dec 13, 2024
bfdf09e
Merge branch 'main' into EW-1060
Fshmit Dec 16, 2024
29431f2
Merge branch 'main' into EW-1060
psachmann Dec 17, 2024
0d5e9b7
Merge branch 'main' into EW-1060
MajedAlaitwniCap Dec 18, 2024
1071e4e
removed check of elements to dtos
Fshmit Dec 18, 2024
4f9ab9d
Merge branch 'EW-1060' of https://github.com/hpi-schul-cloud/schulclo…
Fshmit Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ansible/roles/common-cartridge/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
- service

# This is a testing route and will not be deployed
# - name: Ingress
# kubernetes.core.k8s:
# kubeconfig: ~/.kube/config
# namespace: "{{ NAMESPACE }}"
# template: ingress.yml.j2
# when: WITH_COMMON_CARTRIDGE is defined and WITH_COMMON_CARTRIDGE|bool
# tags:
# - ingress
- name: Ingress
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: ingress.yml.j2
when: WITH_COMMON_CARTRIDGE is defined and WITH_COMMON_CARTRIDGE|bool
tags:
- ingress
MajedAlaitwniCap marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions apps/server/src/core/error/domain/domain-error-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Test, TestingModule } from '@nestjs/testing';
import { BusinessError } from '@shared/common';
import { ErrorLogger, ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger';
import util from 'util';
import { AxiosError } from 'axios';
import { ErrorLoggable } from '../loggable/error.loggable';
import { ErrorUtils } from '../utils';
import { AxiosErrorLoggable } from '../loggable';
import { DomainErrorHandler } from './domain-error-handler';

class SampleLoggableException extends BadRequestException implements Loggable {
Expand Down Expand Up @@ -201,5 +203,22 @@ describe('GlobalErrorFilter', () => {
expect(logger.error).toBeCalledWith(loggable);
});
});

describe('when error is a axios error', () => {
const setup = () => {
const error = new AxiosError('test');
const axiosLoggable = new AxiosErrorLoggable(error, 'AXIOS_REQUEST_ERROR');

return { axiosLoggable };
};

it('should call logger with axios error', () => {
const { axiosLoggable } = setup();

domainErrorHandler.exec(axiosLoggable);

expect(logger.error).toBeCalledWith(axiosLoggable);
});
});
});
});
21 changes: 21 additions & 0 deletions apps/server/src/core/error/filter/global-error.filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { WsException } from '@nestjs/websockets';
import { BusinessError } from '@shared/common';
import { ErrorLogMessage, Loggable } from '@src/core/logger';
import { Response } from 'express';
import { AxiosError } from 'axios';
import { DomainErrorHandler } from '../domain';
import { ErrorResponse } from '../dto';
import { ErrorUtils } from '../utils';
Expand Down Expand Up @@ -102,6 +103,26 @@ describe('GlobalErrorFilter', () => {
});
});

describe('given context is axios', () => {
const setup = () => {
const argumentsHost = createMock<ArgumentsHost>();
argumentsHost.getType.mockReturnValueOnce(UseableContextType.http);

const error = new AxiosError('test');

return { error, argumentsHost };
};

it('should call exec on domain error handler', () => {
const { error, argumentsHost } = setup();

service.catch(error, argumentsHost);

expect(domainErrorHandler.execHttpContext).toBeCalledWith(error, {});
expect(domainErrorHandler.execHttpContext).toBeCalledTimes(1);
});
});

describe('given context is http', () => {
const mockHttpArgumentsHost = () => {
const argumentsHost = createMock<ArgumentsHost>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CardResponseDto } from './card-response.dto';

export class CardListResponseDto {
data: CardResponseDto[];
public data: CardResponseDto[];

constructor(data: CardResponseDto[]) {
this.data = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,24 @@ import { TimestampResponseDto } from './timestamp-response.dto';
import { VisibilitySettingsResponseDto } from './visibility-settings-response.dto';

export class CardResponseDto {
id: string;
public id: string;

title?: string;
public title?: string;

height: number;
public height: number;

elements: Array<CardResponseElementsInnerDto>;
public elements: Array<CardResponseElementsInnerDto>;

visibilitySettings: VisibilitySettingsResponseDto;
public visibilitySettings: VisibilitySettingsResponseDto;

timeStamps: TimestampResponseDto;
public timeStamps: TimestampResponseDto;

constructor(
id: string,
title: string,
height: number,
elements: CardResponseElementsInnerDto[],
visibilitySettings: VisibilitySettingsResponseDto,
timestamps: TimestampResponseDto
) {
this.id = id;
this.title = title;
this.height = height;
this.elements = elements;
this.visibilitySettings = visibilitySettings;
this.timeStamps = timestamps;
constructor(props: Readonly<CardResponseDto>) {
this.id = props.id;
this.title = props.title;
this.height = props.height;
this.elements = props.elements;
this.visibilitySettings = props.visibilitySettings;
this.timeStamps = props.timeStamps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { ContentElementType } from '../cards-api-client';
import { TimestampResponseDto } from './timestamp-response.dto';

export class CollaborativeTextEditorElementResponseDto {
id: string;
public id: string;

type: ContentElementType;
public type: ContentElementType;

timestamps: TimestampResponseDto;
public timestamps: TimestampResponseDto;

content: object;
public content: object;

constructor(id: string, type: ContentElementType, content: object, timestamps: TimestampResponseDto) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export { RichTextElementResponseDto } from './rich-text-element-response.dto';
export { RichTextElementContentDto } from './rich-text-element-content.dto';
export { LinkElementContentDto } from './link-element-content.dto';
export { LinkElementResponseDto } from './link-element-response.dto';
export { CardResponseDto } from './card-response.dto';
export { CardListResponseDto } from './card-list-response.dto';
export { TimestampResponseDto } from './timestamp-response.dto';
export { VisibilitySettingsResponseDto } from './visibility-settings-response.dto';
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export class LinkElementContentDto {
url: string;
public url: string;

title: string;
public title: string;

description?: string;
public description?: string;

imageUrl?: string;
public imageUrl?: string;

constructor(url: string, title: string, description: string, imageUrl: string) {
this.url = url;
this.title = title;
this.description = description;
this.imageUrl = imageUrl;
constructor(props: Readonly<LinkElementContentDto>) {
this.url = props.url;
this.title = props.title;
this.description = props.description;
this.imageUrl = props.imageUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import { LinkElementContentDto } from './link-element-content.dto';
import { TimestampResponseDto } from './timestamp-response.dto';

export class LinkElementResponseDto {
id: string;
public id: string;

type: ContentElementType;
public type: ContentElementType;

content: LinkElementContentDto;
public content: LinkElementContentDto;

timestamps: TimestampResponseDto;
public timestamps: TimestampResponseDto;

constructor(id: string, type: ContentElementType, content: LinkElementContentDto, timestamps: TimestampResponseDto) {
this.id = id;
this.type = type;
this.content = content;
this.timestamps = timestamps;
constructor(props: LinkElementResponseDto) {
this.id = props.id;
this.type = props.type;
this.content = props.content;
this.timestamps = props.timestamps;
}

public static isLinkElement(reference: unknown): reference is LinkElementResponseDto {
return reference instanceof LinkElementResponseDto;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class RichTextElementContentDto {
text: string;
public text: string;

inputFormat: string;
public inputFormat: string;

constructor(text: string, inputFormat: string) {
this.text = text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ import { RichTextElementContentDto } from './rich-text-element-content.dto';
import { TimestampResponseDto } from './timestamp-response.dto';

export class RichTextElementResponseDto {
id: string;
public id: string;

type: ContentElementType;
public type: ContentElementType;

content: RichTextElementContentDto;
public content: RichTextElementContentDto;

timestamps: TimestampResponseDto;
public timestamps: TimestampResponseDto;

constructor(
id: string,
type: ContentElementType,
content: RichTextElementContentDto,
timestamps: TimestampResponseDto
) {
this.id = id;
this.type = type;
this.content = content;
this.timestamps = timestamps;
constructor(props: Readonly<RichTextElementResponseDto>) {
this.id = props.id;
this.type = props.type;
this.content = props.content;
this.timestamps = props.timestamps;
}

public static isRichTextElement(reference: unknown): reference is RichTextElementResponseDto {
return reference instanceof RichTextElementResponseDto;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export class TimestampResponseDto {
lastUpdatedAt: string;
public lastUpdatedAt: string;

createdAt: string;
public createdAt: string;

deletedAt?: string;
public deletedAt?: string;

constructor(lastUpdatedAt: string, createdAt: string, deletedAt: string) {
this.lastUpdatedAt = lastUpdatedAt;
this.createdAt = createdAt;
this.deletedAt = deletedAt;
constructor(props: Readonly<TimestampResponseDto>) {
this.lastUpdatedAt = props.lastUpdatedAt;
this.createdAt = props.createdAt;
this.deletedAt = props.deletedAt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,5 @@ describe('CardResponseMapper', () => {
expect(cardResponse.visibilitySettings.publishedAt).toBe('');
});
});

describe('when deletedAt in TimestampsResponse is null', () => {
const mockList: CardListResponse = setup([]);
mockList.data[0].timestamps.deletedAt = undefined;

it('should return an empty string', () => {
const mapperResult = CardResponseMapper.mapToCardListResponseDto(mockList);
const cardResponse: CardResponseDto = mapperResult.data[0];

expect(cardResponse.timeStamps.deletedAt).toBe('');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export class CardResponseMapper {
}

private static mapToCardResponseDto(cardResponse: CardResponse): CardResponseDto {
return new CardResponseDto(
cardResponse.id,
cardResponse.title ?? '',
cardResponse.height,
this.mapToCardResponseElementsInnerDto(cardResponse.elements),
this.mapToVisibilitySettingsDto(cardResponse.visibilitySettings),
this.mapToTimestampDto(cardResponse.timestamps)
);
return new CardResponseDto({
id: cardResponse.id,
title: cardResponse.title,
height: cardResponse.height,
elements: this.mapToCardResponseElementsInnerDto(cardResponse.elements),
visibilitySettings: this.mapToVisibilitySettingsDto(cardResponse.visibilitySettings),
timeStamps: this.mapToTimestampDto(cardResponse.timestamps),
});
}

private static mapToCardResponseElementsInnerDto(
Expand Down Expand Up @@ -138,24 +138,28 @@ export class CardResponseMapper {
case ContentElementType.LINK: {
const content: LinkElementContent = element.content as LinkElementContent;
elements.push(
new LinkElementResponseDto(
element.id,
ContentElementType.LINK,
new LinkElementContentDto(content.url, content.title, content.description ?? '', content.imageUrl ?? ''),
this.mapToTimestampDto(element.timestamps)
)
new LinkElementResponseDto({
id: element.id,
type: ContentElementType.LINK,
content: new LinkElementContentDto({
url: content.url,
title: content.title,
description: content.description,
}),
timestamps: this.mapToTimestampDto(element.timestamps),
})
);
break;
}
case ContentElementType.RICH_TEXT: {
const content: RichTextElementContent = element.content as RichTextElementContent;
elements.push(
new RichTextElementResponseDto(
element.id,
ContentElementType.RICH_TEXT,
new RichTextElementContentDto(content.text, content.inputFormat),
this.mapToTimestampDto(element.timestamps)
)
new RichTextElementResponseDto({
id: element.id,
type: ContentElementType.RICH_TEXT,
content: new RichTextElementContentDto(content.text, content.inputFormat),
timestamps: this.mapToTimestampDto(element.timestamps),
})
);
break;
}
Expand Down Expand Up @@ -185,6 +189,10 @@ export class CardResponseMapper {
}

private static mapToTimestampDto(timestamp: TimestampsResponse): TimestampResponseDto {
return new TimestampResponseDto(timestamp.lastUpdatedAt, timestamp.createdAt, timestamp.deletedAt ?? '');
return new TimestampResponseDto({
lastUpdatedAt: timestamp.lastUpdatedAt,
createdAt: timestamp.createdAt,
deletedAt: timestamp.deletedAt,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe(CoursesClientAdapter.name, () => {

expect(coursesApi.courseControllerGetCourseCcMetadataById).toHaveBeenCalledWith(courseId, expectedOptions);
expect(result.id).toBeDefined();
expect(result.title).toBeDefined();
expect(result.courseName).toBeDefined();
expect(result.creationDate).toBeDefined();
expect(result.copyRightOwners).toBeDefined();
});
Expand Down
Loading
Loading