승인 단계 삭제 복구 흐름 구현하고 API 정렬 문서 추가
This commit is contained in:
@@ -221,4 +221,70 @@ void main() {
|
||||
expect(result, isNull);
|
||||
expect(controller.errorMessage, isNotNull);
|
||||
});
|
||||
|
||||
test('deleteStep 성공 시 단계가 비활성화된다', () async {
|
||||
when(
|
||||
() => repository.list(
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
query: any(named: 'query'),
|
||||
statusId: any(named: 'statusId'),
|
||||
approverId: any(named: 'approverId'),
|
||||
approvalId: any(named: 'approvalId'),
|
||||
),
|
||||
).thenAnswer((_) async => createResult([sampleRecord]));
|
||||
|
||||
when(() => repository.delete(any())).thenAnswer((_) async {});
|
||||
|
||||
await controller.fetch();
|
||||
|
||||
final success = await controller.deleteStep(sampleRecord.step.id!);
|
||||
|
||||
expect(success, isTrue);
|
||||
expect(controller.result?.items.first.step.isDeleted, isTrue);
|
||||
});
|
||||
|
||||
test('deleteStep 실패 시 false를 반환하고 에러를 기록한다', () async {
|
||||
when(() => repository.delete(any())).thenThrow(Exception('fail'));
|
||||
|
||||
final success = await controller.deleteStep(999);
|
||||
|
||||
expect(success, isFalse);
|
||||
expect(controller.errorMessage, isNotNull);
|
||||
});
|
||||
|
||||
test('restoreStep 성공 시 단계가 활성화된다', () async {
|
||||
final deletedRecord = sampleRecord.copyWith(
|
||||
step: sampleRecord.step.copyWith(isDeleted: true),
|
||||
);
|
||||
|
||||
when(
|
||||
() => repository.list(
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
query: any(named: 'query'),
|
||||
statusId: any(named: 'statusId'),
|
||||
approverId: any(named: 'approverId'),
|
||||
approvalId: any(named: 'approvalId'),
|
||||
),
|
||||
).thenAnswer((_) async => createResult([deletedRecord]));
|
||||
|
||||
when(() => repository.restore(any())).thenAnswer((_) async => sampleRecord);
|
||||
|
||||
await controller.fetch();
|
||||
|
||||
final restored = await controller.restoreStep(sampleRecord.step.id!);
|
||||
|
||||
expect(restored, isNotNull);
|
||||
expect(controller.result?.items.first.step.isDeleted, isFalse);
|
||||
});
|
||||
|
||||
test('restoreStep 실패 시 null을 반환하고 에러를 기록한다', () async {
|
||||
when(() => repository.restore(any())).thenThrow(Exception('fail'));
|
||||
|
||||
final restored = await controller.restoreStep(100);
|
||||
|
||||
expect(restored, isNull);
|
||||
expect(controller.errorMessage, isNotNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user