diff options
| author | Fuwn <[email protected]> | 2026-02-23 11:59:03 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-23 13:33:43 -0800 |
| commit | 382ab5439a45785997b058f5fb6662150e95e9cc (patch) | |
| tree | a3b2f5863b2e1716befb7f59c251077cce922320 | |
| parent | feat: mark context menu delete actions as destructive (diff) | |
| download | sora-testing-382ab5439a45785997b058f5fb6662150e95e9cc.tar.xz sora-testing-382ab5439a45785997b058f5fb6662150e95e9cc.zip | |
feat: mark remove-all alert actions as destructive
| -rw-r--r-- | Sora/Views/FavoritesView.swift | 2 | ||||
| -rw-r--r-- | Sora/Views/Generic/GenericListView.swift | 2 | ||||
| -rw-r--r-- | SoraTests/ViewDerivedDataTests.swift | 30 |
3 files changed, 32 insertions, 2 deletions
diff --git a/Sora/Views/FavoritesView.swift b/Sora/Views/FavoritesView.swift index 1ca41d0..3f12639 100644 --- a/Sora/Views/FavoritesView.swift +++ b/Sora/Views/FavoritesView.swift @@ -424,7 +424,7 @@ struct FavoritesView: View { // swiftlint:disable:this type_body_length "Are you sure you want to remove all favorites? This action cannot be undone.", isPresented: $isShowingRemoveAllConfirmation ) { - Button("Remove All Favorites") { + Button("Remove All Favorites", role: .destructive) { settings.favorites.removeAll() } diff --git a/Sora/Views/Generic/GenericListView.swift b/Sora/Views/Generic/GenericListView.swift index 476bbc1..accd816 100644 --- a/Sora/Views/Generic/GenericListView.swift +++ b/Sora/Views/Generic/GenericListView.swift @@ -432,7 +432,7 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View { removeAllMessage, isPresented: $isShowingRemoveAllConfirmation ) { - Button(removeAllButtonText) { + Button(removeAllButtonText, role: .destructive) { removeAllAction() } diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift index 32e9276..26410f8 100644 --- a/SoraTests/ViewDerivedDataTests.swift +++ b/SoraTests/ViewDerivedDataTests.swift @@ -397,6 +397,36 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b ) } + func testFavoritesRemoveAllAlertUsesDestructiveRole() throws { + let source = try loadSource(at: "Sora/Views/FavoritesView.swift") + let destructiveRemoveAllCount = tokenCount( + matching: #"Button\("Remove All Favorites",\s*role:\s*\.destructive\)"#, + in: source + ) + + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + destructiveRemoveAllCount, + 0, + "Favorites remove-all confirmation should mark the destructive action with role." + ) + } + + func testGenericListRemoveAllAlertUsesDestructiveRole() throws { + let source = try loadSource(at: "Sora/Views/Generic/GenericListView.swift") + let destructiveRemoveAllCount = tokenCount( + matching: #"Button\(removeAllButtonText,\s*role:\s*\.destructive\)"#, + in: source + ) + + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + destructiveRemoveAllCount, + 0, + "Generic list remove-all confirmation should mark the destructive action with role." + ) + } + func testListViewsAvoidComparatorRandomShuffleSorting() throws { let listViewSource = try loadSource(at: "Sora/Views/Generic/GenericListView.swift") let favoritesViewSource = try loadSource(at: "Sora/Views/FavoritesView.swift") |