From 7118e969aa782fa5f65fe0741bb8a6cae0e6f3dc Mon Sep 17 00:00:00 2001 From: opficdev Date: Thu, 23 Jul 2026 09:59:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Todo=20=EB=A7=88=EA=B0=90=EC=9D=BC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EC=97=AC=EB=B6=80=EB=A5=BC=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EB=8B=A8=EC=9C=84=EB=A1=9C=20=EB=B9=84=EA=B5=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Todo/Editor/TodoEditorFeature.swift | 8 ++++++- .../Tests/Todo/TodoEditorFeatureTests.swift | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Application/Presentation/PresentationShared/Sources/Todo/Editor/TodoEditorFeature.swift b/Application/Presentation/PresentationShared/Sources/Todo/Editor/TodoEditorFeature.swift index 17f60ea1..0436f7af 100644 --- a/Application/Presentation/PresentationShared/Sources/Todo/Editor/TodoEditorFeature.swift +++ b/Application/Presentation/PresentationShared/Sources/Todo/Editor/TodoEditorFeature.swift @@ -55,7 +55,13 @@ public struct TodoEditorFeature { } public var hasChanges: Bool { guard let originalDraft else { return true } - return originalDraft != makeTodoDraft(now: Date()) + var draft = makeTodoDraft(now: Date()) + if let originalDueDate = originalDraft.dueDate, + let dueDate = draft.dueDate, + Calendar.current.isDate(originalDueDate, inSameDayAs: dueDate) { + draft.dueDate = originalDueDate + } + return originalDraft != draft } public var isReadyToSubmit: Bool { isValidToSave && hasChanges diff --git a/Application/Presentation/PresentationShared/Tests/Todo/TodoEditorFeatureTests.swift b/Application/Presentation/PresentationShared/Tests/Todo/TodoEditorFeatureTests.swift index 27dfb63d..66fce96e 100644 --- a/Application/Presentation/PresentationShared/Tests/Todo/TodoEditorFeatureTests.swift +++ b/Application/Presentation/PresentationShared/Tests/Todo/TodoEditorFeatureTests.swift @@ -56,6 +56,27 @@ struct TodoEditorFeatureTests { #expect(adapter.isReadyToSubmit) } + @Test("마감일을 원본과 같은 날짜로 되돌리면 변경되지 않은 상태가 된다") + func 마감일을_원본과_같은_날짜로_되돌리면_변경되지_않은_상태가_된다() async throws { + let calendar = Calendar.current + let day = calendar.startOfDay(for: Date(timeIntervalSince1970: 4_102_444_800)) + let originalDueDate = day.addingTimeInterval(43_200) + let restoredDueDate = day.addingTimeInterval(3_600) + let changedDueDate = try #require(calendar.date(byAdding: .day, value: 1, to: originalDueDate)) + let todo = makeTodoEditorTodo(title: "Original", dueDate: originalDueDate) + let adapter = TodoEditorStoreTestAdapter(todo: todo) + + await adapter.setDueDate(changedDueDate) + + #expect(adapter.hasChanges) + #expect(adapter.isReadyToSubmit) + + await adapter.setDueDate(restoredDueDate) + + #expect(adapter.hasChanges == false) + #expect(adapter.isReadyToSubmit == false) + } + @Test("onAppear는 Todo 카테고리 설정을 가져와 상태에 반영한다") func onAppear는_Todo_카테고리_설정을_가져와_상태에_반영한다() async { let fetchSpy = TodoEditorFetchPreferencesUseCaseSpy(preferences: [