Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/features/BI-2389.feature
Original file line number Diff line number Diff line change
@@ -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

1 change: 0 additions & 1 deletion src/features/BreedingMethods.feature
Original file line number Diff line number Diff line change
@@ -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
Expand Down
40 changes: 39 additions & 1 deletion src/step_definitions/steps.js
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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();
Expand Down Expand Up @@ -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<boolean>} - 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;
Expand Down Expand Up @@ -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()
Expand Down