Tests failing in 1.6.0-rc

Version 1.6.0-rc.5

A test that used to pass now fails since upgrading to v1.6.0-rc

The issue appears to be that you’re using inline mode with a workflow. There isn’t a Context module to run, it’s just a container that’s inserted in the completed state.

Is there a way to solve this without large test rewrites?

I have a lot of E2E style tests where some interaction might trigger an oban workflow, but I haven’t been interacting with Oban in the tests because I assume it was in “inline” mode

Cascading workflows and context can’t work with inline mode because there’s nothing to persist. The job never touches the database, which makes dependency resolution and fetching context impossible.

You can disable inline mode in your test and use run_workflow locally:

Oban.Testing.with_testing_mode(:manual, fn ->
  # build and run workflow here
end)

So, I can no longer do E2E tests that trigger Oban Workflows from UI interactions?

I have tests that basically walk through this whole UI flow that at some point triggers an Oban Workflow. These tests are failing now that I’ve added the v1.6 features.

See video:

Sure you can, just not with inline testing mode. Workflows would have only worked coincidentally in inline mode before, regardless of the Pro version.

There are a few common ways to do E2E tests:

  1. Use drain_jobs to execute the jobs manually. Make assertions that the jobs drained at that point.
  2. Start another instance with start_supervised_oban that’s not in testing mode and let it run the jobs automatically. This requires a little more effort to share the instance name in your app and test code, but it’s an option.
2 Likes