Merge pull request #854 from mlorb/ml-sci-1573

Implement single team feature Integration tests [SCI-1573]
This commit is contained in:
mlorb 2017-11-07 13:33:43 +01:00 committed by GitHub
commit 9a875070c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 164 additions and 106 deletions

View file

@ -6,8 +6,6 @@ RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
apt-get update -qq && \
apt-get install -y \
nodejs \
qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x \
xvfb \
postgresql-client \
default-jre-headless \
unison \

View file

@ -108,9 +108,8 @@ group :test do
gem 'cucumber-rails', '~> 1.5'
gem 'database_cleaner'
gem 'capybara'
gem 'headless'
gem 'capybara-webkit', '~> 1.14'
gem 'selenium-webdriver'
gem 'poltergeist'
gem 'phantomjs', :require => 'phantomjs/poltergeist'
gem 'simplecov', require: false
end

View file

@ -137,12 +137,8 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.14.0)
capybara (>= 2.3.0, < 2.14.0)
json
childprocess (0.8.0)
ffi (~> 1.0, >= 1.0.11)
climate_control (0.2.0)
cliver (0.3.2)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.2)
@ -223,7 +219,6 @@ GEM
globalid (0.4.0)
activesupport (>= 4.2.0)
hammerjs-rails (2.0.8)
headless (2.3.1)
httparty (0.15.6)
multi_xml (>= 0.5.2)
i18n (0.9.0)
@ -307,6 +302,11 @@ GEM
parser (2.4.0.0)
ast (~> 2.2)
pg (0.21.0)
phantomjs (2.1.1.0)
poltergeist (1.16.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
polyglot (0.3.5)
powerpack (0.1.1)
pry (0.11.2)
@ -421,9 +421,6 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
selenium-webdriver (3.6.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
silencer (1.0.1)
@ -509,7 +506,6 @@ DEPENDENCIES
bullet
byebug
capybara
capybara-webkit (~> 1.14)
commit_param_routing
creek
cucumber-rails (~> 1.5)
@ -526,7 +522,6 @@ DEPENDENCIES
figaro
font-awesome-rails (~> 4.7.0.2)
hammerjs-rails
headless
i18n-js (>= 3.0.0.rc11)
introjs-rails
jbuilder
@ -544,6 +539,8 @@ DEPENDENCIES
nokogiri
paperclip (~> 5.1)
pg
phantomjs
poltergeist
pry
pry-byebug
pry-rails
@ -564,7 +561,6 @@ DEPENDENCIES
sass-rails (~> 5.0.6)
scss_lint
sdoc (~> 0.4.0)
selenium-webdriver
shoulda-matchers
silencer
simple_token_authentication (~> 1.15.1)

View file

@ -47,7 +47,7 @@ class RemoveUserModal extends Component<Props> {
/>
</Modal.Title>
</Modal.Header>
<Modal.Body>
<Modal.Body className="remove-user-modal-body">
<p>
<FormattedMessage
id="settings_page.remove_user_modal.subtitle"

View file

@ -77,6 +77,7 @@ class UpdateTeamDescriptionModal extends Component<Props, State> {
<FormattedMessage id="settings_page.update_team_description_modal.label" />
</ControlLabel>
<ValidatedFormControl
id="teamDescription"
componentClass="textarea"
tag="description"
defaultValue={this.props.team.description}

View file

@ -60,7 +60,11 @@ class UpdateTeamNameModal extends Component<Props, State> {
render(): Node {
return (
<Modal show={this.props.showModal} onHide={this.onCloseModal}>
<Modal
id="settings_page.update_team_name_modal"
show={this.props.showModal}
onHide={this.onCloseModal}
>
<ValidatedForm
ref={f => {
(this: any).form = f;

View file

@ -177,12 +177,12 @@ class SettingsTeam extends Component<Props, State> {
<FormattedMessage id="settings_page.all_teams" />
</Breadcrumb.Item>
</LinkContainer>
<Breadcrumb.Item active={true}>
<Breadcrumb.Item active>
{this.state.team.name}
</Breadcrumb.Item>
</Breadcrumb>
<TabTitle>
<StyledH3 onClick={this.showNameModal}>
<StyledH3 className="team-name-title" onClick={this.showNameModal}>
{this.state.team.name}
</StyledH3>
</TabTitle>
@ -228,7 +228,7 @@ class SettingsTeam extends Component<Props, State> {
</Col>
</Row>
<Row>
<Col sm={12} onClick={this.showDescriptionModal}>
<Col className="team-description" sm={12} onClick={this.showDescriptionModal}>
<BadgeWrapper>
<Glyphicon glyph="info-sign" />
</BadgeWrapper>

View file

@ -10,8 +10,8 @@ import {
export const removeUserFromTeam = (
teamId: number,
teamUserId: number
): Promise<*> => {
return axiosInstance({
): Promise<*> =>
axiosInstance({
method: "DELETE",
url: REMOVE_USER_FROM_TEAM_PATH,
data: {
@ -19,7 +19,6 @@ export const removeUserFromTeam = (
user_team: teamUserId
}
}).then(({ data }) => data.team_users);
};
export const inviteUsersToTeam = (
role: number,

View file

@ -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

View file

@ -42,9 +42,9 @@ end
Given(/^"([^"]*)" is in "([^"]*)" team as a "([^"]*)"$/) do |user_email, team_name, role|
team = Team.find_by_name(team_name)
user = User.find_by_email(user_email)
FactoryGirl.create( :user_team, user: user,
team: team,
role: UserTeam.roles.fetch(role))
FactoryGirl.create(:user_team, user: user,
team: team,
role: UserTeam.roles.fetch(role))
end
Then(/^I attach a "([^"]*)" file to "([^"]*)" field$/) do |file, field_id|
@ -93,3 +93,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

View file

@ -0,0 +1,30 @@
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|
wait_for_ajax
sleep 0.3
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

View file

@ -7,31 +7,24 @@ ENV['CUCUMBER'] = 'cucumber'
require 'cucumber/rails'
require 'capybara/cucumber'
require 'capybara-webkit'
require 'simplecov'
require 'headless'
require 'capybara/poltergeist'
require 'phantomjs'
headless = Headless.new
headless.start
Capybara::Webkit.configure do |config|
# Enable debug mode. Prints a log of everything the driver is doing.
config.debug = false
# Allow pages to make requests to any URL without issuing a warning.
config.allow_unknown_urls
# Timeout if requests take longer than 30 seconds
config.timeout = 30
# Don't raise errors when SSL certificates can't be validated
config.ignore_ssl_errors
# Raise JavaScript errors as exceptions
config.raise_javascript_errors = false
Capybara.register_driver :poltergeist do |app|
options = {
# inspector: true,
screen_size: [1600, 1200],
js_errors: false,
phantomjs: Phantomjs.path,
phantomjs_options: [
'--ignore-ssl-errors=yes'
]
}
Capybara::Poltergeist::Driver.new(app, options)
end
Capybara.javascript_driver = :webkit
Capybara.javascript_driver = :poltergeist
Capybara.default_max_wait_time = 30
Capybara.asset_host = 'http://localhost:3001'
Capybara.server_port = 3001

View file

@ -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