Merge pull request #975 from ZmagoD/zd_SCI_2001

Zd sci 2001
This commit is contained in:
Zmago Devetak 2018-01-31 14:42:41 +01:00 committed by GitHub
commit ccab688728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 148 additions and 120 deletions

View file

@ -260,9 +260,7 @@
</a>
<ul class="dropdown-menu" data-hook="navigation-user-menu">
<li>
<%= link_to t('nav.user.settings'),
'/settings',
data: { turbolinks: false } %>
<%= link_to t('nav.user.settings'), edit_user_registration_path, data: { turbolinks: false }%>
</li>
<li role="separator" class="divider"></li>
<li>

View file

@ -55,7 +55,11 @@
</div>
<% end %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "full_name" }) do |f| %>
<%= form_for(resource,
as: resource_name,
url: registration_path(resource_name, format: :json),
remote: true,
html: { method: :put, "data-for" => "full_name", class: 'settings-page-full-name' }) do |f| %>
<div data-part="view">
<div class="form-group">
<%= f.label t("users.registrations.edit.name_label") %>
@ -82,7 +86,11 @@
</div>
<% end %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "initials" }) do |f| %>
<%= form_for(resource,
as: resource_name,
url: registration_path(resource_name, format: :json),
remote: true,
html: { method: :put, "data-for" => "initials", class: 'settings-page-initials' }) do |f| %>
<div data-part="view">
<div class="form-group">
<%= f.label t("users.registrations.edit.initials_label") %>
@ -109,7 +117,11 @@
</div>
<% end %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "email" }) do |f| %>
<%= form_for(resource,
as: resource_name,
url: registration_path(resource_name, format: :json),
remote: true,
html: { method: :put, "data-for" => "email", class: 'settings-page-email' }) do |f| %>
<div data-part="view">
<div class="form-group">
<%= f.label t("users.registrations.edit.email_label") %>
@ -146,7 +158,11 @@
</div>
<% end %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "password" }) do |f| %>
<%= form_for(resource,
as: resource_name,
url: registration_path(resource_name, format: :json),
remote: true,
html: { method: :put, "data-for" => "password", class: 'settings-page-change-password' }) do |f| %>
<%= hidden_field_tag "user[change_password]", "true" %>
<div data-part="view">
<div class="form-group">

View file

@ -14,7 +14,7 @@
remote: true,
class: 'name-link name-refresh',
style: 'color: inherit' do %>
<h3><%= @team.name %></h3>
<h3 id="team-name"><%= @team.name %></h3>
<% end %>
<br />
<!-- End of TITLE -->

View file

@ -15,16 +15,16 @@ Rails.application.routes.draw do
root 'projects#index'
# Client APP endpoints
get '/settings', to: 'client_api/settings#index'
get '/settings/*all', to: 'client_api/settings#index'
namespace :client_api, defaults: { format: 'json' } do
post '/premissions', to: 'permissions#status'
%i(activities teams notifications users configurations).each do |path|
draw path
end
end
# # Client APP endpoints
# get '/settings', to: 'client_api/settings#index'
# get '/settings/*all', to: 'client_api/settings#index'
#
# namespace :client_api, defaults: { format: 'json' } do
# post '/premissions', to: 'permissions#status'
# %i(activities teams notifications users configurations).each do |path|
# draw path
# end
# end
# Save sample table state
post '/state_save/:team_id/:user_id',

View file

@ -14,7 +14,7 @@ Feature: Addon versions
@javascript
Scenario: Open the sciNote addons modal
Given I'm on the profile page
And I click "#nav-info-dropdown" icon
And I click "#help-link" icon
And I click "About sciNote" link within ".dropdown.open"
Then I should see "About sciNote"
And I should see "sciNote core version"

View file

