From e5a2de0b9b74764d9bc3effbeda510aa560297ea Mon Sep 17 00:00:00 2001 From: Artemida Date: Tue, 23 Apr 2024 15:09:02 +0200 Subject: [PATCH 1/5] BC-6832-Refactor-pipelines-to-include-Tldraw --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 32a20eac108..b9bb94aa0d6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -197,7 +197,7 @@ jobs: needs: - branch_meta - deploy - uses: hpi-schul-cloud/e2e-system-tests/.github/workflows/remote-trigger.yml@main + uses: hpi-schul-cloud/e2e-system-tests/.github/workflows/remote-trigger.yml@BC-6832-Refactor-pipelines-to-include-Tldraw with: ref: ${{ needs.branch_meta.outputs.branch }} secrets: From cbb4a1f27127f3df73d9bccde2ad2879f4256920 Mon Sep 17 00:00:00 2001 From: Artemida Date: Mon, 6 May 2024 20:03:56 +0200 Subject: [PATCH 2/5] BC-7165-Include tldraw to the quick links --- .../service/board-do-copy-service/recursive-copy.visitor.ts | 2 +- .../src/modules/copy-helper/service/copy-helper.service.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts b/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts index f8c00f4fdbd..212e07cc292 100644 --- a/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts +++ b/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts @@ -148,7 +148,7 @@ export class RecursiveCopyVisitor implements BoardCompositeVisitorAsync { this.resultMap.set(original.id, { copyEntity: copy, type: CopyElementType.DRAWING_ELEMENT, - status: CopyStatusEnum.SUCCESS, + status: CopyStatusEnum.PARTIAL, }); this.copyMap.set(original.id, copy); diff --git a/apps/server/src/modules/copy-helper/service/copy-helper.service.ts b/apps/server/src/modules/copy-helper/service/copy-helper.service.ts index b3a42dac7df..3a578c2618b 100644 --- a/apps/server/src/modules/copy-helper/service/copy-helper.service.ts +++ b/apps/server/src/modules/copy-helper/service/copy-helper.service.ts @@ -8,6 +8,12 @@ const isAtLeastPartialSuccessfull = (status) => status === CopyStatusEnum.PARTIA @Injectable() export class CopyHelperService { deriveStatusFromElements(elements: CopyStatus[]): CopyStatusEnum { + for (const element of elements) { + if (element.elements?.length) { + element.status = this.deriveStatusFromElements(element.elements); + } + } + const elementsStatuses = elements.map((el) => el.status); const filtered = elementsStatuses.filter((status) => status !== CopyStatusEnum.NOT_DOING); From 552ecd086b7e412eefe94c3aaf23005798d5f81f Mon Sep 17 00:00:00 2001 From: Artemida Date: Mon, 6 May 2024 20:10:41 +0200 Subject: [PATCH 3/5] change to main --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b9bb94aa0d6..32a20eac108 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -197,7 +197,7 @@ jobs: needs: - branch_meta - deploy - uses: hpi-schul-cloud/e2e-system-tests/.github/workflows/remote-trigger.yml@BC-6832-Refactor-pipelines-to-include-Tldraw + uses: hpi-schul-cloud/e2e-system-tests/.github/workflows/remote-trigger.yml@main with: ref: ${{ needs.branch_meta.outputs.branch }} secrets: From 3741e3f3a5ab4dc14bc77bfb33335f8efe0018eb Mon Sep 17 00:00:00 2001 From: Artemida Date: Wed, 8 May 2024 12:36:59 +0200 Subject: [PATCH 4/5] Add translate key for link --- .../board-do-copy-service/board-do-copy.service.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts index 0023ece7ad2..d3417a587cc 100644 --- a/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts +++ b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts @@ -511,12 +511,12 @@ describe('recursive board copy visitor', () => { expect(copy.id).not.toEqual(original.id); }); - it('should show status successful', async () => { + it('should show status partial', async () => { const { original, fileCopyService } = setup(); const result = await service.copy({ original, fileCopyService }); - expect(result.status).toEqual(CopyStatusEnum.SUCCESS); + expect(result.status).toEqual(CopyStatusEnum.PARTIAL); }); it('should show type RichTextElement', async () => { From 0f9732a069d600baae9179d37d0e8b22122c3578 Mon Sep 17 00:00:00 2001 From: Artemida Date: Wed, 8 May 2024 12:49:55 +0200 Subject: [PATCH 5/5] Add tests --- .../service/copy-helper.service.spec.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/apps/server/src/modules/copy-helper/service/copy-helper.service.spec.ts b/apps/server/src/modules/copy-helper/service/copy-helper.service.spec.ts index 337178ecbb8..fb44adb6e64 100644 --- a/apps/server/src/modules/copy-helper/service/copy-helper.service.spec.ts +++ b/apps/server/src/modules/copy-helper/service/copy-helper.service.spec.ts @@ -13,6 +13,21 @@ function createStates(elementStates: CopyStatusEnum[]): CopyStatus[] { return elementState; }); } +function createNestedStates(elementStates: CopyStatusEnum[]): CopyStatus { + const elementState = elementStates.shift(); + const element: CopyStatus = { + title: `title-${Math.floor(Math.random() * 1000)}-${elementStates.length}`, + type: CopyElementType.LEAF, + status: CopyStatusEnum.SUCCESS, + }; + + if (elementState) { + element.status = elementState; + element.elements = elementStates.length ? [createNestedStates(elementStates)] : []; + } + + return element; +} describe('copy helper service', () => { let module: TestingModule; @@ -35,6 +50,23 @@ describe('copy helper service', () => { }); describe('deriveStatusFromElements', () => { + describe('setup cases', () => { + it('should run method multiple times for nested structure', () => { + const derivedStatusSpy = jest.spyOn(copyHelperService, 'deriveStatusFromElements'); + const element = createNestedStates([ + CopyStatusEnum.SUCCESS, + CopyStatusEnum.SUCCESS, + CopyStatusEnum.SUCCESS, + CopyStatusEnum.SUCCESS, + ]); + + copyHelperService.deriveStatusFromElements([element]); + + expect(derivedStatusSpy).toHaveBeenCalledTimes(4); + derivedStatusSpy.mockRestore(); + }); + }); + describe('successful cases', () => { it('should return success, if no elements were given', () => { const derivedStatus = copyHelperService.deriveStatusFromElements([]); @@ -90,6 +122,17 @@ describe('copy helper service', () => { const elements = createStates([CopyStatusEnum.FAIL, CopyStatusEnum.NOT_DOING]); const derivedStatus = copyHelperService.deriveStatusFromElements(elements); + expect(derivedStatus).toEqual(CopyStatusEnum.FAIL); + }); + it('should return fail if the last and only nested child is FAIL ', () => { + const element = createNestedStates([ + CopyStatusEnum.SUCCESS, + CopyStatusEnum.SUCCESS, + CopyStatusEnum.SUCCESS, + CopyStatusEnum.FAIL, + ]); + const derivedStatus = copyHelperService.deriveStatusFromElements([element]); + expect(derivedStatus).toEqual(CopyStatusEnum.FAIL); }); });