From 890dce977b00ff4d1bf5f6851e2d951fe8d6576b Mon Sep 17 00:00:00 2001 From: Coalery Date: Sun, 10 Dec 2023 18:34:54 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B7=B8=EB=A3=B9=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20=EC=8B=9C=20=EC=A4=91=EB=8B=A8=20=EB=90=9C=20=EA=B7=B8?= =?UTF-8?q?=EB=A3=B9=EC=9D=84=20=EC=A7=84=ED=96=89=20=EC=A4=91=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/domain/group/model/Group.spec.ts | 35 +++++++++++++++++++++++- src/app/domain/group/model/Group.ts | 21 ++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/app/domain/group/model/Group.spec.ts b/src/app/domain/group/model/Group.spec.ts index 069c6ee..da1d6a0 100644 --- a/src/app/domain/group/model/Group.spec.ts +++ b/src/app/domain/group/model/Group.spec.ts @@ -1,8 +1,41 @@ -import { GroupState } from '@sight/app/domain/group/model/constant'; +import { + CUSTOMER_SERVICE_GROUP_ID, + GroupState, +} from '@sight/app/domain/group/model/constant'; import { DomainFixture } from '@sight/__test__/fixtures'; describe('Group', () => { + describe('wake', () => { + test('그룹이 중단되어 있다면 진행 상태로 변경해야 한다', () => { + const group = DomainFixture.generateGroup({ + state: GroupState.SUSPEND, + }); + + group.wake(); + + expect(group.state).toEqual(GroupState.PROGRESS); + }); + }); + + describe('isEditable', () => { + test('그룹이 종료된 상태라면 false를 반환해야 한다', () => { + const group = DomainFixture.generateGroup({ + state: GroupState.END_SUCCESS, + }); + + expect(group.isEditable()).toEqual(false); + }); + + test('고객센터 그룹이라면 false를 반환해야 한다', () => { + const group = DomainFixture.generateGroup({ + id: CUSTOMER_SERVICE_GROUP_ID, + }); + + expect(group.isEditable()).toEqual(false); + }); + }); + describe('isEnd', () => { test.each([GroupState.END_SUCCESS, GroupState.END_FAIL])( '그룹의 상태가 %s일 때, true를 반환해야 한다', diff --git a/src/app/domain/group/model/Group.ts b/src/app/domain/group/model/Group.ts index 2c4c62f..c2368c0 100644 --- a/src/app/domain/group/model/Group.ts +++ b/src/app/domain/group/model/Group.ts @@ -71,6 +71,8 @@ export class Group extends AggregateRoot { updateTitle(title: string): void { if (this._title !== title) { this._title = title; + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'title')); } } @@ -78,6 +80,8 @@ export class Group extends AggregateRoot { updatePurpose(purpose: string | null): void { if (this._purpose !== purpose) { this._purpose = purpose; + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'purpose')); } } @@ -85,6 +89,8 @@ export class Group extends AggregateRoot { updateInterestIds(interestIds: string[]): void { if (isDifferentStringArray(this._interestIds, interestIds)) { this._interestIds = Array.from(new Set(interestIds)); + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'interests')); } } @@ -92,6 +98,8 @@ export class Group extends AggregateRoot { updateTechnology(technology: string[]): void { if (isDifferentStringArray(this._technology, technology)) { this._technology = technology; + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'technology')); } } @@ -99,6 +107,7 @@ export class Group extends AggregateRoot { updateGrade(grade: GroupAccessGrade): void { if (this._grade !== grade) { this._grade = grade; + this.wake(); this.apply(new GroupUpdated(this.id, 'grade')); } } @@ -106,6 +115,8 @@ export class Group extends AggregateRoot { updateRepository(repository: string | null): void { if (this._repository !== repository) { this._repository = repository; + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'repository')); } } @@ -113,6 +124,8 @@ export class Group extends AggregateRoot { updateAllowJoin(allowJoin: boolean): void { if (this._allowJoin !== allowJoin) { this._allowJoin = allowJoin; + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'allowJoin')); } } @@ -120,10 +133,18 @@ export class Group extends AggregateRoot { updateCategory(category: GroupCategory): void { if (this._category !== category) { this._category = category; + this._updatedAt = new Date(); + this.wake(); this.apply(new GroupUpdated(this.id, 'category')); } } + wake(): void { + if (this._state === GroupState.SUSPEND) { + this._state = GroupState.PROGRESS; + } + } + isEditable(): boolean { return !this.isEnd() && !this.isCustomerServiceGroup(); }