Skip to content

Commit

Permalink
More debugging the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crmne committed Dec 28, 2024
1 parent 391e5f8 commit d25bd97
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/system/headache_logs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,39 @@ class HeadacheLogsTest < ApplicationSystemTestCase
test "marking ongoing headache as complete" do
# Create an ongoing headache log
log = headache_logs(:one)
log.update!(end_time: nil)
log.update(end_time: nil)

# Visit the headache logs page
visit headache_logs_url

# Verify we see the "Ongoing" status
assert_text "Ongoing"

# Click through to edit the log
# Click the "Update Log" button and wait for the page to load
click_on "Update Log"
assert_current_path edit_headache_log_path(log)

# Fill in all required fields, not just end_time
fill_in "Start Time", with: log.start_time.strftime("%Y-%m-%dT%H:%M")
fill_in "End Time", with: Time.current.strftime("%Y-%m-%dT%H:%M")
fill_in "Intensity", with: log.intensity
# Fill in the end time with the current time
end_time = headache_logs(:one).end_time
fill_in "End Time", with: end_time

# Debug output
puts "Form values before submission:"
puts "Start time: #{find_field('Start Time').value}"
puts "End time: #{find_field('End Time').value}"
puts "Intensity: #{find_field('Intensity').value}"

# Submit form and debug any validation errors
# Submit the form and wait for the update
click_button "Update Headache log"

if page.has_css?(".alert")
puts "Validation errors found:"
puts page.find(".alert").text
end

assert_current_path headache_log_path(log)
# Verify the success message and that "Ongoing" is no longer present
assert_text "Headache log was successfully updated"
assert_no_text "Ongoing Headache"
end

test "filtering headache logs" do
Expand Down

0 comments on commit d25bd97

Please sign in to comment.