When(/^I delete a track from the release$/) do
  @tracks_before_delete = on(Workstation::ViewReleasePage).count_tracks_in_release
  # delete first track
  on(Workstation::ViewReleasePage).delete_first_track
end

When(/^I confirm I want to cancel deletion$/) do
  on(Workstation::ViewReleasePage).cancel_delete_element.when_present.element.click
end

Then(/^I should see that the track is still on the release$/) do
  actual = on(Workstation::ViewReleasePage).count_tracks_in_release
  expect(@tracks_before_delete).to eq(actual)
end

When(/^I confirm I want to delete the track$/) do
  on(Workstation::ViewReleasePage).confirm_delete_element.when_present.element.click
end

Then(/^I should see that the deleted track is no longer in the release$/) do
  final = on(Workstation::ViewReleasePage).count_tracks_in_release

  puts "Original number of tracks = #{@tracks_before_delete}"
  puts "Final number = #{final}"

  expect(final).to eq(@tracks_before_delete - 1)
end
