Skip to content

Commit

Permalink
Add system spec for new bulk court dates
Browse files Browse the repository at this point in the history
  • Loading branch information
kcdragon committed Jul 30, 2023
1 parent b73746e commit cf4be91
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/factories/case_groups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :case_group do
name { "A family" }
end
end
44 changes: 44 additions & 0 deletions spec/system/bulk_court_dates/new_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "bulk_court_dates/new", type: :system do
let(:now) { Date.new(2021, 1, 1) }
let(:casa_org) { create(:casa_org) }
let(:admin) { create(:casa_admin, casa_org: casa_org) }
let!(:casa_case) { create(:casa_case, casa_org: casa_org) }
let!(:court_date) { create(:court_date, :with_court_details, casa_case: casa_case, date: now - 1.week) }
let!(:judge) { create(:judge) }
let!(:hearing_type) { create(:hearing_type) }
let(:court_order_text) { Faker::Lorem.paragraph(sentence_count: 2) }

it "is successful", js: true do
case_group = build(:case_group, casa_org: casa_org)
case_group.case_group_memberships.build(casa_case: casa_case)
case_group.save!

travel_to now
sign_in admin
visit casa_cases_path
click_on "New Bulk Court Date"

select case_group.name, from: "Case Group"
fill_in "court_date_date", with: :now
fill_in "court_date_court_report_due_date", with: :now
select judge.name, from: "Judge"
select hearing_type.name, from: "Hearing type"

click_on "Add a court order"
text_area = first(:css, "textarea").native
text_area.send_keys(court_order_text)
page.find("select.implementation-status").find(:option, text: "Partially implemented").select_option

within ".top-page-actions" do
click_on "Create"
end

visit casa_case_path(casa_case)
expect(page).to have_content(hearing_type.name)
expect(page).to have_content(court_order_text)
end
end

0 comments on commit cf4be91

Please sign in to comment.