mirror of
https://github.com/bitwarden/ios.git
synced 2026-02-04 02:14:09 -06:00
[PM-31178] feat: Archive remove confirmation and update localizations (#2281)
This commit is contained in:
parent
30a494b5c5
commit
f620aa5f82
@ -1286,12 +1286,10 @@
|
||||
"Archive" = "Archive";
|
||||
"Archived" = "Archived";
|
||||
"Unarchive" = "Unarchive";
|
||||
"ItemMovedToArchive" = "Item moved to Archive";
|
||||
"ItemUnarchived" = "Item unarchived";
|
||||
"ItemMovedToArchive" = "Item moved to archive";
|
||||
"ItemMovedToVault" = "Item moved to vault";
|
||||
"SendingToArchive" = "Sending to archive…";
|
||||
"Unarchiving" = "Unarchiving…";
|
||||
"DoYouReallyWantToUnarchiveThisItem" = "Do you really want to unarchive this item?";
|
||||
"DoYouReallyWantToArchiveThisItem" = "Do you really want to archive this item?";
|
||||
"MovingItemToVault" = "Moving item to vault";
|
||||
"OrganizationNotFound" = "Organization not found.";
|
||||
"ItemsTransferred" = "Items transferred";
|
||||
"ArchiveIsEmpty" = "Archive is empty";
|
||||
|
||||
@ -227,8 +227,8 @@ class DefaultVaultItemMoreOptionsHelper: VaultItemMoreOptionsHelper {
|
||||
case let .unarchive(cipher):
|
||||
await performOperationAndShowToast(
|
||||
handleDisplayToast: handleDisplayToast,
|
||||
loadingTitle: Localizations.unarchiving,
|
||||
toastTitle: Localizations.itemUnarchived,
|
||||
loadingTitle: Localizations.movingItemToVault,
|
||||
toastTitle: Localizations.itemMovedToVault,
|
||||
) {
|
||||
try await services.vaultRepository.unarchiveCipher(cipher)
|
||||
}
|
||||
|
||||
@ -746,9 +746,9 @@ class VaultItemMoreOptionsHelperTests: BitwardenTestCase { // swiftlint:disable:
|
||||
vaultRepository.unarchiveCipherResult = .success(())
|
||||
try await optionsAlert.tapAction(title: Localizations.unarchive)
|
||||
|
||||
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.unarchiving)
|
||||
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.movingItemToVault)
|
||||
XCTAssertEqual(vaultRepository.unarchiveCipher, [cipherView])
|
||||
XCTAssertEqual(toastToDisplay, Toast(title: Localizations.itemUnarchived))
|
||||
XCTAssertEqual(toastToDisplay, Toast(title: Localizations.itemMovedToVault))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -346,7 +346,7 @@ extension VaultGroupProcessor: CipherItemOperationDelegate {
|
||||
}
|
||||
|
||||
func itemUnarchived() {
|
||||
displayToastAndRefresh(toastTitle: Localizations.itemUnarchived)
|
||||
displayToastAndRefresh(toastTitle: Localizations.itemMovedToVault)
|
||||
}
|
||||
|
||||
// MARK: Private methods
|
||||
|
||||
@ -144,7 +144,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
XCTAssertNil(subject.state.toast)
|
||||
|
||||
subject.itemUnarchived()
|
||||
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemUnarchived))
|
||||
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemMovedToVault))
|
||||
waitFor(vaultRepository.fetchSyncCalled)
|
||||
}
|
||||
|
||||
|
||||
@ -137,28 +137,28 @@ class VaultGroupStateTests: BitwardenTestCase {
|
||||
let subjectNoPremiumArchive = VaultGroupState(
|
||||
group: .archive,
|
||||
hasPremium: false,
|
||||
vaultFilterType: .myVault
|
||||
vaultFilterType: .myVault,
|
||||
)
|
||||
XCTAssertTrue(subjectNoPremiumArchive.showArchivePremiumSubscriptionEndedCard)
|
||||
|
||||
let subjectHasPremiumArchive = VaultGroupState(
|
||||
group: .archive,
|
||||
hasPremium: true,
|
||||
vaultFilterType: .myVault
|
||||
vaultFilterType: .myVault,
|
||||
)
|
||||
XCTAssertFalse(subjectHasPremiumArchive.showArchivePremiumSubscriptionEndedCard)
|
||||
|
||||
let subjectNoPremiumLogin = VaultGroupState(
|
||||
group: .login,
|
||||
hasPremium: false,
|
||||
vaultFilterType: .myVault
|
||||
vaultFilterType: .myVault,
|
||||
)
|
||||
XCTAssertFalse(subjectNoPremiumLogin.showArchivePremiumSubscriptionEndedCard)
|
||||
|
||||
let subjectHasPremiumLogin = VaultGroupState(
|
||||
group: .login,
|
||||
hasPremium: true,
|
||||
vaultFilterType: .myVault
|
||||
vaultFilterType: .myVault,
|
||||
)
|
||||
XCTAssertFalse(subjectHasPremiumLogin.showArchivePremiumSubscriptionEndedCard)
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ extension VaultListProcessor: CipherItemOperationDelegate {
|
||||
}
|
||||
|
||||
func itemUnarchived() {
|
||||
state.toast = Toast(title: Localizations.itemUnarchived)
|
||||
state.toast = Toast(title: Localizations.itemMovedToVault)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ
|
||||
XCTAssertNil(subject.state.toast)
|
||||
|
||||
subject.itemUnarchived()
|
||||
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemUnarchived))
|
||||
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemMovedToVault))
|
||||
}
|
||||
|
||||
/// `init()` has default values set in the state.
|
||||
|
||||
@ -77,36 +77,26 @@ class DefaultVaultItemActionHelper: VaultItemActionHelper {
|
||||
return
|
||||
}
|
||||
|
||||
let alert = Alert.confirmation(title: Localizations.doYouReallyWantToArchiveThisItem) { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
await performOperation(
|
||||
loadingTitle: Localizations.sendingToArchive,
|
||||
operation: {
|
||||
try await self.services.vaultRepository.archiveCipher(cipher)
|
||||
},
|
||||
completionHandler: completionHandler,
|
||||
)
|
||||
}
|
||||
await coordinator.showAlert(alert)
|
||||
await performOperation(
|
||||
loadingTitle: Localizations.sendingToArchive,
|
||||
operation: {
|
||||
try await self.services.vaultRepository.archiveCipher(cipher)
|
||||
},
|
||||
completionHandler: completionHandler,
|
||||
)
|
||||
}
|
||||
|
||||
func unarchive(
|
||||
cipher: CipherView,
|
||||
completionHandler: @escaping () -> Void,
|
||||
) async {
|
||||
let alert = Alert.confirmation(title: Localizations.doYouReallyWantToUnarchiveThisItem) { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
await performOperation(
|
||||
loadingTitle: Localizations.unarchiving,
|
||||
operation: {
|
||||
try await self.services.vaultRepository.unarchiveCipher(cipher)
|
||||
},
|
||||
completionHandler: completionHandler,
|
||||
)
|
||||
}
|
||||
await coordinator.showAlert(alert)
|
||||
await performOperation(
|
||||
loadingTitle: Localizations.movingItemToVault,
|
||||
operation: {
|
||||
try await self.services.vaultRepository.unarchiveCipher(cipher)
|
||||
},
|
||||
completionHandler: completionHandler,
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: Private methods
|
||||
|
||||
@ -98,11 +98,6 @@ class VaultItemActionHelperTests: BitwardenTestCase {
|
||||
completionHandler: { completionCalled = true },
|
||||
)
|
||||
|
||||
let alert = coordinator.alertShown.last
|
||||
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToArchiveThisItem)
|
||||
|
||||
try await alert?.tapAction(title: Localizations.yes)
|
||||
|
||||
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.sendingToArchive)
|
||||
|
||||
XCTAssertEqual(vaultRepository.archiveCipher.last?.id, "123")
|
||||
@ -125,41 +120,11 @@ class VaultItemActionHelperTests: BitwardenTestCase {
|
||||
completionHandler: { completionCalled = true },
|
||||
)
|
||||
|
||||
let alert = coordinator.alertShown.last
|
||||
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToArchiveThisItem)
|
||||
|
||||
try await alert?.tapAction(title: Localizations.yes)
|
||||
|
||||
XCTAssertEqual(coordinator.errorAlertsShown.count, 1)
|
||||
XCTAssertEqual(errorReporter.errors as? [BitwardenTestError], [.example])
|
||||
XCTAssertFalse(completionCalled)
|
||||
}
|
||||
|
||||
/// `archive(cipher:handleOpenURL:completionHandler:)` does not archive when the user cancels
|
||||
/// the confirmation alert.
|
||||
@MainActor
|
||||
func test_archive_cancel() async throws {
|
||||
var completionCalled = false
|
||||
let cipher = CipherView.loginFixture(id: "123")
|
||||
|
||||
vaultRepository.doesActiveAccountHavePremiumResult = true
|
||||
vaultRepository.archiveCipherResult = .success(())
|
||||
|
||||
await subject.archive(
|
||||
cipher: cipher,
|
||||
handleOpenURL: { _ in },
|
||||
completionHandler: { completionCalled = true },
|
||||
)
|
||||
|
||||
let alert = coordinator.alertShown.last
|
||||
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToArchiveThisItem)
|
||||
|
||||
try await alert?.tapCancel()
|
||||
|
||||
XCTAssertTrue(vaultRepository.archiveCipher.isEmpty)
|
||||
XCTAssertFalse(completionCalled)
|
||||
}
|
||||
|
||||
/// `unarchive(cipher:completionHandler:)` shows the confirmation alert and unarchives
|
||||
/// the cipher when the user confirms.
|
||||
@MainActor
|
||||
@ -174,13 +139,7 @@ class VaultItemActionHelperTests: BitwardenTestCase {
|
||||
completionHandler: { completionCalled = true },
|
||||
)
|
||||
|
||||
let alert = coordinator.alertShown.last
|
||||
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToUnarchiveThisItem)
|
||||
XCTAssertNil(alert?.message)
|
||||
|
||||
try await alert?.tapAction(title: Localizations.yes)
|
||||
|
||||
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.unarchiving)
|
||||
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.movingItemToVault)
|
||||
|
||||
XCTAssertEqual(vaultRepository.unarchiveCipher.last?.id, "123")
|
||||
XCTAssertTrue(completionCalled)
|
||||
@ -200,36 +159,8 @@ class VaultItemActionHelperTests: BitwardenTestCase {
|
||||
completionHandler: { completionCalled = true },
|
||||
)
|
||||
|
||||
let alert = coordinator.alertShown.last
|
||||
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToUnarchiveThisItem)
|
||||
|
||||
try await alert?.tapAction(title: Localizations.yes)
|
||||
|
||||
XCTAssertEqual(coordinator.errorAlertsShown.count, 1)
|
||||
XCTAssertEqual(errorReporter.errors as? [BitwardenTestError], [.example])
|
||||
XCTAssertFalse(completionCalled)
|
||||
}
|
||||
|
||||
/// `unarchive(cipher:completionHandler:)` does not unarchive when the user cancels
|
||||
/// the confirmation alert.
|
||||
@MainActor
|
||||
func test_unarchive_cancel() async throws {
|
||||
var completionCalled = false
|
||||
let cipher = CipherView.loginFixture(archivedDate: .now, id: "123")
|
||||
|
||||
vaultRepository.unarchiveCipherResult = .success(())
|
||||
|
||||
await subject.unarchive(
|
||||
cipher: cipher,
|
||||
completionHandler: { completionCalled = true },
|
||||
)
|
||||
|
||||
let alert = coordinator.alertShown.last
|
||||
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToUnarchiveThisItem)
|
||||
|
||||
try await alert?.tapCancel()
|
||||
|
||||
XCTAssertTrue(vaultRepository.unarchiveCipher.isEmpty)
|
||||
XCTAssertFalse(completionCalled)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user