@ -13,14 +13,14 @@ Background:
@javascript
Scenario: User forgot their password and requests for new password
Given I am on reset password page
Then I fill in "nonadmin@myorg.com" in "user_email" input field
Then I fill in "nonadmin@myorg.com" in "#user_email" field
And I click "Send me reset password instruction" button
Then I should see "You will receive an email with instructions on how to reset your password in a few minutes." flash message
@javascript
Scenario: User forgot their password and enters non valid email
Given I am on reset password page
Then I fill in "nonuser@myorg.com" in "user_email" input field
Then I fill in "nonuser@myorg.com" in "#user_email" field
And I click "Send me reset password instruction" button
Then I should see "Email not found"
@ -32,8 +32,8 @@ Scenario: User has got Reset Your Password email and click to link
@javascript
Scenario: User successfully Change password at Change your password page
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
Then I fill in "newpassword1234" in "user_password" input field
And I fill in "newpassword1234" in "user_password_confirmation" input field
Then I fill in "newpassword1234" in "#user_password" field
And I fill in "newpassword1234" in "#user_password_confirmation" field
And I click "Change my password" button
Then I should see "BioSistemika Process"
And I should see "Your password has been changed successfully. You are now logged in." flash message
@ -41,7 +41,7 @@ Scenario: User successfully Change password at Change your password page
@javascript
Scenario: User unsuccessfully Change password at Change your password page
Given I click on Reset Password link in the reset password email for user "nonadmin@myorg.com"
Then I fill in "newpassword1234" in "user_password" input field
And I fill in "nosamepassword" in "user_password_confirmation" input field
Then I fill in "newpassword1234" in "#user_password" field
And I fill in "nosamepassword" in "#user_password_confirmation" field
And I click "Change my password" button
Then I should see "Password confirmation doesn't match Password" flash message

View file

@ -26,7 +26,6 @@ Feature: Sign up
| Full name | Email | Password | Password confirmation | Team name |
| Magnus | magnus@gmail.com | asdf1234 | asdf1234 | SpliceGirls |
And I click "Sign up" button
And Show me the page
Then I should see "SpliceGirls"
And I should be on homepage
@ -37,7 +36,7 @@ Feature: Sign up
| Full name | Email | Password | Password confirmation | Team name |
| Magnus | magnus@gmail.com | asdf1234 | asdf1234567 | SpliceGirls |
And I click "Sign up" button
Then I should see "doesn't match Password" error message under "password_confirmation_form" field
Then I should see "doesn't match Password"
@javascript
Scenario: Unsuccessful sign up, team name is missing
@ -46,4 +45,4 @@ Feature: Sign up
| Full name | Email | Password | Password confirmation |
| Magnus | magnus@gmail.com | asdf1234 | asdf1234 |
And I click "Sign up" button
Then I should see "is too short (minimum is 2 characters)" error message under "team_name_form" field
Then I should see "is too short (minimum is 2 characters)"

View file

