Skip to content

Commit

Permalink
fix: 그룹 수정 시 중단 된 그룹을 진행 중으로 변경하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Coalery committed Dec 10, 2023
1 parent 9622f86 commit 890dce9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/app/domain/group/model/Group.spec.ts
Original file line number Diff line number Diff line change
@@ -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를 반환해야 한다',
Expand Down
21 changes: 21 additions & 0 deletions src/app/domain/group/model/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,59 +71,80 @@ 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'));
}
}

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

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

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

updateGrade(grade: GroupAccessGrade): void {
if (this._grade !== grade) {
this._grade = grade;
this.wake();
this.apply(new GroupUpdated(this.id, 'grade'));
}
}

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

updateAllowJoin(allowJoin: boolean): void {
if (this._allowJoin !== allowJoin) {
this._allowJoin = allowJoin;
this._updatedAt = new Date();
this.wake();
this.apply(new GroupUpdated(this.id, 'allowJoin'));
}
}

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

0 comments on commit 890dce9

Please sign in to comment.