germsvel / phoenix_test

MIT License
144 stars 20 forks source link

assert_path doesn't work with live navigation #62

Closed randycoulman closed 4 months ago

randycoulman commented 4 months ago

I've run into a few places where I've tried to use assert_path and it hasn't produced the results I've expected.

I can try to put together a reproducible example if that would help, but I think you'd be able to reproduce these results using a generated LiveView. Basically, anywhere the generated tests use assert_patch are places where assert_path would fail.

A few examples:

It looks like assert_path is using conn.request_path, but PhoenixTest's follow_redirect isn't actually updating and returning the conn, so the request_path doesn't change. Given that, I'm not sure what the best solution for this problem is, but it makes it so that assert_path is not usable with live navigation.

germsvel commented 4 months ago

Thanks @randycoulman! Yes, this makes sense. We're just relying on conn.request_path to get the "current" path. We'll have to update that to handle patches.