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

tests[Op#52098]: separate regular vs direct uploads in shared examples

Kabiru Mwenja94e3fa227bc2
diff --git a/modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb b/modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb
index f6e7a9c0be2..cbc2a5a1b98 100644
--- a/modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb
+++ b/modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb
@@ -33,5 +33,21 @@ RSpec.describe "direct IFC upload", :js, with_config: { edition: "bim" }, with_d
it_behaves_like "can upload an IFC file" do
# with direct upload, we don't get the model name
let(:model_name) { "model.ifc" }
+
+ context "when the file size exceeds the allowed maximum", with_settings: { attachment_max_size: 1 } do
+ it "invalidates the form via JavaScript preventing submission" do
+ visit new_bcf_project_ifc_model_path(project_id: project.identifier)
+
+ page.attach_file("file", ifc_fixture.path, visible: :all)
+
+ form_validity = page.evaluate_script <<~JS
+ document
+ .querySelector('#new_bim_ifc_models_ifc_model')
+ .checkValidity();
+ JS
+
+ expect(form_validity).to be(false)
+ end
+ end
end
end
diff --git a/modules/bim/spec/features/ifc_models/ifc_upload_shared_examples.rb b/modules/bim/spec/features/ifc_models/ifc_upload_shared_examples.rb
index 6b3ad8df9a0..14bf5cb68a1 100644
--- a/modules/bim/spec/features/ifc_models/ifc_upload_shared_examples.rb
+++ b/modules/bim/spec/features/ifc_models/ifc_upload_shared_examples.rb
@@ -40,21 +40,4 @@ RSpec.shared_examples "can upload an IFC file" do
context "when setting checkbox is_default after selecting file" do
it_behaves_like "allows uploading an IFC file"
end
-
- context "when the file size exceeds the allowed maximum", with_settings: { attachment_max_size: 1 } do
- it "displays an error message" do
- visit new_bcf_project_ifc_model_path(project_id: project.identifier)
-
- page.find_by_id("bim_ifc_models_ifc_model_is_default").set(true) unless set_tick_is_default_after_file
- page.attach_file("file", ifc_fixture.path, visible: :all)
- page.find_by_id("bim_ifc_models_ifc_model_is_default").set true if set_tick_is_default_after_file
-
- form_validity = page.evaluate_script <<~JS
- document
- .querySelector('#new_bim_ifc_models_ifc_model')
- .checkValidity()
- JS
- expect(form_validity).to be(false)
- end
- end
end
diff --git a/modules/bim/spec/features/ifc_models/regular_ifc_upload_spec.rb b/modules/bim/spec/features/ifc_models/regular_ifc_upload_spec.rb
index e9ceec4c3ec..a7b6678e320 100644
--- a/modules/bim/spec/features/ifc_models/regular_ifc_upload_spec.rb
+++ b/modules/bim/spec/features/ifc_models/regular_ifc_upload_spec.rb
@@ -32,5 +32,17 @@ require_relative "ifc_upload_shared_examples"
RSpec.describe "IFC upload", :js, with_config: { edition: "bim" } do
it_behaves_like "can upload an IFC file" do
let(:model_name) { "minimal.ifc" }
+
+ context "when the file size exceeds the allowed maximum", with_settings: { attachment_max_size: 1 } do
+ it "renders an error message" do
+ visit new_bcf_project_ifc_model_path(project_id: project.identifier)
+
+ page.attach_file("file", ifc_fixture.path, visible: :all)
+
+ click_on "Create"
+
+ expect(page).to have_content("IFC file is too large (maximum size is 1024 Bytes).")
+ end
+ end
end
end