From a7e390dc3629a558808a638c05e030872557b762 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 10 Apr 2025 22:07:10 +0000 Subject: [PATCH] Bug 39606: Add a cypress test To test: 1. APPLY PATCH 2. cypress run --spec "t/cypress/integration/Tools/" 3. Tests should pass Signed-off-by: David Nind --- t/cypress/fixtures/sample.mrc | 175 ++++++++++++++++++ .../Tools/ManageMarcImport_spec.ts | 95 ++++++++++ 2 files changed, 270 insertions(+) create mode 100644 t/cypress/fixtures/sample.mrc create mode 100644 t/cypress/integration/Tools/ManageMarcImport_spec.ts diff --git a/t/cypress/fixtures/sample.mrc b/t/cypress/fixtures/sample.mrc new file mode 100644 index 0000000000..790a98f3d9 --- /dev/null +++ b/t/cypress/fixtures/sample.mrc @@ -0,0 +1,175 @@ + + + + 01670nam a2200433Ii 4500 + sky2ocm96738507 + SKY + 20241107145520.0 + 190604t20191985nyu 000 1 eng d + + 9780593098271 (paperback) + + + OClCo + eng + rda + OClCo + + + PBK HERBERT + + + Herbert, Frank, + author. + 11964 + + + Chapterhouse : + Dune / + Frank Herbert ; with an introduction by Brian Herbert. + + + Dune + + + Ace premium edition. + + + New York : + Ace, published by Berkley, + 2019. + + + ©1985. + + + xi, 609 pages ; + 19 cm. + + + text + txt + rdacontent + + + unmediated + n + rdamedia + + + volume + nc + rdacarrier + + + Dune chronicles ; + Book Six + + + Fifteen thousand years after Leto II's death, the remnants of the Bene Gesserit contend with the ruthless leaders of an alien culture to forge a new civilization and preserve the best of the Old Empire. + + + Accelerated Reader AR + UG + 5.4 + 22 + 79162. + + + Prometheus Award for Best Libertarian SF Novel (preliminary ballot) + 1986 + + + Dune (Imaginary place) + Fiction. + 217871 + + + Survival fiction. + lcgft + 1021 + + + Science fiction. + lcgft + 519 + + + Herbert, Brian + writer of introduction. + 22739 + + + Herbert, Frank. + Dune chronicles ; + bk. 6. + 175318 + + + .b114409079 + 08-24-23 + 04-11-19 + + + MARCIVE Unico21e 8arc (UT8-8) + + + MARCIVE + + + MARCIVE + + + PBK + 8 + + + 46 + 46a + 06-04-19 + m + a + - + eng + nyu + 0 + 4 + + + 135034 + 135034 + + + + 727135 + + + 0 + 4 + ddc + 0 + PBK_HERBERT + 0 + ADULT + 589309 + ADM + NOL + SCIFI + 2019-05-30 + - + 5.99 + .i223869399 + 8 + 8 + PBK HERBERT + 4005302326 + 2023-09-05 00:00:00 + 2023-08-09 + 5.99 + 2023-08-25 + PBK + + diff --git a/t/cypress/integration/Tools/ManageMarcImport_spec.ts b/t/cypress/integration/Tools/ManageMarcImport_spec.ts new file mode 100644 index 0000000000..4141a99ff2 --- /dev/null +++ b/t/cypress/integration/Tools/ManageMarcImport_spec.ts @@ -0,0 +1,95 @@ +// File: t/cypress/integration/tools/ManageMarcImport_spec.ts + +describe("Breadcrumb tests", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + }); + + it("Breadcrumbs", () => { + cy.visit("/cgi-bin/koha/cataloguing/cataloging-home.pl"); + cy.contains("Manage staged records").click(); + cy.get("#breadcrumbs").contains("Cataloging"); + }); +}); + +describe("loads the manage MARC import page", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + }); + + it("loads the manage MARC import page", () => { + cy.visit("/cgi-bin/koha/tools/manage-marc-import.pl"); + cy.contains("Manage staged MARC records").click(); + }); + + it("upload a MARC record", () => { + cy.visit("/cgi-bin/koha/tools/stage-marc-import.pl"); + + cy.get('input[type="file"]').selectFile( + "t/cypress/fixtures/sample.mrc" + ); + cy.get('form[id="uploadfile"]').within(() => { + cy.get('button[id="fileuploadbutton"]').click(); + }); + + //wait after file upload, it can go to quickly here + cy.wait(2000); + + //check default values + cy.get('select[name="matcher"] option:selected').should( + "have.value", + "" + ); + cy.get('select[name="overlay_action"] option:selected').should( + "have.value", + "replace" + ); + cy.get('select[name="nomatch_action"] option:selected').should( + "have.value", + "create_new" + ); + cy.get('select[name="item_action"] option:selected').should( + "have.value", + "always_add" + ); + + cy.get('select[name="format"]').select("MARCXML", { force: true }); + cy.get("#format").should("have.value", "MARCXML"); + + //select some new options + cy.get("#matcher").select("3", { force: true }); + cy.get("#overlay_action").select("create_new", { force: true }); + cy.get("#nomatch_action").select("ignore", { force: true }); + cy.get("#item_action").select("ignore", { force: true }); + + //remove focus + //cy.get('#item_action').blur(); + cy.screenshot("after_selection"); + + // Now verify all values + cy.get("#matcher").should("have.value", "3"); + cy.get("#overlay_action").should("have.value", "create_new"); + cy.get("#nomatch_action").should("have.value", "ignore"); + cy.get("#item_action").should("have.value", "ignore"); + + cy.screenshot("right_before_submission"); + cy.get("#mainformsubmit").click(); + + cy.get("#job_callback").should("exist"); + + //wait for View batch link to load with the batch ID + cy.wait(5000); + + cy.screenshot("after_waiting"); + cy.contains("View batch").click(); + + cy.wait(2000); + // Now verify all values are retained + cy.get("#new_matcher_id").should("have.value", "3"); + cy.get("#overlay_action").should("have.value", "create_new"); + cy.get("#nomatch_action").should("have.value", "ignore"); + cy.get("#item_action").should("have.value", "ignore"); + }); +}); -- 2.39.5