Skip to content

Navigation destination help #368

@ifuller1

Description

@ifuller1

Hi,

Given this view body:

NavigationStack(path: $appPathPublisher.path) {
            LoginView(viewModel: LoginViewModel(dependencies: dependencies, flow: self))
                .navigationDestination(for: AuthNavigationPath.self) { currentStep in
                    switch currentStep {
                    case .login:
                        LoginView(viewModel: LoginViewModel(dependencies: dependencies, flow: self))
                    case let .verify(email, password, token):
                        VerifyEmailView(viewModel: VerifyEmailViewModel(
                            email: email,
                            password: password,
                            token: token,
                            dependencies: dependencies,
                            flow: self
                        )).navigationBarBackButtonHidden().navigationBarHidden(true)
                    case .forgotPassword:
                        Text("Forgot Password")
                            .navigationBarBackButtonHidden()
                            .navigationBarHidden(true)
                    }
                }
        }
        .onAppear { self.isReadyForViewTesting?(self) } // 2.

How can we find that the VerifyEmailView has been presented? Running the debugger I can see that the currentStep is indeed .verify and that the VerifyEmailView has been constructed but I cannot find the view e.g. this cannot find the navigationDestination modifier

                let exp = flow.on(\.isReadyForViewTesting) { view in
            let loginView = try view.find(LoginView.self)
            let firstElement = try try self.flow.inspect().implicitAnyView().navigationStack(0)
            let result = try loginView.navigationDestination()
            
            let verifyView = try firstElement.find(VerifyEmailView.self)

            XCTAssertNotNil(verifyView)
        }
        ViewHosting.host(view: flow)
        defer { ViewHosting.expel() }
        wait(for: [exp], timeout: 0.1)

Please can I get some pointers? Thanks in advanced!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions