diff --git a/src/features/BI-2389.feature b/src/features/BI-2389.feature new file mode 100644 index 00000000..871f51ce --- /dev/null +++ b/src/features/BI-2389.feature @@ -0,0 +1,26 @@ +Feature: Verify correct entry numbers on all germplasm export list + + Background: + Given a new program is created + + @BI-2389 + Scenario Outline: The ontology can be case insensitive + Given user logs in as "Cucumber Breeder" + When user selects "*" on program-selection page + And user selects "Germplasm" in top-level navigation + And user selects "Manage Germplasm" button + And user selects "Import file" menu item + And user uploads Germplasm "GermplasmSample.xlsx" file + And user selects 'Import' button + When user sets "GermplasmSort" in List Name field of import page + When user sets "GermplasmSort" in List Description field of import page + And user selects "Confirm" button + And user pause for "5" seconds + And user selects "Germplasm" in top-level navigation + And user selects "Manage Germplasm" button + And user selects "Download file" button + Then the value of column "GID" and column "Entry No" at row 1 in the downloaded file should be equal + Then the value of column "GID" and column "Entry No" at row 2 in the downloaded file should be equal + Then the value of column "GID" and column "Entry No" at row 3 in the downloaded file should be equal + Then the value of column "GID" and column "Entry No" at row 4 in the downloaded file should be equal + \ No newline at end of file diff --git a/src/features/BreedingMethods.feature b/src/features/BreedingMethods.feature index 12c8da7d..0756889b 100644 --- a/src/features/BreedingMethods.feature +++ b/src/features/BreedingMethods.feature @@ -1,7 +1,6 @@ Feature: Breeding Methods @BI-1805 - @debug Scenario Outline: Breeding Methods Management Given user logs in as "sysad" And user selects "System Administration" on program-selection page diff --git a/src/step_definitions/steps.js b/src/step_definitions/steps.js index 5ad920ac..6e2beae7 100644 --- a/src/step_definitions/steps.js +++ b/src/step_definitions/steps.js @@ -1,4 +1,5 @@ const { Given, Then, When, World } = require("@cucumber/cucumber"); +const { getLatestDownloadedFile } = require('../../cucumber.conf.js'); const path = require("path"); const importFolder = path.join(__dirname, "../", "files", "TraitImport"); const germplasmFolder = path.join(__dirname, "../", "files", "GermplasmImport"); @@ -11,6 +12,7 @@ const genotypeSamplesFolder = path.join( const user = {}; const helpers = require("./helpers.js"); const assert = require("assert"); +const ExcelJS = require("exceljs"); Given(/^user logs with valid credentials$/, async function () { await this.browser.page.page().navigate(); @@ -1367,6 +1369,32 @@ Then("user can not see {string} button", async function (args0) { }); }); +/** + * Compare the value of a source column and target column at a specific row in an Excel file. + * @param {string} filePath - Path to the Excel file. + * @param {string} sourceCol - Source column letter (e.g., "A"). + * @param {string} targetCol - Target column letter (e.g., "B"). + * @param {number} rowNum - Row number (1-based). + * @returns {Promise} - true if equal, false otherwise. + */ +async function compareCellValuesByColumns(filePath, sourceCol, targetCol, rowNum) { + const workbook = new ExcelJS.Workbook(); + await workbook.xlsx.readFile(filePath); + const worksheet = workbook.worksheets[0]; + const sourceValue = worksheet.getCell(`${sourceCol}${rowNum}`).value; + const targetValue = worksheet.getCell(`${targetCol}${rowNum}`).value; + return sourceValue === targetValue; +} + +Then( + /^the value of column "([^"]*)" and column "([^"]*)" at row (\d+) in the downloaded file should be equal$/, + async function (sourceCol, targetCol, rowNum) { + const filePath = this.browser.globals.downloadedFilePath; + const isEqual = await compareCellValuesByColumns(filePath, sourceCol, targetCol, Number(rowNum)); + assert.ok(isEqual, `Column ${sourceCol}${rowNum} and ${targetCol}${rowNum} values are not equal`); + } +); + //functions async function setUserName(name) { user.userName = name; @@ -1600,10 +1628,20 @@ async function selectsImportButton() { } async function selectsButton(args1) { + //download file + if (args1 === "Download file") { + this.browser.page.page().click('#germplasm-download-file'); + const filePath = await getLatestDownloadedFile(); + this.browser.globals.downloadedFilePath = filePath; + console.log("File downloaded to: " + filePath); + return; + } + const selectorWithModal = { - selector: `//*[@class='modal is-active']//button[normalize-space(.)='${args1}']`, + selector: `//*[@class='modal is-active']//button[normalize-space()='${args1}']`, locateStrategy: "xpath", }; + try { await this.browser.page .page()