@ -16,97 +16,101 @@ Background:
Given I'm on the home page of "BioSistemika Process" team
And I click on Avatar
And I click "Settings" link within "#user-account-dropdown"
Then I should see "My Profile"
Then I should see "My profile"
@javascript
Scenario: Unsuccessful avatar image upload, file is too big
Given I'm on the profile page
Then I click on image within ".avatar-container" element
And I attach a "Moon.png" file to "user_avatar_input" field
And I should see "file too large (maximum size is 0.2 MB)" error message under "user_avatar_input" field
And I attach a "Moon.png" file to "user_avatar" field
And I click "Upload" button
And I should see "Your avatar file cannot be larger than 0.2 MB. (Please try again with a smaller file.)" error message
@javascript
Scenario: Unsuccessful avatar image upload, file is invalid
Given I'm on the profile page
Then I click on image within ".avatar-container" element
And I attach a "File.txt" file to "user_avatar_input" field
And I should see "invalid file extension" error message under "user_avatar_input" field
And I attach a "File.txt" file to "user_avatar" field
And I click "Upload" button
And I should see "Avatar content type is invalid" error message
@javascript
Scenario: Successful upload avatar image
Given I'm on the profile page
Then I click on image within ".avatar-container" element
And I attach a "Star.png" file to "user_avatar_input" field
And I attach a "Star.png" file to "user_avatar" field
Then I click "Upload" button
And I should see "Your account has been updated successfully" flash message
@javascript
Scenario: Successfully changes user full name
Given I'm on the profile page
Then I click on Edit on "settings_page.full_name" input field
And I fill in "Karli Novak Novakovic" in "settings_page.full_name" input field
Then I click on Edit on ".settings-page-full-name" input field
And I fill in "Karli Novak Novakovic" in ".settings-page-full-name" input field
Then I click "Update" button
And I should see "Karli Novak Novakovic" in "settings_page.full_name" input field
And I should see "Karli Novak Novakovic" in ".settings-page-full-name" input field
@javascript
Scenario: Unsuccessfully changes user initials, text is too long
Given I'm on the profile page
Then I click on Edit on "settings_page.initials" input field
And I fill in "KNOCK" in "settings_page.initials" input field
And I should see "is too long (maximum is 4 characters)" error message under "settings_page.initials" field
Then I click on Edit on ".settings-page-initials" input field
And I fill in "KNOCK" in ".settings-page-initials" input field
Then I click "Update" button
And I should see "is too long (maximum is 4 characters)" error message
@javascript
Scenario: Successfully changes user initials
Given I'm on the profile page
Then I click on Edit on "settings_page.initials" input field
And I fill in "KN" in "settings_page.initials" input field
Then I click on Edit on ".settings-page-initials" input field
And I fill in "KN" in ".settings-page-initials" input field
Then I click "Update" button
And I should see "KN" in "settings_page.initials" input field
And I should see "KN" in ".settings-page-initials" input field
@javascript
Scenario: Successfully changes user email
Given I'm on the profile page
Then I click on Edit on "settings_page.email" input field
Then I click on Edit on ".settings-page-email" input field
And I change "nonadmin@myorg.com" with "user@myorg.com" email
And I fill in "mypassword1234" in Current password field
And I fill in "mypassword1234" in "Current password" field of ".settings-page-email" form
Then I click "Update" button
And I should see "user@myorg.com" in "settings_page.email" input field
And I should see "user@myorg.com" in ".settings-page-email" input field
@javascript
Scenario: Unsuccessful Password Change, password is too short
Given I'm on the profile page
Then I click on Edit on "settings_page.change_password" input field
And I fill in "mypassword1234" in Current password field
And I fill in "mypass" in New password field
And I fill in "mypass" in New password confirmation field
Then I click on Edit on ".settings-page-change-password" input field
And I fill in "mypassword1234" in "Current password" field of ".settings-page-change-password" form
And I fill in "mypass" in "New password" field of ".settings-page-change-password" form
And I fill in "mypass" in "New password confirmation" field of ".settings-page-change-password" form
Then I click "Update" button
And I should see "is too short (minimum is 8 characters)"
@javascript
Scenario: Unsuccessful Password Change, passwords does not match
Given I'm on the profile page
Then I click on Edit on "settings_page.change_password" input field
And I fill in "mypassword1234" in Current password field
And I fill in "mypassword5678" in New password field
And I fill in "mypassword56788" in New password confirmation field
Then I click on Edit on ".settings-page-change-password" input field
And I fill in "mypassword1234" in "Current password" field of ".settings-page-change-password" form
And I fill in "mypassword5678" in "New password" field of ".settings-page-change-password" form
And I fill in "mypassword56788" in "New password confirmation" field of ".settings-page-change-password" form
Then I click "Update" button
And I should see "doesn't match"
@javascript
Scenario: Unsuccessful Password Change, current password is invalid
Given I'm on the profile page
Then I click on Edit on "settings_page.change_password" input field
And I fill in "mypassword123" in Current password field
And I fill in "mypassword5678" in New password field
And I fill in "mypassword5678" in New password confirmation field
Then I click on Edit on ".settings-page-change-password" input field
And I fill in "mypassword123" in "Current password" field of ".settings-page-change-password" form
And I fill in "mypassword5678" in "New password" field of ".settings-page-change-password" form
And I fill in "mypassword5678" in "New password confirmation" field of ".settings-page-change-password" form
Then I click "Update" button
And I should see "incorrect password"
And I should see "is invalid"
@javascript
Scenario: Successful Password Change
Given I'm on the profile page
Then I click on Edit on "settings_page.change_password" input field
And I fill in "mypassword1234" in Current password field
And I fill in "mypassword5678" in New password field
And I fill in "mypassword5678" in New password confirmation field
Then I click on Edit on ".settings-page-change-password" input field
And I fill in "mypassword1234" in "Current password" field of ".settings-page-change-password" form
And I fill in "mypassword5678" in "New password" field of ".settings-page-change-password" form
And I fill in "mypassword5678" in "New password confirmation" field of ".settings-page-change-password" form
Then I click "Update" button
And I should see "Your account has been updated successfully" flash message
And I should see "Password successfully updated." flash message

