diff --git a/BitwardenShared/Core/Autofill/Services/AutofillCredentialService+AppExtensionTests.swift b/BitwardenShared/Core/Autofill/Services/AutofillCredentialService+AppExtensionTests.swift index 6dfd913e5..951c275f8 100644 --- a/BitwardenShared/Core/Autofill/Services/AutofillCredentialService+AppExtensionTests.swift +++ b/BitwardenShared/Core/Autofill/Services/AutofillCredentialService+AppExtensionTests.swift @@ -153,10 +153,6 @@ class AutofillCredentialServiceAppExtensionTests: BitwardenTestCase { // swiftli prepareDataForIdentitiesReplacement() stateService.activeAccount = .fixture(profile: .fixture(userId: "1")) - try await waitForAsync { [weak self] in - guard let self else { return false } - return subject.hasCipherChangesSubscription - } credentialIdentityFactory.createCredentialIdentitiesMocker .withResult { cipher in if cipher.id == "3" { @@ -174,6 +170,11 @@ class AutofillCredentialServiceAppExtensionTests: BitwardenTestCase { // swiftli } } + try await waitForAsync { [weak self] in + guard let self else { return false } + return subject.hasCipherChangesSubscription + } + // Send an upserted cipher cipherService.cipherChangesSubject.send( .upserted(.fixture( diff --git a/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessor.swift b/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessor.swift index 9d00b90d2..07cf9f266 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessor.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessor.swift @@ -141,7 +141,10 @@ final class VaultGroupProcessor: StateProcessor< switch action { case let .addItemPressed(type): let type = type ?? CipherType(group: state.group) ?? .login - coordinator.navigate(to: .addItem(group: state.group, type: type)) + coordinator.navigate( + to: .addItem(group: state.group, type: type), + context: self, + ) case .clearURL: state.url = nil case let .copyTOTPCode(code): @@ -216,7 +219,10 @@ final class VaultGroupProcessor: StateProcessor< private func navigateToViewItem(cipherListView: CipherListView, id: String) { Task { await masterPasswordRepromptHelper.repromptForMasterPasswordIfNeeded(cipherListView: cipherListView) { - self.coordinator.navigate(to: .viewItem(id: id, masterPasswordRepromptCheckCompleted: true)) + self.coordinator.navigate( + to: .viewItem(id: id, masterPasswordRepromptCheckCompleted: true), + context: self, + ) } } } diff --git a/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessorTests.swift b/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessorTests.swift index fa17d5748..e7db8a975 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessorTests.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultGroup/VaultGroupProcessorTests.swift @@ -618,6 +618,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty subject.state.group = .card subject.receive(.addItemPressed(.card)) XCTAssertEqual(coordinator.routes.last, .addItem(group: .card, type: .card)) + XCTAssertTrue(coordinator.contexts.last is VaultGroupProcessor) } /// `receive(_:)` with `.addItemPressed` navigates to the `.addItem` route with the correct group. @@ -627,6 +628,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty subject.state.group = group subject.receive(.addItemPressed(nil)) XCTAssertEqual(coordinator.routes.last, .addItem(group: group, type: .login)) + XCTAssertTrue(coordinator.contexts.last is VaultGroupProcessor) } /// `receive(_:)` with `.addItemPressed` navigates to the `.addItem` route with an organization @@ -637,6 +639,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty subject.state.group = group subject.receive(.addItemPressed(.secureNote)) XCTAssertEqual(coordinator.routes.last, .addItem(group: group, type: .secureNote)) + XCTAssertTrue(coordinator.contexts.last is VaultGroupProcessor) } /// TOTP Code expiration updates the state's TOTP codes. @@ -837,6 +840,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty try await waitForAsync { !self.coordinator.routes.isEmpty } XCTAssertEqual(coordinator.routes.last, .viewItem(id: "id", masterPasswordRepromptCheckCompleted: true)) + XCTAssertTrue(coordinator.contexts.last is VaultGroupProcessor) XCTAssertEqual(masterPasswordRepromptHelper.repromptForMasterPasswordCipherListView, cipherListView) } @@ -880,6 +884,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty try await waitForAsync { !self.coordinator.routes.isEmpty } XCTAssertEqual(coordinator.routes.last, .viewItem(id: totpItem.id, masterPasswordRepromptCheckCompleted: true)) + XCTAssertTrue(coordinator.contexts.last is VaultGroupProcessor) XCTAssertEqual(masterPasswordRepromptHelper.repromptForMasterPasswordCipherListView, cipherListView) } diff --git a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessor.swift b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessor.swift index e776c0530..18ce1bfe6 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessor.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessor.swift @@ -208,9 +208,15 @@ extension VaultListProcessor { setProfileSwitcher(visible: false) switch state.vaultFilterType { case let .organization(organization): - coordinator.navigate(to: .addItem(organizationId: organization.id, type: type)) + coordinator.navigate( + to: .addItem(organizationId: organization.id, type: type), + context: self, + ) default: - coordinator.navigate(to: .addItem(type: type)) + coordinator.navigate( + to: .addItem(type: type), + context: self, + ) } reviewPromptTask?.cancel() } @@ -346,7 +352,10 @@ extension VaultListProcessor { private func navigateToViewItem(cipherListView: CipherListView, id: String) { Task { await masterPasswordRepromptHelper.repromptForMasterPasswordIfNeeded(cipherListView: cipherListView) { - self.coordinator.navigate(to: .viewItem(id: id, masterPasswordRepromptCheckCompleted: true)) + self.coordinator.navigate( + to: .viewItem(id: id, masterPasswordRepromptCheckCompleted: true), + context: self, + ) } } } diff --git a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessorTests.swift b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessorTests.swift index 7b84eae93..1de2d0363 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessorTests.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListProcessorTests.swift @@ -1791,6 +1791,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ subject.receive(.addItemPressed(.login)) XCTAssertEqual(coordinator.routes.last, .addItem(type: .login)) + XCTAssertTrue(coordinator.contexts.last is VaultListProcessor) } /// `receive(_:)` with `.addItemPressed` navigates to the `.addItem` route for a new secure note. @@ -1799,6 +1800,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ subject.receive(.addItemPressed(.secureNote)) XCTAssertEqual(coordinator.routes.last, .addItem(type: .secureNote)) + XCTAssertTrue(coordinator.contexts.last is VaultListProcessor) } /// `receive(_:)` with `.addItemPressed` hides the profile switcher view @@ -1829,6 +1831,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ subject.receive(.addItemPressed(.login)) XCTAssertEqual(coordinator.routes.last, .addItem(organizationId: "organization-1", type: .login)) + XCTAssertTrue(coordinator.contexts.last is VaultListProcessor) } /// `receive(_:)` with `.clearURL` clears the url in the state. @@ -1874,6 +1877,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ try await waitForAsync { !self.coordinator.routes.isEmpty } XCTAssertEqual(coordinator.routes.last, .viewItem(id: item.id, masterPasswordRepromptCheckCompleted: true)) + XCTAssertTrue(coordinator.contexts.last is VaultListProcessor) XCTAssertEqual(masterPasswordRepromptHelper.repromptForMasterPasswordCipherListView, cipherListView) } @@ -1918,6 +1922,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ try await waitForAsync { !self.coordinator.routes.isEmpty } XCTAssertEqual(coordinator.routes.last, .viewItem(id: "123", masterPasswordRepromptCheckCompleted: true)) + XCTAssertTrue(coordinator.contexts.last is VaultListProcessor) XCTAssertEqual(masterPasswordRepromptHelper.repromptForMasterPasswordCipherListView, cipherListView) }