From fd54a12bcb484a9e0882d37cbadf8c40338f3153 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 11 Apr 2024 12:36:47 +0100 Subject: [PATCH] Moves methods to end of the file --- spec/system/admin/orders_spec.rb | 53 ++++++++++++++++---------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index d8befcb8d4..d7b4ca715f 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -574,33 +574,6 @@ describe ' end context "can bulk print invoices" do - def extract_pdf_content - # Extract last part of invoice URL - link = page.find(class: "button", text: "VIEW FILE") - filename = link[:href].match %r{/invoices/.*} - - # Load invoice temp file directly instead of downloading - reader = PDF::Reader.new("tmp/#{filename}.pdf") - reader.pages.map(&:text) - end - - def print_all_invoices - page.find("span.icon-reorder", text: "ACTIONS").click - within ".ofn-drop-down .menu" do - expect { - page.find("span", text: "Print Invoices").click # Prints invoices in bulk - }.to enqueue_job(BulkInvoiceJob).exactly(:once) - end - - expect(page).to have_content "Compiling Invoices" - expect(page).to have_content "Please wait until the PDF is ready " \ - "before closing this modal." - - perform_enqueued_jobs(only: BulkInvoiceJob) - - expect(page).to have_content "Bulk Invoice created" - end - let(:order4_selector){ "#order_#{order4.id} input[name='bulk_ids[]']" } let(:order5_selector){ "#order_#{order5.id} input[name='bulk_ids[]']" } @@ -1158,4 +1131,30 @@ describe ' expect(find("input.datepicker").value).to be_empty end end + def extract_pdf_content + # Extract last part of invoice URL + link = page.find(class: "button", text: "VIEW FILE") + filename = link[:href].match %r{/invoices/.*} + + # Load invoice temp file directly instead of downloading + reader = PDF::Reader.new("tmp/#{filename}.pdf") + reader.pages.map(&:text) + end + + def print_all_invoices + page.find("span.icon-reorder", text: "ACTIONS").click + within ".ofn-drop-down .menu" do + expect { + page.find("span", text: "Print Invoices").click # Prints invoices in bulk + }.to enqueue_job(BulkInvoiceJob).exactly(:once) + end + + expect(page).to have_content "Compiling Invoices" + expect(page).to have_content "Please wait until the PDF is ready " \ + "before closing this modal." + + perform_enqueued_jobs(only: BulkInvoiceJob) + + expect(page).to have_content "Bulk Invoice created" + end end