View file

@ -18,26 +18,26 @@ Feature: Team settings
@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 on team title
And I change "BioSistemika Process" with "BioSistemika Process Company" in "team-name-modal" input field
Then I click "Update" button
And I should see "BioSistemika Process Company" on ".team-name-title" element
And I should see "BioSistemika Process Company" on "#team-name" 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 on ".description-label" element
And I fill in "I was on Triglav one summer." in "team_description" textarea field
Then I click "Update" button
And I should see "I was on Triglav one summer." on ".team-description" element
And I should see "I was on Triglav one summer." on ".description-label" 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 on ".description-label" element
And I change "Lorem ipsum dolor sit amet, consectetuer adipiscing eli." with "I was on Triglav one summer." in "team_description" textarea field
Then I click "Update" button
And I should see "I was on Triglav one summer." on ".team-description" element
And I should see "I was on Triglav one summer." on ".description-label" element
@javascript
Scenario: Successfully changes user role
@ -65,6 +65,6 @@ Feature: Team settings
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
And I should see "Are you sure you wish to remove user Suazana Novak from team BioSistemika Process?"
Then I click "Remove user" button
Then I should not see "suazana@myorg.com" in Team members table

View file

@ -3,7 +3,7 @@ Then(/^I click on Avatar$/) do
end
Given(/^I'm on the profile page$/) do
visit '/settings/account/profile'
visit edit_user_registration_path
end
Then(/^I click on Browse button$/) do
@ -15,15 +15,8 @@ Then(/^I change "([^"]*)" with "([^"]*)" email$/) do |prev_email, new_email|
find(:css, "input[value='#{prev_email}']").set(new_email)
end
Then(/^I fill in "([^"]*)" in Current password field$/) do |password|
find(:css, 'input[id="settings_page.current_password"]').set(password)
end
Then(/^I fill in "([^"]*)" in New password field$/) do |password|
find(:css, 'input[id="settings_page.new_password"]').set(password)
end
Then(/^I fill in "([^"]*)" in New password confirmation field$/) do |password|
find(:css,
'input[id="settings_page.new_password_confirmation"]').set(password)
Then(/^I fill in "([^"]*)" in "([^"]*)" field of "([^"]*)" form$/) do |password, field, form_id|
within form_id do
fill_in field, with: password
end
end

View file

@ -60,10 +60,9 @@ Then(/^I attach a "([^"]*)" file to "([^"]*)" field$/) do |file, field_id|
sleep(0.5)
end
Then(/^I should see "([^"]*)" error message under "([^"]*)" field$/) do |message, field_id|
Then(/^I should see "([^"]*)" error message$/) do |message|
wait_for_ajax
parent = find_by_id(field_id).first(:xpath, './/..')
expect(parent).to have_content(message)
expect(page).to have_content(message)
end
Then(/^I click on "([^"]*)"$/) do |button|
@ -85,18 +84,21 @@ end
Then(/^I click on Edit on "([^"]*)" input field$/) do |container_id|
wait_for_ajax
container = page.find_by_id(container_id)
within(container) do
find('button').click
within(container_id) do
find('[data-action="edit"]').click
end
end
Then(/^I fill in "([^"]*)" in "([^"]*)" input field$/) do |text, input_id|
page.find_by_id(input_id).set(text)
page.find("#{input_id} input[type=\"text\"]").set(text)
end
Then(/^I fill in "([^"]*)" in "([^"]*)" field$/) do |text, input_id|
page.find(input_id).set(text)
end
Then(/^I should see "([^"]*)" in "([^"]*)" input field$/) do |text, container_id|
container = page.find_by_id(container_id)
container = page.find(container_id)
expect(container).to have_xpath("//input[@value='#{text}']")
end
@ -109,6 +111,7 @@ Then(/^(?:|I )click on "([^"]*)" element$/) do |selector|
end
Then(/^I change "([^"]*)" with "([^"]*)" in "([^"]*)" input field$/) do |old_text, new_text, container_id|
wait_for_ajax
container = page.find_by_id(container_id)
expect(container).to have_xpath("//input[@value='#{old_text}']")
container.find('input').set(new_text)

