Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

move spec to cuprite

ulfertse87127b732b5
diff --git a/modules/reporting/spec/features/export_timesheet_spec.rb b/modules/reporting/spec/features/export_timesheet_spec.rb
index 347b0412f5b..bc783d8a4a7 100644
--- a/modules/reporting/spec/features/export_timesheet_spec.rb
+++ b/modules/reporting/spec/features/export_timesheet_spec.rb
@@ -29,7 +29,7 @@
require_relative "../spec_helper"
require_relative "support/pages/cost_report_page"
-RSpec.describe "Timesheet PDF export", :js, :selenium do
+RSpec.describe "Timesheet PDF export", :js do
shared_let(:project) { create(:project) }
shared_let(:user) { create(:admin) }
shared_let(:cost_type) { create(:cost_type, name: "Post-war", unit: "cap", unit_plural: "caps") }
@@ -37,28 +37,25 @@ RSpec.describe "Timesheet PDF export", :js, :selenium do
shared_let(:cost_entry) { create(:cost_entry, user:, work_package:, project:, cost_type:) }
let(:report_page) { Pages::CostReportPage.new project }
- subject { @download_list.refresh_from(page).latest_download.to_s } # rubocop:disable RSpec/InstanceVariable
-
- before do
- @download_list = DownloadList.new
- login_as(user)
- end
-
- after do
- DownloadList.clear
- end
+ current_user { user }
it "can download the PDF" do
report_page.visit!
- click_on I18n.t("export.timesheet.button")
- expect(page).to have_content I18n.t("job_status_dialog.generic_messages.in_queue"),
- wait: 10
- perform_enqueued_jobs
+ # The export opens a new tab with the result
+ new_window = window_opened_by do
+ click_on I18n.t("export.timesheet.button")
+
+ expect(page).to have_content I18n.t("job_status_dialog.generic_messages.in_queue")
+
+ perform_enqueued_jobs
- expect(page).to have_text(I18n.t("export.succeeded"),
- wait: 10)
+ expect(page).to have_text(I18n.t("export.succeeded"))
+ end
- expect(subject).to have_text(".pdf")
+ # Switching to that tab and checking that the content is a PDF
+ within_window new_window do
+ expect(page.source).to have_css("[type='application/pdf']")
+ end
end
end