From 8b63c1c539d26ffb5c80f841d0e761731098db8b Mon Sep 17 00:00:00 2001 From: cvacalares Date: Sun, 18 May 2025 08:36:05 -0700 Subject: [PATCH 1/5] Add test for BI-2392. Add new step definitions for checking the collaborator field. --- src/features/BI-2056.feature | 2 +- src/features/BI-2392.feature | 50 +++++++++++++++++++ src/features/ProgramManagement.feature | 1 - .../experimentsObservationsPage.js | 10 ++++ .../experimentsObservationsSteps.js | 10 +++- src/step_definitions/steps.js | 3 +- 6 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 src/features/BI-2392.feature diff --git a/src/features/BI-2056.feature b/src/features/BI-2056.feature index b094bf1f..6cdc60ae 100644 --- a/src/features/BI-2056.feature +++ b/src/features/BI-2056.feature @@ -3,7 +3,7 @@ Feature: The ontology can be case insensitive Background: Given a new program is created - @BI-2156 + @BI-2056 Scenario Outline: The ontology can be case insensitive Given user logs in as "Cucumber Breeder" When user selects "*" on program-selection page diff --git a/src/features/BI-2392.feature b/src/features/BI-2392.feature new file mode 100644 index 00000000..72e6a643 --- /dev/null +++ b/src/features/BI-2392.feature @@ -0,0 +1,50 @@ +Feature: Read Only with non System Admin roles cannot see a delete button next to each collaborator + + Background: + Given a new program is created + + @BI-2392 + @debug + Scenario Outline: Read Only with non System Admin roles cannot see a delete button next to each collaborator + Given user logs in as "Cucumber Breeder" + When user selects "*" on program-selection page + And user selects "Program Administration" in top-level navigation + And user selects New User button + And user sets "test user" in Name field of User + And user sets "test@mailinator.com" in Email field of User + And user selects "Experimental Collaborator" in Role dropdown + And user selects Save button + And user pause for "5" seconds + 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 + When user selects "Ontology" in navigation + When user selects "Manage Ontology" button + When user selects "Import file" link + And user uploads Ontology "test01-ontology.xls" file + When user selects 'Import' button + When user selects "Confirm" button + And user pause for "5" seconds + When user selects "Experiments & Observations" in navigation + When user selects "Import Experiments & Observations" button + And user uploads Experiments & Observations "BI-2056.csv" file + When user selects 'Import' button + When user selects "Confirm" button + And user pause for "5" seconds + And user selects "Experiments & Observations" in top-level navigation + And user selects "New Trial DRP1" of row "1" of Experiments page + And user selects "Manage Experiment" button + And user selects "Add Collaborator" link + And user selects "Save" button + And user logs out + Given user logs in as "Cucumber Member" + When user selects "*" on program-selection page + And user selects "Experiments & Observations" in top-level navigation + And user selects "New Trial DRP1" of row "1" of Experiments page + And user can see "test user(test@mailinator.com)" as Collaborator + And user can not see "test user(test@mailinator.com)" delete button of Collaborator \ No newline at end of file diff --git a/src/features/ProgramManagement.feature b/src/features/ProgramManagement.feature index 15ecb6f0..ac55356f 100644 --- a/src/features/ProgramManagement.feature +++ b/src/features/ProgramManagement.feature @@ -1,4 +1,3 @@ -@debug Feature: Program Management (15) Background: Sysad logs in diff --git a/src/page_objects/experimentsObservationsPage.js b/src/page_objects/experimentsObservationsPage.js index d8c85c2a..73f616f6 100644 --- a/src/page_objects/experimentsObservationsPage.js +++ b/src/page_objects/experimentsObservationsPage.js @@ -15,6 +15,16 @@ module.exports = { locateStrategy: "xpath", }, }, + commands: [ + { + isCollaboratorVisible: async function (collaborator) { + this.assert.visible({selector:`//li[contains((.), '${collaborator}')]`, locateStrategy:"xpath"}); + }, + isDeleteNotVisible: async function (collaborator) { + this.assert.not.visible({selector:`//li[contains((.), '${collaborator}')]//button`, locateStrategy:"xpath"}); + } + } + ], sections: { table: { selector: ".table.is-striped.is-narrow", diff --git a/src/step_definitions/experimentsObservationsSteps.js b/src/step_definitions/experimentsObservationsSteps.js index 41d4bc0f..3cd19c0b 100644 --- a/src/step_definitions/experimentsObservationsSteps.js +++ b/src/step_definitions/experimentsObservationsSteps.js @@ -1,4 +1,5 @@ const { When } = require("@cucumber/cucumber"); +const { assert } = require("nightwatch"); When( /^user selects "([^"]*)" of row "([^"]*)" of Experiments page$/, @@ -8,4 +9,11 @@ When( locateStrategy: "xpath", }); } - ); \ No newline at end of file + ); +When('user can see {string} as Collaborator', async function (s) { + await this.browser.page.experimentsObservationsPage().isCollaboratorVisible(s); +}) + +When('user can not see {string} delete button of Collaborator', async function(s) { + await this.browser.page.experimentsObservationsPage().isDeleteNotVisible(s); +}) diff --git a/src/step_definitions/steps.js b/src/step_definitions/steps.js index 57848cd5..dfe0217a 100644 --- a/src/step_definitions/steps.js +++ b/src/step_definitions/steps.js @@ -1602,10 +1602,9 @@ async function selectsImportButton() { async function selectsButton(args1) { await this.browser.page.page().pause(1000); const selector = { - selector: `//button[starts-with(normalize-space(.),'${args1}')] | //span[normalize-space(.)='${args1}']/ancestor::button`, + selector: `//button[starts-with(normalize-space(.),'${args1}')]`, locateStrategy: "xpath", }; - await this.browser.page.page().waitForElementVisible(selector, 20000); await this.browser.page.page().click(selector); } From ca8fadfadf4ecec5cf2baf5eaa2a907c8a8a3b57 Mon Sep 17 00:00:00 2001 From: cvacalares Date: Mon, 19 May 2025 15:18:36 -0700 Subject: [PATCH 2/5] Add test for BI-2394. Add step to deleteCollaborator. Add cliecExecute using expath. --- src/features/BI-2392.feature | 1 - src/features/BI-2394.feature | 65 ++++++++++ src/files/ExperimentsImport/BI-2392.csv | 5 + .../experimentsObservationsPage.js | 3 + .../experimentsObservationsSteps.js | 10 +- src/step_definitions/steps.js | 112 +++++++++++++++++- 6 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 src/features/BI-2394.feature create mode 100644 src/files/ExperimentsImport/BI-2392.csv diff --git a/src/features/BI-2392.feature b/src/features/BI-2392.feature index 72e6a643..12cc1559 100644 --- a/src/features/BI-2392.feature +++ b/src/features/BI-2392.feature @@ -4,7 +4,6 @@ Feature: Read Only with non System Admin roles cannot see a delete button next t Given a new program is created @BI-2392 - @debug Scenario Outline: Read Only with non System Admin roles cannot see a delete button next to each collaborator Given user logs in as "Cucumber Breeder" When user selects "*" on program-selection page diff --git a/src/features/BI-2394.feature b/src/features/BI-2394.feature new file mode 100644 index 00000000..6175d5b6 --- /dev/null +++ b/src/features/BI-2394.feature @@ -0,0 +1,65 @@ +Feature: Revoking access for Experimental Collaborator + + Background: + Given a new program is created + + @BI-2394 + @debug + Scenario Outline: Revoking access for Experimental Collaborator + Given user logs in as "Cucumber Breeder" + When user selects "*" on program-selection page + And user selects "Program Administration" in top-level navigation + And user selects "Edit" of row "2" of Experiments page + And user sets "Experimental Collaborator" in Role dropdown + And user selects "Save" button + And user pause for "5" seconds + 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 + When user selects "Ontology" in navigation + When user selects "Manage Ontology" button + When user selects "Import file" link + And user uploads Ontology "test01-ontology.xls" file + When user selects 'Import' button + When user selects "Confirm" button + And user pause for "5" seconds + When user selects "Experiments & Observations" in navigation + When user selects "Import Experiments & Observations" button + And user uploads Experiments & Observations "BI-2056.csv" file + When user selects 'Import' button + When user selects "Confirm" button + And user pause for "5" seconds + When user selects "Experiments & Observations" in navigation + When user selects "Import Experiments & Observations" button + And user uploads Experiments & Observations "BI-2392.csv" file + When user selects 'Import' button + When user selects "Confirm" button + And user pause for "5" seconds + And user selects "Experiments & Observations" in top-level navigation + And user selects "New Trial DRP1" link + And user selects "Manage Experiment" button + And user selects "Add Collaborator" link + And user selects "Save" button + And user logs out + Given user logs in as "Cucumber Member" + When user selects "*" on program-selection page + And user selects "Experiments & Observations" in top-level navigation + And user can see row "1" rows in a table + And user logs out + Given user logs in as "Cucumber Breeder" + When user selects "*" on program-selection page + And user selects "Experiments & Observations" in top-level navigation + And user selects "New Trial DRP1" link + And user selects "(cucumbermember@mailinator.com)" delete button of Collaborator + And user selects "Confirm" button + And user pause for "5" seconds + And user logs out + Given user logs in as "Cucumber Member" + When user selects "*" on program-selection page + And user selects "Experiments & Observations" in top-level navigation + And user can see "No experiments and observations are currently defined for this program." message \ No newline at end of file diff --git a/src/files/ExperimentsImport/BI-2392.csv b/src/files/ExperimentsImport/BI-2392.csv new file mode 100644 index 00000000..992df633 --- /dev/null +++ b/src/files/ExperimentsImport/BI-2392.csv @@ -0,0 +1,5 @@ +Germplasm Name,Germplasm GID,Test (T) or Check (C),Exp Title ,Exp Description,Exp Unit,Exp Type,Env,Env Location,Env Year,Exp Unit ID,Exp Replicate #,Exp Block #,Row,Column,Lat,Long,Elevation,RTK,Treatment Factors,ObsUnitID,BLACKBERRY,BlackBERRY1,blackberry01 +Germplas127,1,C,New Trial DRP 11,A new trial DRP,plot,phenotyping,New Study 15,New Location DRP6,2000,9390,1,2,4,5,,,,,Jam application,,,, +Germplas128,2,C,New Trial DRP 11,A new trial DRP,plot,phenotyping,New Study 16,New Location DRP7,2000,9391,1,2,4,5,,,,,Jam application,,,, +Germplas129,3,C,New Trial DRP 11,A new trial DRP,plot,phenotyping,New Study 17,New Location DRP8,2000,9392,1,2,4,5,,,,,Jam application,,,, +Germplas130,4,C,New Trial DRP 11,A new trial DRP,plot,phenotyping,New Study 18,New Location DRP9,2000,9393,1,2,4,5,,,,,Jam application,,,, diff --git a/src/page_objects/experimentsObservationsPage.js b/src/page_objects/experimentsObservationsPage.js index 73f616f6..e1577660 100644 --- a/src/page_objects/experimentsObservationsPage.js +++ b/src/page_objects/experimentsObservationsPage.js @@ -22,6 +22,9 @@ module.exports = { }, isDeleteNotVisible: async function (collaborator) { this.assert.not.visible({selector:`//li[contains((.), '${collaborator}')]//button`, locateStrategy:"xpath"}); + }, + deleteCollaborator: async function (collaborator) { + this.api.click({selector:`//li[contains((.), '${collaborator}')]//button`, locateStrategy:"xpath"}); } } ], diff --git a/src/step_definitions/experimentsObservationsSteps.js b/src/step_definitions/experimentsObservationsSteps.js index 3cd19c0b..36780f19 100644 --- a/src/step_definitions/experimentsObservationsSteps.js +++ b/src/step_definitions/experimentsObservationsSteps.js @@ -5,7 +5,7 @@ When( /^user selects "([^"]*)" of row "([^"]*)" of Experiments page$/, async function (link, rowIndex) { await this.browser.page.experimentsObservationsPage().section.table.click({ - selector: `.//tr[${rowIndex}]//a[normalize-space()='${link}']`, + selector: `.//tr[${rowIndex}]//a[normalize-space(.)='${link}']`, locateStrategy: "xpath", }); } @@ -17,3 +17,11 @@ When('user can see {string} as Collaborator', async function (s) { When('user can not see {string} delete button of Collaborator', async function(s) { await this.browser.page.experimentsObservationsPage().isDeleteNotVisible(s); }) + +When('user selects {string} delete button of Collaborator', async function (s) { + await this.browser.page.experimentsObservationsPage().deleteCollaborator(s); +}) + +When('user can see {string} message', async function (s) { + await this.browser.page.experimentsObservationsPage().assert.textContains({selector:"//*[@class='is-empty']//p", locateStrategy:"xpath"}, s); +}) diff --git a/src/step_definitions/steps.js b/src/step_definitions/steps.js index dfe0217a..aaa76aa3 100644 --- a/src/step_definitions/steps.js +++ b/src/step_definitions/steps.js @@ -1013,7 +1013,7 @@ When(/^user selects "([^"]*)" button$/, async function (args1) { When(/^user selects "([^"]*)" link$/, async function (args1) { await this.browser.page.page().pause(1000); const selector = { - selector: `//a[starts-with(normalize-space(.),'${args1}')]`, + selector: `//a[normalize-space(.)='${args1}']`, locateStrategy: "xpath", }; await this.browser.page.page().waitForElementVisible(selector); @@ -1600,12 +1600,88 @@ async function selectsImportButton() { } async function selectsButton(args1) { - await this.browser.page.page().pause(1000); - const selector = { - selector: `//button[starts-with(normalize-space(.),'${args1}')]`, + const selectorWithModal = { + selector: `//*[@class='modal is-active']//button[normalize-space(.)='${args1}']`, locateStrategy: "xpath", }; - await this.browser.page.page().click(selector); + try { + await this.browser.page + .page() + .waitForElementVisible(selectorWithModal, 2000); + await this.browser.page.page().click(selectorWithModal); + console.log("Click the modal."); + } catch (error) { + let element = { + selector: `//button[normalize-space(.)='${args1}']`, + locateStrategy: "xpath", + }; + + try { + await this.browser.page.page().waitForElementVisible(element, 2000); + await clickExecute(element.selector); + // await browser.execute( + // function (xpath) { + // const node = document.evaluate( + // xpath, + // document, + // null, + // XPathResult.FIRST_ORDERED_NODE_TYPE, + // null + // ).singleNodeValue; + + // if (node) { + // const event = new MouseEvent("click", { + // bubbles: true, + // cancelable: true, + // view: window, + // }); + // node.dispatchEvent(event); + // } else { + // console.warn("Element not found via XPath: " + xpath); + // } + // }, + // [element.selector] + // ); + console.log("Click as button."); + } catch (error) { + element = { + selector: `//span[normalize-space(.)='${args1}']/..`, + locateStrategy: "xpath", + }; + + try { + await this.browser.page.page().waitForElementVisible(element, 2000); + await clickExecute(element.selector); + // await browser.execute( + // function (xpath) { + // const node = document.evaluate( + // xpath, + // document, + // null, + // XPathResult.FIRST_ORDERED_NODE_TYPE, + // null + // ).singleNodeValue; + + // if (node) { + // const event = new MouseEvent("click", { + // bubbles: true, + // cancelable: true, + // view: window, + // }); + // node.dispatchEvent(event); + // } else { + // console.warn("Element not found via XPath: " + xpath); + // } + // }, + // [element.selector] + // ); + console.log("Click span"); + } catch (error) { + console.log("Unable to find or click button: " + args1); + throw error; + } + } + } } async function importGermplasmFile(args1) { @@ -1625,3 +1701,29 @@ async function showAll() { await this.browser.page.page().click("@showAllButton"); await this.browser.page.page().pause(5000); } + +async function clickExecute(xpath){ + await browser.execute( + function (xpath) { + const node = document.evaluate( + xpath, + document, + null, + XPathResult.FIRST_ORDERED_NODE_TYPE, + null + ).singleNodeValue; + + if (node) { + const event = new MouseEvent("click", { + bubbles: true, + cancelable: true, + view: window, + }); + node.dispatchEvent(event); + } else { + console.warn("Element not found via XPath: " + xpath); + } + }, + [xpath] + ); +} \ No newline at end of file From a80edeb5d32b43dbf3306b0a869f980863fa4b0a Mon Sep 17 00:00:00 2001 From: cvacalares Date: Mon, 19 May 2025 15:35:31 -0700 Subject: [PATCH 3/5] Remove commented section. Create function for clickExecute. --- src/step_definitions/steps.js | 100 +++++++++------------------------- 1 file changed, 27 insertions(+), 73 deletions(-) diff --git a/src/step_definitions/steps.js b/src/step_definitions/steps.js index aaa76aa3..5ad920ac 100644 --- a/src/step_definitions/steps.js +++ b/src/step_definitions/steps.js @@ -1619,29 +1619,6 @@ async function selectsButton(args1) { try { await this.browser.page.page().waitForElementVisible(element, 2000); await clickExecute(element.selector); - // await browser.execute( - // function (xpath) { - // const node = document.evaluate( - // xpath, - // document, - // null, - // XPathResult.FIRST_ORDERED_NODE_TYPE, - // null - // ).singleNodeValue; - - // if (node) { - // const event = new MouseEvent("click", { - // bubbles: true, - // cancelable: true, - // view: window, - // }); - // node.dispatchEvent(event); - // } else { - // console.warn("Element not found via XPath: " + xpath); - // } - // }, - // [element.selector] - // ); console.log("Click as button."); } catch (error) { element = { @@ -1649,32 +1626,9 @@ async function selectsButton(args1) { locateStrategy: "xpath", }; - try { - await this.browser.page.page().waitForElementVisible(element, 2000); - await clickExecute(element.selector); - // await browser.execute( - // function (xpath) { - // const node = document.evaluate( - // xpath, - // document, - // null, - // XPathResult.FIRST_ORDERED_NODE_TYPE, - // null - // ).singleNodeValue; - - // if (node) { - // const event = new MouseEvent("click", { - // bubbles: true, - // cancelable: true, - // view: window, - // }); - // node.dispatchEvent(event); - // } else { - // console.warn("Element not found via XPath: " + xpath); - // } - // }, - // [element.selector] - // ); + try { + await this.browser.page.page().waitForElementVisible(element, 2000); + await clickExecute(element.selector); console.log("Click span"); } catch (error) { console.log("Unable to find or click button: " + args1); @@ -1702,28 +1656,28 @@ async function showAll() { await this.browser.page.page().pause(5000); } -async function clickExecute(xpath){ +async function clickExecute(xpath) { await browser.execute( - function (xpath) { - const node = document.evaluate( - xpath, - document, - null, - XPathResult.FIRST_ORDERED_NODE_TYPE, - null - ).singleNodeValue; - - if (node) { - const event = new MouseEvent("click", { - bubbles: true, - cancelable: true, - view: window, - }); - node.dispatchEvent(event); - } else { - console.warn("Element not found via XPath: " + xpath); - } - }, - [xpath] - ); -} \ No newline at end of file + function (xpath) { + const node = document.evaluate( + xpath, + document, + null, + XPathResult.FIRST_ORDERED_NODE_TYPE, + null + ).singleNodeValue; + + if (node) { + const event = new MouseEvent("click", { + bubbles: true, + cancelable: true, + view: window, + }); + node.dispatchEvent(event); + } else { + console.warn("Element not found via XPath: " + xpath); + } + }, + [xpath] + ); +} From cdd62e6d7399aa12213990d95f579069300b4a05 Mon Sep 17 00:00:00 2001 From: cvacalares Date: Sat, 24 May 2025 14:37:57 -0700 Subject: [PATCH 4/5] Remove debug flag. --- src/features/BI-2394.feature | 1 - 1 file changed, 1 deletion(-) diff --git a/src/features/BI-2394.feature b/src/features/BI-2394.feature index 6175d5b6..04d209a6 100644 --- a/src/features/BI-2394.feature +++ b/src/features/BI-2394.feature @@ -4,7 +4,6 @@ Feature: Revoking access for Experimental Collaborator Given a new program is created @BI-2394 - @debug Scenario Outline: Revoking access for Experimental Collaborator Given user logs in as "Cucumber Breeder" When user selects "*" on program-selection page From 0b96f76bb9a03fe4da40fef2166c58cda5c14d46 Mon Sep 17 00:00:00 2001 From: cvacalares Date: Wed, 18 Jun 2025 23:59:19 -0700 Subject: [PATCH 5/5] Update the step since there's an existing one. --- src/features/BreedingMethods.feature | 5 +++-- src/step_definitions/breedingMethodsSteps.js | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/features/BreedingMethods.feature b/src/features/BreedingMethods.feature index 94e834eb..12c8da7d 100644 --- a/src/features/BreedingMethods.feature +++ b/src/features/BreedingMethods.feature @@ -1,6 +1,7 @@ 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 @@ -41,7 +42,7 @@ Feature: Breeding Methods Then user can see 'Delete' action on "" Breeding Method Then user can see 'Edit' action on "" Breeding Method When user clicks 'Edit' action on "" Breeding Method - Then user cannot see "Breeding method is in use. Deletion disabled." message + Then user cannot see "Breeding method is in use. Deletion disabled." message on Program Administration page And user selects "Import Data" in navigation And user uploads Germplasm "BreedingMethodGermplasm.csv" file And user selects 'Import' button @@ -58,7 +59,7 @@ Feature: Breeding Methods Then user cannot see 'Delete' action on "" Breeding Method Then user can see 'Edit' action on "" Breeding Method When user clicks 'Edit' action on "" Breeding Method - Then user can see "Breeding method is in use. Deletion disabled." message + Then user can see "Breeding method is in use. Deletion disabled." message on Program Administration page Examples: | name | abbreviation | description | diff --git a/src/step_definitions/breedingMethodsSteps.js b/src/step_definitions/breedingMethodsSteps.js index 85af020b..577fc180 100644 --- a/src/step_definitions/breedingMethodsSteps.js +++ b/src/step_definitions/breedingMethodsSteps.js @@ -146,7 +146,14 @@ Then( ); Then( - /^user cannot see "Breeding method is in use. Deletion disabled." message$/, + /^user can see "Breeding method is in use. Deletion disabled." message on Program Administration page$/, + async function() { + await this.browser.page.programAdministrationPage().section.breedingMethods.assert.visible("@inUseMessage"); + } +); + +Then( + /^user cannot see "Breeding method is in use. Deletion disabled." message on Program Administration page$/, async function() { await this.browser.page.programAdministrationPage().section.breedingMethods.assert.not.elementPresent( "@inUseMessage"