module OA
  class ApproveNewChecksPage < OA::BasePage
    page_url "/accounting/vendor_check_payable_tmp.php"

    table(:results, class: "data")
    button(:submit, value: "Update")
    div(:alert, class: "alertConfirm")

    def approve_single_check(check)
      expect(results_element.count).to eql 2
      row = results_element[1]
      verify_row(row, check)
      row.checkbox_element.click
    end

    def verify_row(row, check_data)
      expect(row["Label ID"].text).to eql check_data[:label_id]
      expect(row["Total Outstanding"].text.to_f).to be_within(0.10).of(check_data[:balance].delete("$").to_f)
    end

    def expect_success
      expect(alert).to include "Temp Check Payable updated successfully"
    end
  end
end
