|
| 1 | +require_relative "../application_system_test_case" |
| 2 | + |
| 3 | +class BlockedJobsTest < ApplicationSystemTestCase |
| 4 | + setup do |
| 5 | + # Find a SolidQueue server to use for this test |
| 6 | + @solid_queue_server = MissionControl::Jobs.applications.first.servers.find { |s| s.queue_adapter_name == :solid_queue } |
| 7 | + |
| 8 | + # Skip if SolidQueue is not available |
| 9 | + skip "SolidQueue adapter not available for testing" unless @solid_queue_server |
| 10 | + |
| 11 | + # Use the SolidQueue server's activating method to switch adapters temporarily |
| 12 | + @solid_queue_server.activating do |
| 13 | + # Create jobs with SolidQueue adapter |
| 14 | + BlockingJob.perform_later(10) |
| 15 | + BlockingJob.perform_later(20) |
| 16 | + |
| 17 | + # Get the last job |
| 18 | + job = ActiveJob.jobs.blocked.last |
| 19 | + |
| 20 | + # Make sure the job has nil blocked_until |
| 21 | + if job.respond_to?(:blocked_execution) && job.blocked_execution |
| 22 | + job.blocked_execution.update!(expires_at: nil) |
| 23 | + end |
| 24 | + end |
| 25 | + |
| 26 | + # Visit the blocked jobs page with SolidQueue active |
| 27 | + @solid_queue_server.activating do |
| 28 | + visit jobs_path(:blocked) |
| 29 | + end |
| 30 | + end |
| 31 | + |
| 32 | + test "displays blocked jobs with expiration date" do |
| 33 | + @solid_queue_server.activating do |
| 34 | + assert_text "10" |
| 35 | + assert_text "Expires" |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + test "displays blocked jobs without expiration date" do |
| 40 | + @solid_queue_server.activating do |
| 41 | + assert_text "20" |
| 42 | + |
| 43 | + within_job_row "20" do |
| 44 | + # The expiration message should be empty when blocked_until is nil |
| 45 | + assert page.has_selector?(".has-text-grey.is-size-7", text: "") |
| 46 | + end |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + test "run now button works for blocked jobs" do |
| 51 | + @solid_queue_server.activating do |
| 52 | + assert_equal 2, job_row_elements.length |
| 53 | + |
| 54 | + within_job_row "10" do |
| 55 | + click_on "Run now" |
| 56 | + end |
| 57 | + |
| 58 | + assert_text "Dispatched" |
| 59 | + assert_equal 1, job_row_elements.length |
| 60 | + end |
| 61 | + end |
| 62 | +end |
0 commit comments