From 21e3c653eb6d083cd85dee11c4aecf28cd851e68 Mon Sep 17 00:00:00 2001 From: mlorb Date: Fri, 3 Nov 2017 10:48:09 +0100 Subject: [PATCH] add integration tests for single team feature --- .../team/components/RemoveUserModal.jsx | 2 +- .../components/UpdateTeamDescriptionModal.jsx | 1 + .../team/components/UpdateTeamNameModal.jsx | 6 +- .../scenes/SettingsPage/scenes/team/index.jsx | 6 +- features/settings_page/team.feature | 70 +++++++++++++++++++ features/step_definitions/shared_steps.rb | 31 ++++++++ features/step_definitions/team_steps.rb | 28 ++++++++ features/teams.feature | 57 --------------- 8 files changed, 139 insertions(+), 62 deletions(-) create mode 100644 features/settings_page/team.feature create mode 100644 features/step_definitions/team_steps.rb diff --git a/app/javascript/src/scenes/SettingsPage/scenes/team/components/RemoveUserModal.jsx b/app/javascript/src/scenes/SettingsPage/scenes/team/components/RemoveUserModal.jsx index fe251601c..2cdec42af 100644 --- a/app/javascript/src/scenes/SettingsPage/scenes/team/components/RemoveUserModal.jsx +++ b/app/javascript/src/scenes/SettingsPage/scenes/team/components/RemoveUserModal.jsx @@ -47,7 +47,7 @@ class RemoveUserModal extends Component { /> - +

{ { render(): Node { return ( - + { (this: any).form = f; diff --git a/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx b/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx index 258f7d1a9..07134fbb1 100644 --- a/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx +++ b/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx @@ -177,12 +177,12 @@ class SettingsTeam extends Component { - + {this.state.team.name} - + {this.state.team.name} @@ -228,7 +228,7 @@ class SettingsTeam extends Component { - + diff --git a/features/settings_page/team.feature b/features/settings_page/team.feature new file mode 100644 index 000000000..5aa17cd7c --- /dev/null +++ b/features/settings_page/team.feature @@ -0,0 +1,70 @@ +Feature: Team settings + As a creator of a team + I want to be able to change team name, team description and user roles + So that I can manage my team + + Background: + Given the "BioSistemika Process" team exists + Given the following users are registered + | email | password | password_confirmation | full_name | initials | + | karli@myorg.com | mypassword1234 | mypassword1234 | Karli Novak | KN | + | marija@myorg.com | mypassword5555 | mypassword5555 | Marija Novak | MN | + | suazana@myorg.com | mypassword6666 | mypassword6666 | Suazana Novak | SN | + And "karli@myorg.com" is in "BioSistemika Process" team as a "admin" + And "marija@myorg.com" is in "BioSistemika Process" team as a "normal_user" + And "suazana@myorg.com" is in "BioSistemika Process" team as a "guest" + And is signed in with "karli@myorg.com", "mypassword1234" + + @javascript + Scenario: Successfully changes team name + Given I'm on "BioSistemika Process" team settings page + Then I click on ".team-name-title" element + And I change "BioSistemika Process" with "BioSistemika Process Company" in "settings_page.update_team_name_modal" input field + Then I click "Update" button + And I should see "BioSistemika Process Company" on ".team-name-title" element + + @javascript + Scenario: Successfully adds team description + Given I'm on "BioSistemika Process" team settings page + Then I click on ".team-description" element + And I fill in "I was on Triglav one summer." in "teamDescription" textarea field + Then I click "Update" button + And I should see "I was on Triglav one summer." on ".team-description" element + + @javascript + Scenario: Successfully changes team description + Given I'm on "BioSistemika Process" team settings page + Then I click on ".team-description" element + And I change "Lorem ipsum dolor sit amet, consectetuer adipiscing eli." with "I was on Triglav one summer." in "teamDescription" textarea field + Then I click "Update" button + And I should see "I was on Triglav one summer." on ".team-description" element + + @javascript + Scenario: Successfully changes user role + Given I'm on "BioSistemika Process" team settings page + Then I click on "marija@myorg.com" action button within Team members table + And I click "Guest" link within "marija@myorg.com" actions dropdown within Team members table + Then I should see "Guest" in Role column of "marija@myorg.com" within Team members table + + @javascript + Scenario: Successfully changes user role + Given I'm on "BioSistemika Process" team settings page + Then I click on "suazana@myorg.com" action button within Team members table + And I click "Normal user" link within "suazana@myorg.com" actions dropdown within Team members table + Then I should see "Normal user" in Role column of "suazana@myorg.com" within Team members table + + @javascript + Scenario: Successfully changes user role + Given I'm on "BioSistemika Process" team settings page + Then I click on "marija@myorg.com" action button within Team members table + And I click "Administrator" link within "marija@myorg.com" actions dropdown within Team members table + Then I should see "Administrator" in Role column of "marija@myorg.com" within Team members table + + @javascript + Scenario: Successfully removes user + Given I'm on "BioSistemika Process" team settings page + Then I click on "suazana@myorg.com" action button within Team members table + And I click "Remove" link within "suazana@myorg.com" actions dropdown within Team members table + And I should see "Are you sure you wish to remove user Suazana Novak from team BioSistemika Process?" on ".remove-user-modal-body" element + Then I click "Remove user" button + Then I should not see "suazana@myorg.com" in Team members table diff --git a/features/step_definitions/shared_steps.rb b/features/step_definitions/shared_steps.rb index be4ab7cdd..d85c5d267 100644 --- a/features/step_definitions/shared_steps.rb +++ b/features/step_definitions/shared_steps.rb @@ -2,6 +2,12 @@ When(/^I click "(.+)" button$/) do |button| click_on(button) end +When(/^I click "(.+)" button within "(.+)"$/) do |button, container| + within(find(container)) do + click_on button + end +end + Given(/^Show me the page$/) do save_and_open_page end @@ -93,3 +99,28 @@ Then(/^I should see "([^"]*)" in "([^"]*)" input field$/) do |text, container_id container = page.find_by_id(container_id) expect(container).to have_xpath("//input[@value='#{text}']") end + +Then(/^(?:|I )click on "([^"]*)" element$/) do |selector| + find(selector).click +end + +Then(/^I change "([^"]*)" with "([^"]*)" in "([^"]*)" input field$/) do |old_text, new_text, container_id| + container = page.find_by_id(container_id) + expect(container).to have_xpath("//input[@value='#{old_text}']") + container.find('input').set(new_text) +end + +Then(/^I fill in "([^"]*)" in "([^"]*)" textarea field$/) do |text, textarea_id| + textarea = page.find_by_id(textarea_id) + textarea.set(text) +end + +Then(/^I change "([^"]*)" with "([^"]*)" in "([^"]*)" textarea field$/) do |old_text, new_text, textarea_id| + textarea = page.find_by_id(textarea_id) + expect(textarea).to have_content(old_text) + textarea.set(new_text) +end + +Then(/^I should see "([^"]*)" on "([^"]*)" element$/) do |text, element| + expect(find(element)).to have_content(text) +end diff --git a/features/step_definitions/team_steps.rb b/features/step_definitions/team_steps.rb new file mode 100644 index 000000000..d68254194 --- /dev/null +++ b/features/step_definitions/team_steps.rb @@ -0,0 +1,28 @@ +Given(/^I'm on "([^"]*)" team settings page$/) do |team_name| + team = Team.find_by_name(team_name) + visit '/settings/teams/' + team.id.to_s +end + +Then(/^I click on "(.+)" action button within Team members table$/) do |email| + mail_td = find('td', text: /\A#{email}\z/) + parent = mail_td.first(:xpath, './/..') + parent.find_by_id('actions-dropdown').click +end + +Then(/^I click "(.+)" link within "(.+)" actions dropdown within Team members table$/) do |role, email| + mail_td = find('td', text: /\A#{email}\z/) + parent = mail_td.first(:xpath, './/..') + within(parent) do + click_link role + end +end + +Then(/^I should see "(.+)" in Role column of "(.+)" within Team members table$/) do |role, email| + mail_td = find('td', text: /\A#{email}\z/) + parent = mail_td.first(:xpath, './/..') + expect(parent).to have_css('td', text: /\A#{role}\z/) +end + +Then(/^I should not see "([^"]*)" in Team members table$/) do |email| + expect(page).to have_no_css('td', text: /\A#{email}\z/) +end diff --git a/features/teams.feature b/features/teams.feature index 51a2bf6b3..2174baf01 100644 --- a/features/teams.feature +++ b/features/teams.feature @@ -12,63 +12,6 @@ Given the following users is registered: |Marija Novak | marija@myorg.com | mypassword5555 | BioSistemika Process | Normal user | |Suazana Novak | suazana@myorg.com | mypassword6666 | BioSistemika Process | Guest user | - Scenario: Add team description - Given team BioSistemika Process settings page of a Karli Novak user - And I click to "i" blue button - Then I fill in "I was on Triglav one summer." to Description field of "Edit team description" modal window - And I click on "Update" button - Then I should see "I was on Triglav one summer." in team description field - - Scenario: Change team name - Given team BioSistemika Process settings page of a Karli Novak user - And I click to "BioSistemika Process Company" team name link - Then I change "BioSistemika Process Company" description with "BioSistemika Process" description to Name field of "Edit team name" modal window - And I click on "Update" button - Then I should see "BioSistemika Process" in team name field - - Scenario: Change team description - Given team BioSistemika Process settings page of a Karli Novak user - And I click to "i" blue button - Then I change "I was on Triglav one summer." description with "I want to go to Nanos." description to Description field of "Edit team description" modal window - And I click on "Update" button - Then I should see "I want to go to Nanos." in team description field - - Scenario: Change user role - Given team BioSistemika Process settings page of a Karli Novak user - And I click to Action button of a Marija Novak user in Team members table - Then I click to "Guest" in User role modal window - Then I should see "Guest" in Role column of a Marija Novak user in Team members table - - Scenario: Change user role - Given team BioSistemika Process settings page of a Karli Novak user - And I click to Action button of a Suazana Novak user in Team members table - Then I click to "Normal user" in User role modal window - Then I should see "Normal user" in Role column of a Suazana Novak user in Team members table - - Scenario: Change user role - Given team BioSistemika Process settings page of a Karli Novak user - And I click to Action button of a Marija Novak user in Team members table - Then I click to "Administrator" in User role modal window - Then I should see "Administrator" in Role column of a Marija Novak user in Team members table - - Scenario: Change user role - Given team BioSistemika Process settings page of a Karli Novak user - And I click to Action button of a Suazana Novak user in Team members table - Then I click to "Administrator" in User role modal window - Then I should see "Administratorr" in Role column of a Suazana Novak user in Team members table - - Scenario: Change user role - Given team BioSistemika Process settings page of a Karli Novak user - And I click to Action button of a Suazana Novak user in Team members table - Then I click to "Normal user" in User role modal window - Then I should see "Normal user" in Role column of a Suazana Novak user in Team members table - - Scenario: User is removed - Given team BioSistemika Process settings page of a Karli Novak user - And I click to Action button of a Suazana Novak user in Team members table - Then I click to "Remove" in User role modal window - Then I should not see Suazana Novak user in Team members table - Scenario: User left a team Given team BioSistemika Process settings page of a Marija Novak user And I click to Leave team button of BioSistemika Process team in Team table