Skip to content

Commit

Permalink
Add system spec
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Dec 18, 2024
1 parent d97b612 commit 2d9c156
Showing 1 changed file with 62 additions and 26 deletions.
88 changes: 62 additions & 26 deletions spec/system/admin/instrument_scheduling_tab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,47 +117,83 @@
login_as user
end

it "does not show discounts in index table" do
expect(instrument.schedule_rules).to_not be_empty
context do
it "does not show discounts in index table" do
expect(instrument.schedule_rules).to_not be_empty

visit facility_instrument_schedule_rules_path(facility, instrument)
visit facility_instrument_schedule_rules_path(facility, instrument)

expect(page).to_not have_content("Discount")
within("table") do
expect(page).to have_content("Days of Week")
expect(page).to_not have_content("Discount")
within("table") do
expect(page).to have_content("Days of Week")
end
end

it "works as expected on create" do
# Destroy other rules so we don't deal with conflicts
instrument.schedule_rules.destroy_all

visit new_facility_instrument_schedule_rule_path(facility, instrument)

expect(page).to_not have_content("Discount")

check("Tue")
click_button("Create")

expect(page).to have_content(I18n.t("controllers.schedule_rules.create"))
end
end

it "works as expected on create" do
# Destroy other rules so we don't deal with conflicts
instrument.schedule_rules.destroy_all
it "works as expected on edit" do
schedule_rule = instrument.schedule_rules.last
# Destroy other rules so we don't deal with conflicts
instrument.schedule_rules.where.not(id: schedule_rule.id).destroy_all

visit new_facility_instrument_schedule_rule_path(facility, instrument)
visit edit_facility_instrument_schedule_rule_path(facility, instrument, schedule_rule)

expect(page).to_not have_content("Discount")
expect(page).to_not have_content("Discount")

check("Tue")
click_button("Create")
check("Mon")
check("Tue")
check("Wed")

expect(page).to have_content(I18n.t("controllers.schedule_rules.create"))
expect(page).to have_field("schedule_rule[start_hour]")
expect(page).to have_field("schedule_rule[start_min]")
expect(page).to have_field("schedule_rule[end_hour]")
expect(page).to have_field("schedule_rule[end_min]")

click_button("Update")

expect(page).to have_content(I18n.t("controllers.schedule_rules.update"))
end
end

it "works as expected on edit" do
schedule_rule = instrument.schedule_rules.last
# Destroy other rules so we don't deal with conflicts
instrument.schedule_rules.where.not(id: schedule_rule.id).destroy_all
context "when instrument has fixed_start_time on" do
before do
instrument.update(fixed_start_time: true)
end

it "allows to select days but not time" do
schedule_rule = instrument.schedule_rules.last
# Destroy other rules so we don't deal with conflicts
instrument.schedule_rules.where.not(id: schedule_rule.id).destroy_all

visit edit_facility_instrument_schedule_rule_path(facility, instrument, schedule_rule)
visit edit_facility_instrument_schedule_rule_path(facility, instrument, schedule_rule)

expect(page).to_not have_content("Discount")
expect(page).to_not have_content("Discount")

check("Mon")
check("Tue")
check("Wed")
check("Mon")
check("Tue")
check("Wed")

click_button("Update")
expect(page).to have_field("schedule_rule[start_hour]", disabled: true)
expect(page).to have_field("schedule_rule[start_min]", disabled: true)
expect(page).to have_field("schedule_rule[end_hour]", disabled: true)
expect(page).to have_field("schedule_rule[end_min]", disabled: true)

expect(page).to have_content(I18n.t("controllers.schedule_rules.update"))
click_button("Update")

expect(page).to have_content(I18n.t("controllers.schedule_rules.update"))
end
end
end
end

0 comments on commit 2d9c156

Please sign in to comment.