View file

@ -1,12 +1,12 @@
Given(/^I'm on "([^"]*)" team settings page$/) do |team_name|
team = Team.find_by_name(team_name)
visit '/settings/teams/' + team.id.to_s
visit team_path(team)
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
parent.find('[type="button"]').click
end
Then(/^I click "(.+)" link within "(.+)" actions dropdown within Team members table$/) do |role, email|
@ -28,3 +28,7 @@ end
Then(/^I should not see "([^"]*)" in Team members table$/) do |email|
expect(page).to have_no_css('td', text: /\A#{email}\z/)
end
Then(/^I click on team title$/) do
find('#team-name').click
end

View file

@ -38,13 +38,14 @@ World(Capybara::Email::DSL)
# Precompile webpacker to avoid render bugs in capybara webkit
# global hook throws an error :( https://github.com/cucumber/cucumber/wiki/Hooks
compiled = false
Before do
unless compiled
system('NODE_ENV=production bundle exec rails webpacker:compile')
compiled = true
end
end
# No need to run webpacker since we don't user React in the momemnt
# compiled = false
# Before do
# unless compiled
# system('NODE_ENV=production bundle exec rails webpacker:compile')
# compiled = true
# end
# end
# Capybara defaults to CSS3 selectors rather than XPath.
# If you'd prefer to use XPath, just uncomment this line and adjust any

View file

@ -1,11 +1,19 @@
# wait_for_ajax implementation for axios library
# def wait_for_ajax
# counter = 0
# while page.evaluate_script('window.IN_REQUEST')
# counter += 1
# sleep(0.1)
# if (0.1 * counter) >= Capybara.default_max_wait_time
# raise "AJAX request took longer than " \
# "#{Capybara.default_max_wait_time} seconds."
# end
# end
# end
# Jquery implementation
def wait_for_ajax
counter = 0
while page.evaluate_script('window.IN_REQUEST')
counter += 1
sleep(0.1)
if (0.1 * counter) >= Capybara.default_max_wait_time
raise "AJAX request took longer than " \
"#{Capybara.default_max_wait_time} seconds."
end
Timeout.timeout(Capybara.default_max_wait_time) do
loop until page.evaluate_script('jQuery.active').zero?
end
end
end

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::ActivitiesController, type: :controller do
describe ClientApi::ActivitiesController, type: :controller, broken: true do
login_user
render_views

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::ConfigurationsController, type: :controller do
describe ClientApi::ConfigurationsController, type: :controller, broken: true do
login_user
describe '#about_scinote' do

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::NotificationsController, type: :controller do
describe ClientApi::NotificationsController, type: :controller, broken: true do
login_user
let(:notification) { create :notification }
let(:user_notification) do

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::PermissionsController, type: :controller do
describe ClientApi::PermissionsController, type: :controller, broken: true do
login_user
describe '#status' do

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::Teams::TeamsController, type: :controller do
describe ClientApi::Teams::TeamsController, type: :controller, broken: true do
login_user
before do

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::Users::InvitationsController, type: :controller do
describe ClientApi::Users::InvitationsController, type: :controller, broken: true do
login_user
let(:user_one) { User.first }
let(:team_one) { create :team }

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::Users::UserTeamsController, type: :controller do
describe ClientApi::Users::UserTeamsController, type: :controller, broken: true do
login_user
let(:user_one) { User.first }
let(:user_two) { create :user, email: Faker::Internet.email }

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe ClientApi::Users::UsersController, type: :controller do
describe ClientApi::Users::UsersController, type: :controller, broken: true do
login_user
before do

View file

@ -84,6 +84,8 @@ RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
config.include ApiHelper, type: :controller
config.extend ControllerMacros, type: :controller
config.filter_run_excluding broken: true
end
# config shoulda matchers to work with rspec