From f26302bfbe9392e0caad25fd3e5290c6622614b6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Jun 2025 13:35:42 +0200 Subject: [PATCH] Bug 40046: Use xml and auto-select it Absolutely no idea why the previous code was not selecting MARCXML (MARC was passed and so the import failed) cy.get('select[name="format"]') .select("MARCXML", { force: true }) .should("have.value", "MARCXML"); But I found a bug in the JS code: we are supposed to auto-detect .xml file and pre-select MARCXML. So let's rely on that behaviour! sample.mrc is actually an xml file so it makes sense to rename it --- .../prog/en/modules/tools/stage-marc-import.tt | 2 +- t/cypress/fixtures/{sample.mrc => sample.xml} | 0 t/cypress/integration/Tools/ManageMarcImport_spec.ts | 8 +++----- 3 files changed, 4 insertions(+), 6 deletions(-) rename t/cypress/fixtures/{sample.mrc => sample.xml} (100%) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt index d5ff4771b5f..e42fde81c6b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt @@ -471,7 +471,7 @@ $('#fileuploadbutton').show(); $("#fileuploadcancel").hide(); var filename=$('#fileToUpload').prop('files')[0].name; - if( filename.match( new RegExp(/\.[^.]+xml$/) ) ) { + if( filename.match( new RegExp(/[^.]+\.xml$/) ) ) { $('#format').val('MARCXML'); } $("#processfile").show(); diff --git a/t/cypress/fixtures/sample.mrc b/t/cypress/fixtures/sample.xml similarity index 100% rename from t/cypress/fixtures/sample.mrc rename to t/cypress/fixtures/sample.xml diff --git a/t/cypress/integration/Tools/ManageMarcImport_spec.ts b/t/cypress/integration/Tools/ManageMarcImport_spec.ts index f3483e6cfc5..e27f3cf9a1f 100644 --- a/t/cypress/integration/Tools/ManageMarcImport_spec.ts +++ b/t/cypress/integration/Tools/ManageMarcImport_spec.ts @@ -27,8 +27,8 @@ describe("loads the manage MARC import page", () => { it("upload a MARC record", () => { cy.visit("/cgi-bin/koha/tools/stage-marc-import.pl"); - cy.fixture("sample.mrc", null).as("sample_mrc"); - cy.get("input[type=file]").selectFile("@sample_mrc"); + cy.fixture("sample.xml", null).as("sample_xml"); + cy.get("input[type=file]").selectFile("@sample_xml"); cy.get("#fileuploadbutton").click(); cy.get("#fileuploadstatus").contains("100%"); @@ -51,9 +51,7 @@ describe("loads the manage MARC import page", () => { "always_add" ); - cy.get('select[name="format"]') - .select("MARCXML", { force: true }) - .should("have.value", "MARCXML"); + cy.get('select[name="format"]').should("have.value", "MARCXML"); //select some new options cy.get("#matcher").select("3", { force: true }); -- 2.34.1