From fe8b5697530c2cf0bf0c1ddfda94850927dc7bdd Mon Sep 17 00:00:00 2001 From: Christophe Vila Date: Sat, 19 Sep 2026 16:59:37 +0200 Subject: [PATCH] test: add edge case coverage for nonexistent groupId in GroupSelection Verify that subtreeIds returns empty set and toggling returns current unchanged when groupId is not found in the tree. Co-Authored-By: Claude Haiku 4.5 Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf --- .../MyPassCoreTests/GroupSelectionTests.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MyPassCore/Tests/MyPassCoreTests/GroupSelectionTests.swift b/MyPassCore/Tests/MyPassCoreTests/GroupSelectionTests.swift index b5c5a84..ded5ef2 100644 --- a/MyPassCore/Tests/MyPassCoreTests/GroupSelectionTests.swift +++ b/MyPassCore/Tests/MyPassCoreTests/GroupSelectionTests.swift @@ -39,4 +39,19 @@ final class GroupSelectionTests: XCTestCase { let result = GroupSelection.toggling(work.id, in: root, current: [personal.id]) XCTAssertEqual(result, [personal.id, work.id, email.id]) } + + func test_subtreeIds_groupNotFound_returnsEmptySet() { + let (root, _, _, _) = makeSampleTree() + let nonExistentId = UUID() + let ids = GroupSelection.subtreeIds(of: nonExistentId, in: root) + XCTAssertEqual(ids, []) + } + + func test_toggling_groupNotFound_returnsCurrentUnchanged() { + let (root, _, _, personal) = makeSampleTree() + let nonExistentId = UUID() + let current: Set = [personal.id] + let result = GroupSelection.toggling(nonExistentId, in: root, current: current) + XCTAssertEqual(result, current) + } }