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(); }