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..12cc1559 --- /dev/null +++ b/src/features/BI-2392.feature @@ -0,0 +1,49 @@ +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 + 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/BI-2394.feature b/src/features/BI-2394.feature new file mode 100644 index 00000000..04d209a6 --- /dev/null +++ b/src/features/BI-2394.feature @@ -0,0 +1,64 @@ +Feature: Revoking access for Experimental Collaborator + + Background: + Given a new program is created + + @BI-2394 + 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/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/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/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 d8c85c2a..e1577660 100644 --- a/src/page_objects/experimentsObservationsPage.js +++ b/src/page_objects/experimentsObservationsPage.js @@ -15,6 +15,19 @@ 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"}); + }, + deleteCollaborator: async function (collaborator) { + this.api.click({selector:`//li[contains((.), '${collaborator}')]//button`, locateStrategy:"xpath"}); + } + } + ], sections: { table: { selector: ".table.is-striped.is-narrow", 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" diff --git a/src/step_definitions/experimentsObservationsSteps.js b/src/step_definitions/experimentsObservationsSteps.js index 41d4bc0f..36780f19 100644 --- a/src/step_definitions/experimentsObservationsSteps.js +++ b/src/step_definitions/experimentsObservationsSteps.js @@ -1,11 +1,27 @@ const { When } = require("@cucumber/cucumber"); +const { assert } = require("nightwatch"); 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", }); } - ); \ 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); +}) + +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 57848cd5..5ad920ac 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,13 +1600,42 @@ 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`, + const selectorWithModal = { + selector: `//*[@class='modal is-active']//button[normalize-space(.)='${args1}']`, locateStrategy: "xpath", }; - await this.browser.page.page().waitForElementVisible(selector, 20000); - 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); + 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); + console.log("Click span"); + } catch (error) { + console.log("Unable to find or click button: " + args1); + throw error; + } + } + } } async function importGermplasmFile(args1) { @@ -1626,3 +1655,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] + ); +}