mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
into its helper, which touches other system specs (namely orders_and_fulfillment_spec.rb). Rubocop fixup
37 lines
827 B
Ruby
37 lines
827 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ReportsHelper
|
|
def run_report
|
|
click_on "Go"
|
|
|
|
expect(page).to have_button "Go", disabled: true
|
|
expect(page).to have_selector ".loading"
|
|
|
|
perform_enqueued_jobs(only: ReportJob)
|
|
|
|
expect(page).not_to have_selector ".loading"
|
|
expect(page).to have_button "Go", disabled: false
|
|
end
|
|
|
|
def generate_report
|
|
run_report
|
|
click_on "Download Report"
|
|
wait_for_download
|
|
end
|
|
|
|
def load_file_txt(extension, downloaded_filename)
|
|
case extension
|
|
when "csv"
|
|
CSV.read(downloaded_filename).join(" ")
|
|
when "xlsx"
|
|
xlsx = Roo::Excelx.new(downloaded_filename)
|
|
xlsx.map(&:to_a).join(" ")
|
|
end
|
|
end
|
|
|
|
def table_headers
|
|
rows = find("table.report__table").all("thead tr")
|
|
rows.map { |r| r.all("th").map { |c| c.text.strip } }
|
|
end
|
|
end
|