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-977 remove redundant title from cards after export #5318

Merged
merged 26 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3c62bf0
remove redundant title from cards after export
MajedAlaitwniCap Oct 29, 2024
ad73f3c
section title to card title
MajedAlaitwniCap Oct 30, 2024
59999b2
Merge branch 'main' into EW-977
psachmann Jan 6, 2025
27bd49a
Merge branch 'main' of https://github.com/hpi-schul-cloud/schulcloud-…
MajedAlaitwniCap Jan 14, 2025
171a2aa
Initial commit
MajedAlaitwniCap Jan 15, 2025
574c372
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 15, 2025
f43583d
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 16, 2025
bd1be92
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 16, 2025
1590a87
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 20, 2025
467b3f4
remove column title
MajedAlaitwniCap Jan 20, 2025
3abb96f
adjust test
MajedAlaitwniCap Jan 21, 2025
e206eeb
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 21, 2025
4591c80
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 21, 2025
e348c8d
Fix 1/3 of tests after title changed.
mkreuzkam-cap Jan 21, 2025
685b260
user counter for naming Column
MajedAlaitwniCap Jan 22, 2025
90cbaa8
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 22, 2025
e8d69f5
initial commit
MajedAlaitwniCap Jan 22, 2025
5f505f9
adjust test for column title
MajedAlaitwniCap Jan 22, 2025
2574bf9
Work on Review Comments
MajedAlaitwniCap Jan 23, 2025
40782db
Merge branch 'main' of https://github.com/hpi-schul-cloud/schulcloud-…
MajedAlaitwniCap Jan 27, 2025
b31ee78
fix mapper Tests
MajedAlaitwniCap Jan 27, 2025
b71a3c4
remove duplicate card title
MajedAlaitwniCap Jan 28, 2025
c86f563
fix CCImportMapper Tests
MajedAlaitwniCap Jan 29, 2025
3f2d7ce
Merge branch 'main' into EW-977
MajedAlaitwniCap Jan 29, 2025
e99943c
change attribute name
MajedAlaitwniCap Jan 30, 2025
7981a13
Merge branch 'main' into EW-977
psachmann Jan 30, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type CommonCartridgeFileParserOptions = {
export const DEFAULT_FILE_PARSER_OPTIONS: CommonCartridgeFileParserOptions = {
maxSearchDepth: 5,
pathSeparator: '/',
inputFormat: InputFormat.RICH_TEXT_CK5,
inputFormat: InputFormat.RICH_TEXT_CK4,
psachmann marked this conversation as resolved.
Show resolved Hide resolved
};

export type CommonCartridgeOrganizationProps = {
Expand All @@ -27,7 +27,6 @@ export type CommonCartridgeOrganizationProps = {

export type CommonCartridgeWebContentResourceProps = {
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT;
title: string;
html: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ describe('CommonCartridgeResourceFactory', () => {

expect(result).toStrictEqual({
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
title: organizationProps.title,
html: '<p>Content</p>',
});
});
Expand All @@ -191,7 +190,6 @@ describe('CommonCartridgeResourceFactory', () => {

expect(result).toStrictEqual({
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
title: organizationProps.title,
html: '',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class CommonCartridgeResourceFactory {
case CommonCartridgeResourceTypeV1P1.WEB_LINK:
return this.createWebLinkResource(content, title);
case CommonCartridgeResourceTypeV1P1.WEB_CONTENT:
return this.createWebContentResource(content, title, inputFormat);
return this.createWebContentResource(content, inputFormat);
default:
return undefined;
}
Expand Down Expand Up @@ -59,7 +59,6 @@ export class CommonCartridgeResourceFactory {

private createWebContentResource(
content: string,
title: string,
psachmann marked this conversation as resolved.
Show resolved Hide resolved
inputFormat: InputFormat
): CommonCartridgeWebContentResourceProps | undefined {
const document = this.tryCreateDocument(content, 'text/html');
Expand All @@ -72,7 +71,6 @@ export class CommonCartridgeResourceFactory {

return {
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
title,
html,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('CommonCartridgeExportMapper', () => {
expect(result).toEqual({
identifier: `i${task.id}`,
title: task.name,
html: `<h1>${task.name}</h1><p>${task.description ?? ''}</p>`,
html: `<p>${task.description ?? ''}</p>`,
intendedUse: CommonCartridgeIntendedUseType.UNSPECIFIED,
type: CommonCartridgeResourceType.WEB_CONTENT,
});
Expand All @@ -252,7 +252,7 @@ describe('CommonCartridgeExportMapper', () => {
expect(result).toEqual({
identifier: `i${task.id}`,
title: task.name,
html: `<h1>${task.name}</h1><p>${task.description ?? ''}</p>`,
html: `<p>${task.description ?? ''}</p>`,
intendedUse: CommonCartridgeIntendedUseType.ASSIGNMENT,
type: CommonCartridgeResourceType.WEB_CONTENT,
});
Expand All @@ -267,7 +267,7 @@ describe('CommonCartridgeExportMapper', () => {
expect(result).toEqual({
identifier: `i${task.id}`,
title: task.name,
html: `<h1>${task.name}</h1><p>${task.description ?? ''}</p>`,
html: `<p>${task.description ?? ''}</p>`,
intendedUse: CommonCartridgeIntendedUseType.UNSPECIFIED,
type: CommonCartridgeResourceType.WEB_CONTENT,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export class CommonCartridgeExportMapper {
type: CommonCartridgeResourceType.WEB_CONTENT,
identifier: createIdentifier(lessonContent.id),
title: lessonContent.title,
html: `<h1>${lessonContent.title ?? ''}</h1><p>${
(lessonContent.content as ComponentTextPropsDto).text ?? ''
}</p>`,
html: `<p>${(lessonContent.content as ComponentTextPropsDto).text ?? ''}</p>`,
intendedUse: CommonCartridgeIntendedUseType.UNSPECIFIED,
};
case LessonContentDtoComponentValues.GEO_GEBRA:
Expand Down Expand Up @@ -146,7 +144,7 @@ export class CommonCartridgeExportMapper {
type: CommonCartridgeResourceType.WEB_CONTENT,
identifier: createIdentifier(task.id),
title: task.name,
html: `<h1>${task.name}</h1><p>${task.description ?? ''}</p>`,
html: `<p>${task.description ?? ''}</p>`,
intendedUse,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,34 @@ describe('CommonCartridgeImportMapper', () => {
});
});
});
});

describe('mapOrganizationToCard', () => {
describe('when organization is provided', () => {
describe('when organization is provided and withTitle is false', () => {
const setup = () => setupOrganization();

it('should map organization to card', () => {
it('should set the title to an empty string', () => {
const { organization } = setup();

const result = sut.mapOrganizationToCard(organization);
const result = sut.mapOrganizationToCard(organization, false);

expect(result).toEqual({
title: organization.title,
title: '',
height: 150,
});
});
});
});

describe('when organization is provided and withTitle is false', () => {
psachmann marked this conversation as resolved.
Show resolved Hide resolved
describe('mapOrganizationToCard', () => {
describe('when organization is provided', () => {
const setup = () => setupOrganization();

it('should set the title to an empty string', () => {
it('should map organization to card', () => {
const { organization } = setup();

const result = sut.mapOrganizationToCard(organization, false);
const result = sut.mapOrganizationToCard(organization);

expect(result).toEqual({
title: '',
title: organization.title,
height: 150,
});
});
Expand All @@ -105,7 +105,7 @@ describe('CommonCartridgeImportMapper', () => {
const result = sut.mapOrganizationToTextElement(organization);

expect(result).toBeInstanceOf(RichTextContentBody);
expect(result).toEqual<RichTextContentBody>({
expect(result).toEqual({
text: `<b>${organization.title}</b>`,
inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
});
Expand Down Expand Up @@ -156,16 +156,15 @@ describe('CommonCartridgeImportMapper', () => {
it('should return rich text content element body', () => {
const resource: CommonCartridgeImportResourceProps = {
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
title: faker.lorem.words(3),
html: faker.lorem.paragraph(),
};

const result = sut.mapResourceToContentElementBody(resource);

expect(result).toBeInstanceOf(RichTextContentBody);
expect(result).toEqual<RichTextContentBody>({
inputFormat: InputFormat.RICH_TEXT_CK4,
text: resource.html,
inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AnyElementContentBody, ContentElementType, LinkContentBody, RichTextContentBody } from '@modules/board';
import { CardProps, ColumnProps } from '@modules/board/domain';
import {
CommonCartridgeImportResourceProps,
CommonCartridgeImportWebContentResourceProps,
Expand All @@ -11,17 +12,18 @@ import { InputFormat } from '@shared/domain/types';

@Injectable()
export class CommonCartridgeImportMapper {
public mapOrganizationToColumn(organization: CommonCartridgeOrganizationProps) {
return {
public mapOrganizationToColumn(organization: CommonCartridgeOrganizationProps): Partial<ColumnProps> {
const column = {
title: organization.title,
};

return column;
}

public mapOrganizationToCard(organization: CommonCartridgeOrganizationProps, withTitle = true) {
return {
title: withTitle ? organization.title : '',
height: 150,
};
public mapOrganizationToCard(organization: CommonCartridgeOrganizationProps, withTitle = true): Partial<CardProps> {
const card = { title: withTitle ? organization.title : '', height: 150 };

return card;
}

public mapOrganizationToTextElement(organization: CommonCartridgeOrganizationProps): AnyElementContentBody {
Expand Down Expand Up @@ -69,7 +71,7 @@ export class CommonCartridgeImportMapper {
const body = new RichTextContentBody();

body.text = resource.html;
body.inputFormat = InputFormat.RICH_TEXT_CK5_SIMPLE;
body.inputFormat = InputFormat.RICH_TEXT_CK4;

return body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ describe('CommonCartridgeImportService', () => {
const board2Title = '';
const board3Title = 'Spaltenboard 1';

const column1ofBoard1Title = 'Test Text';
const column1ofBoard2Title = 'Test Aufgabe';
const column1ofBoard3Title = 'Spalte 1';
const column2ofBoard3Title = 'Spalte 2';
const column3ofBoard3Title = 'Spalte 3';
const column4ofBoard3Title = 'Spalte 4';

const emptyCardTitle = '';
const card1Title = 'Karte 1';
const card2Title = 'Karte 2';
const card3Title = 'Karte 3';
const card4Title = 'Karte 4';

const columnPlaceholderTitle1 = '1';
const columnPlaceholderTitle2 = '2';

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
const objectContainingTitle = (title: string) => expect.objectContaining({ title });

Expand Down Expand Up @@ -122,27 +117,15 @@ describe('CommonCartridgeImportService', () => {

expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board1Title),
objectContainingTitle(column1ofBoard1Title)
objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board2Title),
objectContainingTitle(column1ofBoard2Title)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board3Title),
objectContainingTitle(column1ofBoard3Title)
objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board3Title),
objectContainingTitle(column2ofBoard3Title)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board3Title),
objectContainingTitle(column3ofBoard3Title)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board3Title),
objectContainingTitle(column4ofBoard3Title)
objectContainingTitle(columnPlaceholderTitle1)
);
});

Expand All @@ -154,28 +137,20 @@ describe('CommonCartridgeImportService', () => {
expect(spyBuildCard).toHaveBeenCalledTimes(6);

expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(column1ofBoard1Title),
objectContainingTitle(emptyCardTitle)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(column1ofBoard2Title),
objectContainingTitle(emptyCardTitle)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(column1ofBoard3Title),
objectContainingTitle(card1Title)
objectContainingTitle(board1Title),
objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(column2ofBoard3Title),
objectContainingTitle(card2Title)
objectContainingTitle(board2Title),
objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(column3ofBoard3Title),
objectContainingTitle(card3Title)
objectContainingTitle(board3Title),
objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(column4ofBoard3Title),
objectContainingTitle(card4Title)
objectContainingTitle(board3Title),
objectContainingTitle(columnPlaceholderTitle2)
);
});

Expand All @@ -186,10 +161,6 @@ describe('CommonCartridgeImportService', () => {

expect(spyBuildContentElement).toHaveBeenCalledTimes(6);

expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(emptyCardTitle),
expect.any(RichTextElement)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(card1Title),
expect.any(RichTextElement)
Expand All @@ -209,16 +180,16 @@ describe('CommonCartridgeImportService', () => {
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledTimes(6);

expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(RichTextElement), {
text: 'Test Text<p></p><p>Dies ist ein Textinhalt.</p><p></p>',
inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
text: '<h1>Test Text</h1><p></p><p>Dies ist ein Textinhalt.</p><p></p>',
inputFormat: InputFormat.RICH_TEXT_CK4,
});
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(RichTextElement), {
text: 'Test Aufgabe<p></p>',
inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
text: '<h1>Test Aufgabe</h1><p></p>',
inputFormat: InputFormat.RICH_TEXT_CK4,
});
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(RichTextElement), {
text: '<p></p><p>Karteninhalt von Karte 1</p><p></p>',
inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
inputFormat: InputFormat.RICH_TEXT_CK4,
});
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(LinkElement), {
title: 'Example Domain',
Expand Down
Loading
Loading