From 9713be961290b7ea6ec5ce41bf8c2455338e755e Mon Sep 17 00:00:00 2001 From: natalypatti Date: Mon, 2 Dec 2019 23:18:45 -0300 Subject: [PATCH 01/21] caminho triste cadastrar conta --- src/app/features/001_sign_up.feature | 8 ++++++- .../step_definitions/sign_up_steps.rb | 21 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/app/features/001_sign_up.feature b/src/app/features/001_sign_up.feature index f5703770..0e2951db 100644 --- a/src/app/features/001_sign_up.feature +++ b/src/app/features/001_sign_up.feature @@ -15,4 +15,10 @@ Scenario: User creates a new account successfully checking the checkbox to see n When I fill the user registration form And I check the checkbox to see the page's wizard And I click the Cadastrar button - Then I should see the page's wizard \ No newline at end of file + Then I should see the page's wizard + +Scenario: User try to create a new account with invalid data + Given I am on the create account page + When I fill the user registration form with invalid data + And I click the Cadastrar button + Then I should see the red failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/sign_up_steps.rb b/src/app/features/step_definitions/sign_up_steps.rb index b7cffac7..a6eb7b9f 100644 --- a/src/app/features/step_definitions/sign_up_steps.rb +++ b/src/app/features/step_definitions/sign_up_steps.rb @@ -78,4 +78,23 @@ Then /^I should see the page's wizard$/ do expect(page).to have_xpath('.//div[@class="jumbotron"]/h2', text: 'Páginas de instituições próximas') end - \ No newline at end of file + +When (/^I fill the user registration form with invalid data$/) do + @user = FactoryBot.build(:user) + + fill_in "user[email]", with: @user.email + fill_in "user[nickname]", with: @user.nickname + fill_in "user[first_name]", with: @user.first_name + fill_in "user[last_name]", with: @user.last_name + fill_in "user[birth_date]", with: @user.birth_date + fill_in "user[password]", with: @user.password + fill_in "user[password_confirmation]", with: 'senha errada' + fill_in "user[country]", with: @user.country + fill_in "user[state]", with: @user.state + fill_in "user[city]", with: @user.city + attach_file("user[profile_picture]", 'features/upload-files/icon-384x384.png') +end + +Then (/^I should see the red failed toast$/) do + expect(page).to have_xpath('.//div[@class="alert alert-danger"]') +end \ No newline at end of file From 91e431b9f4da467072c2c6815374bf3617650a7d Mon Sep 17 00:00:00 2001 From: natalypatti Date: Mon, 2 Dec 2019 23:35:32 -0300 Subject: [PATCH 02/21] login caminho triste --- src/app/features/002_login_click.feature | 8 +++++++- src/app/features/step_definitions/login_steps.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/app/features/002_login_click.feature b/src/app/features/002_login_click.feature index ab3f80d9..42fa5a5e 100644 --- a/src/app/features/002_login_click.feature +++ b/src/app/features/002_login_click.feature @@ -11,4 +11,10 @@ Scenario: student clicks the login button Given I am on the login page When I fill the login form with login information And I click the Entrar button - Then I should see the initial user page \ No newline at end of file + Then I should see the initial user page + +Scenario: student fill user login with invalid data + Given I am on the login page + When I fill the login form with invalid login information + And I click the Entrar button + Then I should see the failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/login_steps.rb b/src/app/features/step_definitions/login_steps.rb index a2a4ac60..4979af4b 100644 --- a/src/app/features/step_definitions/login_steps.rb +++ b/src/app/features/step_definitions/login_steps.rb @@ -11,6 +11,16 @@ expect(page).to have_xpath('.//input[@id="pages-menu-access"]') end +When(/^I fill the login form with invalid login information$/) do + fill_in "Email ou usuário", :with => "email errado" + fill_in "Senha", :with => "senha errada" +end + +Then("I should see the failed toast") do + expect(page).to have_xpath('.//div[@class="alert alert-danger alert-dismissible"]') +end + + # - - - Given (/^I logged in successfully$/) do From 9557418f41404c6e16c63af0bea470c85b238b85 Mon Sep 17 00:00:00 2001 From: natalypatti Date: Mon, 2 Dec 2019 23:40:26 -0300 Subject: [PATCH 03/21] criar college page caminho triste --- src/app/features/003_create_page_click.feature | 8 +++++++- .../step_definitions/create_page_click_steps.rb | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/app/features/003_create_page_click.feature b/src/app/features/003_create_page_click.feature index dfdcf833..4f04d24e 100644 --- a/src/app/features/003_create_page_click.feature +++ b/src/app/features/003_create_page_click.feature @@ -11,4 +11,10 @@ Scenario: spotted page manager clicks the create new page button with valid data Given I am on the create new page page When I fill the create new page form And I click the Cadastrar button - Then I should see the initial user page \ No newline at end of file + Then I should see the initial user page + +Scenario: spotted page manager clicks the create new page button with invalid data + Given I am on the create new page page + When I fill the create new page form with invalid data + And I click the Cadastrar button + Then I should see the red failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/create_page_click_steps.rb b/src/app/features/step_definitions/create_page_click_steps.rb index cf952970..f85e6c2d 100644 --- a/src/app/features/step_definitions/create_page_click_steps.rb +++ b/src/app/features/step_definitions/create_page_click_steps.rb @@ -16,6 +16,20 @@ select 'Não', from: "college[request_to_participate]" end +When("I fill the create new page form with invalid data") do + fill_in "college[name]", with: "" + fill_in "college[initials]", with: "UT001" + fill_in "college[city]", with: "São Paulo" + fill_in "college[state]", with: "SP" + fill_in "college[country]", with: "Brasil" + fill_in "college[unit]", with: "Faculdade Teste 001" + fill_in "college[background_color]", with: "#fafafa" + fill_in "college[font_family]", with: "Arial" + fill_in "college[font_color]", with: "#000000" + select 'Manual', from: "college[admin_approves_spotted]" + select 'Não', from: "college[request_to_participate]" +end + # - - - Given(/^There is a college page created$/) do From 136f1115ad3e3de88695d8e5835080b338379493 Mon Sep 17 00:00:00 2001 From: natalypatti Date: Tue, 3 Dec 2019 00:17:52 -0300 Subject: [PATCH 04/21] empty college page test --- src/app/features/003_create_page_click.feature | 2 +- src/app/features/access_college_page.feature | 12 ++++++++---- .../step_definitions/access_college_page_steps.rb | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/app/features/003_create_page_click.feature b/src/app/features/003_create_page_click.feature index 4f04d24e..f7adda2b 100644 --- a/src/app/features/003_create_page_click.feature +++ b/src/app/features/003_create_page_click.feature @@ -17,4 +17,4 @@ Scenario: spotted page manager clicks the create new page button with invalid da Given I am on the create new page page When I fill the create new page form with invalid data And I click the Cadastrar button - Then I should see the red failed toast \ No newline at end of file + Then I should see the red failed toast diff --git a/src/app/features/access_college_page.feature b/src/app/features/access_college_page.feature index 594efdd3..4e5aa01f 100644 --- a/src/app/features/access_college_page.feature +++ b/src/app/features/access_college_page.feature @@ -4,11 +4,15 @@ As a student I want to access a college page So that I can check spotteds and content of that page -Background: I am logged in and there is a college page already created +Background: I am logged in Given I logged in successfully - And I created a college page - + Scenario: student clicks on a college link at the colleges menu and access the college page - Given I am on the colleges menu + Given I created a college page + And I am on the colleges menu When I click on my college page link Then I should see my college page + +Scenario: student is on college page but there is no college + Given I am on the colleges menu + Then I should see empty college page menu diff --git a/src/app/features/step_definitions/access_college_page_steps.rb b/src/app/features/step_definitions/access_college_page_steps.rb index a8a7f862..1a2c3b54 100644 --- a/src/app/features/step_definitions/access_college_page_steps.rb +++ b/src/app/features/step_definitions/access_college_page_steps.rb @@ -15,6 +15,10 @@ expect(page).to have_xpath('.//h2', text: "Universidade Teste 003") end +Then("I should see empty college page menu") do + page.should have_no_content('#star-white') +end + # - - - Given (/^I accessed a college page successfully$/) do From f2e63043445aa63eb5b7768e3b2906167f96f6ef Mon Sep 17 00:00:00 2001 From: natalypatti Date: Tue, 3 Dec 2019 22:59:56 -0300 Subject: [PATCH 05/21] caminho triste nickname sign_up --- src/app/features/001_sign_up.feature | 7 +++++++ .../features/step_definitions/sign_up_steps.rb | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/app/features/001_sign_up.feature b/src/app/features/001_sign_up.feature index 0e2951db..a3aa6326 100644 --- a/src/app/features/001_sign_up.feature +++ b/src/app/features/001_sign_up.feature @@ -21,4 +21,11 @@ Scenario: User try to create a new account with invalid data Given I am on the create account page When I fill the user registration form with invalid data And I click the Cadastrar button + Then I should see the red failed toast + +Scenario: User try to create a new account with existing user id + Given There is an unregistered user + And I am on the create account page + When I fill the user registration form with existing user id + And I click the Cadastrar button Then I should see the red failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/sign_up_steps.rb b/src/app/features/step_definitions/sign_up_steps.rb index a6eb7b9f..877d784d 100644 --- a/src/app/features/step_definitions/sign_up_steps.rb +++ b/src/app/features/step_definitions/sign_up_steps.rb @@ -94,6 +94,22 @@ fill_in "user[city]", with: @user.city attach_file("user[profile_picture]", 'features/upload-files/icon-384x384.png') end + +When (/^I fill the user registration form with existing user id$/) do + @user = FactoryBot.build(:user) + + fill_in "user[email]", with: @user.email + fill_in "user[nickname]", with: 'teste002.user' + fill_in "user[first_name]", with: @user.first_name + fill_in "user[last_name]", with: @user.last_name + fill_in "user[birth_date]", with: @user.birth_date + fill_in "user[password]", with: @user.password + fill_in "user[password_confirmation]", with: @user.password_confirmation + fill_in "user[country]", with: @user.country + fill_in "user[state]", with: @user.state + fill_in "user[city]", with: @user.city + attach_file("user[profile_picture]", 'features/upload-files/icon-384x384.png') +end Then (/^I should see the red failed toast$/) do expect(page).to have_xpath('.//div[@class="alert alert-danger"]') From c027ad6fafaa408ff9a61413d4b9b4ca83519778 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 00:13:17 -0300 Subject: [PATCH 06/21] Fazer testes com navegador aberto funcionar --- src/app/features/support/env.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/features/support/env.rb b/src/app/features/support/env.rb index 44a7cffc..80f7b872 100644 --- a/src/app/features/support/env.rb +++ b/src/app/features/support/env.rb @@ -62,5 +62,7 @@ require 'report_builder' -# Capybara.javascript_driver = :selenium_chrome #roda no navegador -# Capybara.javascript_driver = :selenium_chrome_headless #roda com o nageador em background \ No newline at end of file +# Capybara.configure do |config| +# config.default_driver = :selenium_chrome #roda no navegador +# # config.default_driver = :selenium_chrome_headless #roda com o nageador em background +# end \ No newline at end of file From 435c126f4f0c3b1b89bbdc78e1ebf159b730ae3c Mon Sep 17 00:00:00 2001 From: natalypatti Date: Wed, 4 Dec 2019 00:56:20 -0300 Subject: [PATCH 07/21] delete college caminho triste --- src/app/features/delete_college.feature | 7 ++++++- .../features/delete_pages_administrator.feature | 14 +++++++------- .../step_definitions/delete_college_steps.rb | 5 +++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/features/delete_college.feature b/src/app/features/delete_college.feature index 01c0f4b1..e2e70894 100644 --- a/src/app/features/delete_college.feature +++ b/src/app/features/delete_college.feature @@ -12,4 +12,9 @@ Scenario: Delete a college page when I go to edit page settings and click the "A Given I am on the edit page settings page When I click the Apagar a página button And I am on the colleges menu page - Then The college page shouldn't be exist anymore \ No newline at end of file + Then The college page shouldn't be exist anymore + +Scenario: User tries to delete a college that he is not admin + Given There is a college page created + And I am on the colleges menu + Then I cant find that college Editar button \ No newline at end of file diff --git a/src/app/features/delete_pages_administrator.feature b/src/app/features/delete_pages_administrator.feature index b6e771df..0adc2108 100644 --- a/src/app/features/delete_pages_administrator.feature +++ b/src/app/features/delete_pages_administrator.feature @@ -5,13 +5,13 @@ I want to delete a administrator of the page So that i can manage the page administration resposibility Background: -Given I logged in successfully -And I created a college page -And I already defined the user as administrator + Given I logged in successfully + And I created a college page + And I already defined the user as administrator Scenario: Administrator choose othe administrator to be exclude clicking on the trash buttom -Given I am on the page's list of administrators -When I click on the trash button associated with a administrator -Then I should see the list without the administrator that I choose -And I should see a success message + Given I am on the page's list of administrators + When I click on the trash button associated with a administrator + Then I should see the list without the administrator that I choose + And I should see a success message diff --git a/src/app/features/step_definitions/delete_college_steps.rb b/src/app/features/step_definitions/delete_college_steps.rb index bca530cd..0288c16c 100644 --- a/src/app/features/step_definitions/delete_college_steps.rb +++ b/src/app/features/step_definitions/delete_college_steps.rb @@ -1,3 +1,8 @@ Then(/^The college page shouldn't be exist anymore$/) do expect(page).not_to have_link('Editar', href: '/colleges/#{@college.id}/edit') +end + +Then(/^I cant find that college Editar button$/) do + element = find('.summary', text: 'UT002 - Faculdade Teste 002') + expect(element).not_to have_link('Editar') end \ No newline at end of file From 01da833dee0b5e79d13d81011774ebe09b6083a5 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 00:58:17 -0300 Subject: [PATCH 08/21] Making sign_up feature DRY --- src/app/features/001_sign_up.feature | 32 +++++-- .../step_definitions/sign_up_steps.rb | 87 +++++++------------ 2 files changed, 57 insertions(+), 62 deletions(-) diff --git a/src/app/features/001_sign_up.feature b/src/app/features/001_sign_up.feature index a3aa6326..85d7061e 100644 --- a/src/app/features/001_sign_up.feature +++ b/src/app/features/001_sign_up.feature @@ -4,28 +4,48 @@ As a user I want to create an account So that I can use the application -Scenario: User creates a new account filling all fields filled with valid data +Scenario: User creates a new account filling all fields with valid data Given I am on the create account page When I fill the user registration form + When I attach a profile picture And I click the Cadastrar button Then I should see the welcome page -Scenario: User creates a new account successfully checking the checkbox to see near colleges +Scenario: User creates a new account successfully and check the option to see near colleges Given I am on the create account page When I fill the user registration form + When I attach a profile picture And I check the checkbox to see the page's wizard And I click the Cadastrar button Then I should see the page's wizard -Scenario: User try to create a new account with invalid data +Scenario Outline: User try to create a new account with invalid data Given I am on the create account page - When I fill the user registration form with invalid data + When I fill the user registration form + When I fill in "
" with "" + When I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast -Scenario: User try to create a new account with existing user id + Examples: + | form field | value | + | user_email | emailinvalido.com | + | user_password_confirmation | senha errada | + +Scenario: User try to create a new account with invalid password format + Given I am on the create account page + When I fill the user registration form + When I fill in "user_password" with "cinco" + When I fill in "user_password_confirmation" with "cinco" + When I attach a profile picture + And I click the Cadastrar button + Then I should see the red failed toast + +Scenario: User try to create a new account with existing user nickname Given There is an unregistered user And I am on the create account page - When I fill the user registration form with existing user id + When I fill the user registration form + When I fill in "user_nickname" with "teste002.user" + When I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/sign_up_steps.rb b/src/app/features/step_definitions/sign_up_steps.rb index 877d784d..f70c861d 100644 --- a/src/app/features/step_definitions/sign_up_steps.rb +++ b/src/app/features/step_definitions/sign_up_steps.rb @@ -2,19 +2,26 @@ visit new_user_path end -When(/^I fill the user registration form$/) do - @user = FactoryBot.build(:user) +When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| + fill_in(field.gsub(' ', '_'), :with => value) +end + +When /^I fill the user registration form$/ do + steps %Q{ + When I fill in "user_first_name" with "teste001" + When I fill in "user_last_name" with "user" + When I fill in "user_nickname" with "teste001.user" + When I fill in "user_birth_date" with "1998-10-25" + When I fill in "user_email" with "teste001.user@spottapp.com.br" + When I fill in "user_password" with "teste001user" + When I fill in "user_password_confirmation" with "teste001user" + When I fill in "user_country" with "Brasil" + When I fill in "user_state" with "SP" + When I fill in "user_city" with "São Paulo" + } +end - fill_in "user[email]", with: @user.email - fill_in "user[nickname]", with: @user.nickname - fill_in "user[first_name]", with: @user.first_name - fill_in "user[last_name]", with: @user.last_name - fill_in "user[birth_date]", with: @user.birth_date - fill_in "user[password]", with: @user.password - fill_in "user[password_confirmation]", with: @user.password_confirmation - fill_in "user[country]", with: @user.country - fill_in "user[state]", with: @user.state - fill_in "user[city]", with: @user.city +When /^I attach a profile picture$/ do attach_file("user[profile_picture]", 'features/upload-files/icon-384x384.png') end @@ -22,12 +29,24 @@ click_button button_name end +When /^I check the checkbox to see the page's wizard$/ do + find(:css, "#checkbox").set(true) +end + Then(/^I should see the welcome page$/) do expect(page).to have_xpath('.//div[@class="alert alert-success alert-dismissible"]') expect(page).to have_xpath('.//form[@action="/users/new"]') expect(page).to have_xpath('.//form[@action="/entrar"]') end +Then /^I should see the page's wizard$/ do + expect(page).to have_xpath('.//div[@class="jumbotron"]/h2', text: 'Páginas de instituições próximas') +end + +Then (/^I should see the red failed toast$/) do + expect(page).to have_xpath('.//div[@class="alert alert-danger"]') +end + # - - - Given(/^I have an account$/) do @@ -69,48 +88,4 @@ u.save @user = User.find_by(nickname: "teste003.user") -end - -When /^I check the checkbox to see the page's wizard$/ do - find(:css, "#checkbox").set(true) -end - -Then /^I should see the page's wizard$/ do - expect(page).to have_xpath('.//div[@class="jumbotron"]/h2', text: 'Páginas de instituições próximas') -end - -When (/^I fill the user registration form with invalid data$/) do - @user = FactoryBot.build(:user) - - fill_in "user[email]", with: @user.email - fill_in "user[nickname]", with: @user.nickname - fill_in "user[first_name]", with: @user.first_name - fill_in "user[last_name]", with: @user.last_name - fill_in "user[birth_date]", with: @user.birth_date - fill_in "user[password]", with: @user.password - fill_in "user[password_confirmation]", with: 'senha errada' - fill_in "user[country]", with: @user.country - fill_in "user[state]", with: @user.state - fill_in "user[city]", with: @user.city - attach_file("user[profile_picture]", 'features/upload-files/icon-384x384.png') -end - -When (/^I fill the user registration form with existing user id$/) do - @user = FactoryBot.build(:user) - - fill_in "user[email]", with: @user.email - fill_in "user[nickname]", with: 'teste002.user' - fill_in "user[first_name]", with: @user.first_name - fill_in "user[last_name]", with: @user.last_name - fill_in "user[birth_date]", with: @user.birth_date - fill_in "user[password]", with: @user.password - fill_in "user[password_confirmation]", with: @user.password_confirmation - fill_in "user[country]", with: @user.country - fill_in "user[state]", with: @user.state - fill_in "user[city]", with: @user.city - attach_file("user[profile_picture]", 'features/upload-files/icon-384x384.png') -end - -Then (/^I should see the red failed toast$/) do - expect(page).to have_xpath('.//div[@class="alert alert-danger"]') end \ No newline at end of file From ac06c22b2c066242d068c7c5e7355497bf5a03a2 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 01:09:25 -0300 Subject: [PATCH 09/21] More tests for invalid fields on sign_up test --- src/app/features/001_sign_up.feature | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/features/001_sign_up.feature b/src/app/features/001_sign_up.feature index 85d7061e..4cce0bff 100644 --- a/src/app/features/001_sign_up.feature +++ b/src/app/features/001_sign_up.feature @@ -29,8 +29,20 @@ Scenario Outline: User try to create a new account with invalid data Examples: | form field | value | + | user_first_name | | + | user_last_name | | + | user_nickname | | + | user_birth_date | | + | user_email | | | user_email | emailinvalido.com | - | user_password_confirmation | senha errada | + | user_email | emailinvalido@empresa | + | user_password | | + | user_password_confirmation | | + | user_password_confirmation | confirmacao errada | + | user_country | | + | user_state | | + | user_state | São Paulo | + | user_city | | Scenario: User try to create a new account with invalid password format Given I am on the create account page From 07307d7c952604f742cacb4d5520483c98958ea7 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 01:32:34 -0300 Subject: [PATCH 10/21] sign_up test code adjustment --- src/app/features/001_sign_up.feature | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/features/001_sign_up.feature b/src/app/features/001_sign_up.feature index 4cce0bff..98bd43ad 100644 --- a/src/app/features/001_sign_up.feature +++ b/src/app/features/001_sign_up.feature @@ -7,14 +7,14 @@ So that I can use the application Scenario: User creates a new account filling all fields with valid data Given I am on the create account page When I fill the user registration form - When I attach a profile picture + And I attach a profile picture And I click the Cadastrar button Then I should see the welcome page Scenario: User creates a new account successfully and check the option to see near colleges Given I am on the create account page When I fill the user registration form - When I attach a profile picture + And I attach a profile picture And I check the checkbox to see the page's wizard And I click the Cadastrar button Then I should see the page's wizard @@ -22,8 +22,8 @@ Scenario: User creates a new account successfully and check the option to see ne Scenario Outline: User try to create a new account with invalid data Given I am on the create account page When I fill the user registration form - When I fill in "" with "" - When I attach a profile picture + And I fill in "" with "" + And I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast @@ -48,8 +48,8 @@ Scenario: User try to create a new account with invalid password format Given I am on the create account page When I fill the user registration form When I fill in "user_password" with "cinco" - When I fill in "user_password_confirmation" with "cinco" - When I attach a profile picture + And I fill in "user_password_confirmation" with "cinco" + And I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast @@ -57,7 +57,7 @@ Scenario: User try to create a new account with existing user nickname Given There is an unregistered user And I am on the create account page When I fill the user registration form - When I fill in "user_nickname" with "teste002.user" - When I attach a profile picture + And I fill in "user_nickname" with "teste002.user" + And I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast \ No newline at end of file From 85445f2d6f826e833e6390c10c817c6b0b48ae8e Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 01:32:46 -0300 Subject: [PATCH 11/21] Making create_page test DRY --- .../features/003_create_page_click.feature | 26 ++++++-- .../create_page_click_steps.rb | 59 ++++++++++--------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/src/app/features/003_create_page_click.feature b/src/app/features/003_create_page_click.feature index f7adda2b..e379b252 100644 --- a/src/app/features/003_create_page_click.feature +++ b/src/app/features/003_create_page_click.feature @@ -1,20 +1,36 @@ Feature: Create a new page -As a spotted page manager +As a user I want to create a page to my educational institution -So that I can manage the page of my educational institution +So that there is a page to my educational institution on the app Background: I am logged in Given I logged in successfully -Scenario: spotted page manager clicks the create new page button with valid data and all fields filled except "background_image" +Scenario: User clicks the create new page button with valid data Given I am on the create new page page When I fill the create new page form + And I select manual approve + And I select to not request to participate And I click the Cadastrar button Then I should see the initial user page -Scenario: spotted page manager clicks the create new page button with invalid data +Scenario Outline: User clicks the create new page button with invalid data Given I am on the create new page page - When I fill the create new page form with invalid data + When I fill the create new page form + And I fill in "" with "" + And I select manual approve + And I select to not request to participate And I click the Cadastrar button Then I should see the red failed toast + + Examples: + | form field | value | + | college_name | | + | college_initials | nove letras | + | college_city | | + | college_state | | + | college_state | São Paulo | + | college_country | | + | college_font_color | | + | college_background_color | | \ No newline at end of file diff --git a/src/app/features/step_definitions/create_page_click_steps.rb b/src/app/features/step_definitions/create_page_click_steps.rb index f85e6c2d..7c8777c8 100644 --- a/src/app/features/step_definitions/create_page_click_steps.rb +++ b/src/app/features/step_definitions/create_page_click_steps.rb @@ -1,48 +1,53 @@ -Given (/^I am on the create new page page$/) do +Given /^I am on the create new page page$/ do visit new_college_path end -When (/^I fill the create new page form$/) do - fill_in "college[name]", with: "Universidade Teste 001" - fill_in "college[initials]", with: "UT001" - fill_in "college[city]", with: "São Paulo" - fill_in "college[state]", with: "SP" - fill_in "college[country]", with: "Brasil" - fill_in "college[unit]", with: "Faculdade Teste 001" - fill_in "college[background_color]", with: "#fafafa" - fill_in "college[font_family]", with: "Arial" - fill_in "college[font_color]", with: "#000000" - select 'Manual', from: "college[admin_approves_spotted]" - select 'Não', from: "college[request_to_participate]" +When /^I fill the create new page form$/ do + steps %Q{ + When I fill in "college_name" with "Universidade Teste 001" + When I fill in "college_initials" with "UT001" + When I fill in "college_city" with "São Paulo" + When I fill in "college_state" with "SP" + When I fill in "college_country" with "Brasil" + When I fill in "college_unit" with "Faculdade Teste 001" + When I fill in "college_background_color" with "#fafafa" + When I fill in "college_font_family" with "Arial" + When I fill in "college_font_color" with "#000000" + } end -When("I fill the create new page form with invalid data") do - fill_in "college[name]", with: "" - fill_in "college[initials]", with: "UT001" - fill_in "college[city]", with: "São Paulo" - fill_in "college[state]", with: "SP" - fill_in "college[country]", with: "Brasil" - fill_in "college[unit]", with: "Faculdade Teste 001" - fill_in "college[background_color]", with: "#fafafa" - fill_in "college[font_family]", with: "Arial" - fill_in "college[font_color]", with: "#000000" +When /^I select manual approve$/ do select 'Manual', from: "college[admin_approves_spotted]" +end + +When /^I select to not request to participate$/ do select 'Não', from: "college[request_to_participate]" end # - - - -Given(/^There is a college page created$/) do +Given /^There is a college page created$/ do steps %Q{ Given There is an unregistered user } - u = College.new(:name => "Universidade Teste 002", :initials => "UT002", :city => "São Paulo", :state => "SP", :country => "Brasil", :unit => "Faculdade Teste 002", :user_id => @user.id, :background_color => "fafafa", :font_family => "Arial", :background_image => "", :font_color => "#000000", :request_to_participate => 0) + u = College.new(:name => "Universidade Teste 002", + :initials => "UT002", + :city => "São Paulo", + :state => "SP", + :country => "Brasil", + :unit => "Faculdade Teste 002", + :user_id => @user.id, + :background_color => "fafafa", + :font_family => "Arial", + :background_image => "", + :font_color => "#000000", + :request_to_participate => 0) u.save @college = College.find_by(initials: "UT002") end -Given(/^I created a college page$/) do +Given /^I created a college page$/ do steps %Q{ Given I am on the create new page page When I fill the create new page form @@ -53,7 +58,7 @@ end -Given(/^There is a college page with request needed created$/) do +Given /^There is a college page with request needed created$/ do steps %Q{ Given There is another unregistered user } From 3318c8a426ae46ae18dee07cbcee357fabf3ad30 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 01:37:33 -0300 Subject: [PATCH 12/21] create_page test adjustment --- src/app/features/003_create_page_click.feature | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/features/003_create_page_click.feature b/src/app/features/003_create_page_click.feature index e379b252..ed72e7f6 100644 --- a/src/app/features/003_create_page_click.feature +++ b/src/app/features/003_create_page_click.feature @@ -26,11 +26,11 @@ Scenario Outline: User clicks the create new page button with invalid data Examples: | form field | value | - | college_name | | - | college_initials | nove letras | - | college_city | | - | college_state | | - | college_state | São Paulo | - | college_country | | - | college_font_color | | - | college_background_color | | \ No newline at end of file + | college name | | + | college initials | nove letras | + | college city | | + | college state | | + | college state | São Paulo | + | college country | | + | college font color | | + | college background color | | \ No newline at end of file From 1c29f18a548cc23d8477ce1abf7d0354d239e570 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 01:38:11 -0300 Subject: [PATCH 13/21] sign_up test adjustment --- src/app/features/001_sign_up.feature | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/app/features/001_sign_up.feature b/src/app/features/001_sign_up.feature index 98bd43ad..9a56fb8f 100644 --- a/src/app/features/001_sign_up.feature +++ b/src/app/features/001_sign_up.feature @@ -29,26 +29,26 @@ Scenario Outline: User try to create a new account with invalid data Examples: | form field | value | - | user_first_name | | - | user_last_name | | - | user_nickname | | - | user_birth_date | | - | user_email | | - | user_email | emailinvalido.com | - | user_email | emailinvalido@empresa | - | user_password | | - | user_password_confirmation | | - | user_password_confirmation | confirmacao errada | - | user_country | | - | user_state | | - | user_state | São Paulo | - | user_city | | + | user first name | | + | user last name | | + | user nickname | | + | user birth date | | + | user email | | + | user email | emailinvalido.com | + | user email | emailinvalido@empresa | + | user password | | + | user password confirmation | | + | user password confirmation | confirmacao errada | + | user country | | + | user state | | + | user state | São Paulo | + | user city | | Scenario: User try to create a new account with invalid password format Given I am on the create account page When I fill the user registration form - When I fill in "user_password" with "cinco" - And I fill in "user_password_confirmation" with "cinco" + When I fill in "user password" with "cinco" + And I fill in "user password confirmation" with "cinco" And I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast @@ -57,7 +57,7 @@ Scenario: User try to create a new account with existing user nickname Given There is an unregistered user And I am on the create account page When I fill the user registration form - And I fill in "user_nickname" with "teste002.user" + And I fill in "user nickname" with "teste002.user" And I attach a profile picture And I click the Cadastrar button Then I should see the red failed toast \ No newline at end of file From aca43c97f0ea3caab9c061ac742b4fa07b0bc5c4 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 02:06:19 -0300 Subject: [PATCH 14/21] Updating post_comment test --- src/app/features/post_comment.feature | 9 ++++----- src/app/features/receive_notification.feature | 2 +- .../step_definitions/access_college_page_steps.rb | 4 ++++ src/app/features/step_definitions/post_comment_steps.rb | 6 +++--- src/app/features/step_definitions/post_spotted_steps.rb | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/app/features/post_comment.feature b/src/app/features/post_comment.feature index f4c8972d..c417d317 100644 --- a/src/app/features/post_comment.feature +++ b/src/app/features/post_comment.feature @@ -5,14 +5,13 @@ I want to post a comment So that I can tell what I think about any spotted Background: - Given There is a college page created + Given There is a spotted created And I logged in successfully - And I accessed a college page successfully - And I posted a spotted successfully on the college page Scenario: student write a comment on the content field and clicks the button "Mandar Comentário" - Given I click the Ver spotted button - When I fill the content comment field with some information + Given I am on the college page + When I click the Ver spotted button + And I fill the content comment field with some information And I click the Mandar comentário button icon Then I should see the view spotted page And I should see my new comment on the timeline \ No newline at end of file diff --git a/src/app/features/receive_notification.feature b/src/app/features/receive_notification.feature index d3514a7f..ca7ef6cf 100644 --- a/src/app/features/receive_notification.feature +++ b/src/app/features/receive_notification.feature @@ -5,7 +5,7 @@ I want to receive notifications from spotted So that I can follow spotted updates Background: There is a spotted and a comment created - Given There is a comment + Given There is a comment created And I logged in successfully Scenario: Student clicks on bell button diff --git a/src/app/features/step_definitions/access_college_page_steps.rb b/src/app/features/step_definitions/access_college_page_steps.rb index 1a2c3b54..6b9f4dc0 100644 --- a/src/app/features/step_definitions/access_college_page_steps.rb +++ b/src/app/features/step_definitions/access_college_page_steps.rb @@ -44,4 +44,8 @@ When I click on my college page link Then I should see my college page } +end + +Given /^I am on the college page$/ do + visit college_spotteds_path(@college.id) end \ No newline at end of file diff --git a/src/app/features/step_definitions/post_comment_steps.rb b/src/app/features/step_definitions/post_comment_steps.rb index b65fcf68..5f87c767 100644 --- a/src/app/features/step_definitions/post_comment_steps.rb +++ b/src/app/features/step_definitions/post_comment_steps.rb @@ -7,7 +7,7 @@ end Then(/^I should see the view spotted page$/) do - expect(page).to have_xpath('.//h2', text: "Spotted n. 1") + expect(page).to have_xpath('.//h2', text: "Spotted n.") end And(/^I should see my new comment on the timeline$/) do @@ -33,9 +33,9 @@ end -Given (/^There is a comment$/) do +Given (/^There is a comment created$/) do steps %Q{ - Given There is a spotted + Given There is a spotted created } u = Comment.new(:content => "Comment Test", :user_id => @user.id, :spotted_id => @spotted.id) diff --git a/src/app/features/step_definitions/post_spotted_steps.rb b/src/app/features/step_definitions/post_spotted_steps.rb index 78f1beae..b482013d 100644 --- a/src/app/features/step_definitions/post_spotted_steps.rb +++ b/src/app/features/step_definitions/post_spotted_steps.rb @@ -38,7 +38,7 @@ @spotted = Spotted.find_by(content: "Spotted") end -Given (/^There is a spotted$/) do +Given (/^There is a spotted created$/) do steps %Q{ Given There is a college page created } From 285d69b221ea11cc1799456090e87b7fc1c4a2da Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 02:23:34 -0300 Subject: [PATCH 15/21] sign_up test adjustment --- src/app/features/step_definitions/sign_up_steps.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/features/step_definitions/sign_up_steps.rb b/src/app/features/step_definitions/sign_up_steps.rb index f70c861d..21a09c70 100644 --- a/src/app/features/step_definitions/sign_up_steps.rb +++ b/src/app/features/step_definitions/sign_up_steps.rb @@ -53,6 +53,7 @@ steps %Q{ Given I am on the create account page When I fill the user registration form + And I attach a profile picture And I click the Cadastrar button Then I should see the welcome page } From c3a996573867c00b942f7f4e016a40d2c9b32bca Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 4 Dec 2019 02:31:23 -0300 Subject: [PATCH 16/21] Commet area on a spotted CSS adjustment --- src/app/app/assets/stylesheets/spotted.scss | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/app/assets/stylesheets/spotted.scss b/src/app/app/assets/stylesheets/spotted.scss index ca7478c6..0bad8d7d 100644 --- a/src/app/app/assets/stylesheets/spotted.scss +++ b/src/app/app/assets/stylesheets/spotted.scss @@ -191,10 +191,11 @@ h2.title { #show .container-right .scroll { width: 100%; - height: calc(100% - 60px); - height: -moz-calc(100% - 60px); - height: -webkit-calc(100% - 60px); + height: calc(100% - 66px); + height: -moz-calc(100% - 66px); + height: -webkit-calc(100% - 66px); height: -o-calc(100% - 60px); + padding-top: 10px; overflow: auto; } From 24bc90da83ae4e82c4c3ed66b78f2b9cfde85b53 Mon Sep 17 00:00:00 2001 From: natalypatti Date: Wed, 4 Dec 2019 02:49:30 -0300 Subject: [PATCH 17/21] post_spotted caminho triste --- src/app/features/post_spotted.feature | 8 +++++++- src/app/features/step_definitions/post_spotted_steps.rb | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/features/post_spotted.feature b/src/app/features/post_spotted.feature index c4d4354b..1f4008df 100644 --- a/src/app/features/post_spotted.feature +++ b/src/app/features/post_spotted.feature @@ -14,4 +14,10 @@ Scenario: student write a spotted on the content field and clicks the button "Ma When I fill the content spotted field with some information And I click the Mandar spotted button Then I should see the college page - And I should see my new spotted on the timeline \ No newline at end of file + And I should see my new spotted on the timeline + +Scenario: student tries to post a spotted with empty content + Given I click the Novo spotted button + When I dont fill the content spotted field + And I click the Mandar spotted button + Then I should see the red failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/post_spotted_steps.rb b/src/app/features/step_definitions/post_spotted_steps.rb index b482013d..ac62da50 100644 --- a/src/app/features/step_definitions/post_spotted_steps.rb +++ b/src/app/features/step_definitions/post_spotted_steps.rb @@ -6,6 +6,10 @@ expect(page).to have_xpath('.//div', text: "Spotted Teste") end +When("I dont fill the content spotted field") do + fill_in "spotted[content]", with: "" +end + # - - - Given (/^I posted a spotted successfully on the college page$/) do From e83a33e7b35b0ff95d28879ce6cca3a35738444f Mon Sep 17 00:00:00 2001 From: natalypatti Date: Wed, 4 Dec 2019 02:54:04 -0300 Subject: [PATCH 18/21] post_comment caminho triste --- src/app/features/post_comment.feature | 9 ++++++++- src/app/features/step_definitions/post_comment_steps.rb | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/features/post_comment.feature b/src/app/features/post_comment.feature index c417d317..82a8aec4 100644 --- a/src/app/features/post_comment.feature +++ b/src/app/features/post_comment.feature @@ -14,4 +14,11 @@ Scenario: student write a comment on the content field and clicks the button "Ma And I fill the content comment field with some information And I click the Mandar comentário button icon Then I should see the view spotted page - And I should see my new comment on the timeline \ No newline at end of file + And I should see my new comment on the timeline + +Scenario: student tries to post a comment with empty content + Given I am on the college page + When I click the Ver spotted button + And I dont fill the content comment field + And I click the Mandar comentário button icon + Then I should see the red failed toast \ No newline at end of file diff --git a/src/app/features/step_definitions/post_comment_steps.rb b/src/app/features/step_definitions/post_comment_steps.rb index 5f87c767..eae555a1 100644 --- a/src/app/features/step_definitions/post_comment_steps.rb +++ b/src/app/features/step_definitions/post_comment_steps.rb @@ -14,6 +14,10 @@ expect(page).to have_xpath('.//div', text: "Comment Teste") end +When(/^I dont fill the content comment field$/) do + fill_in "comment[content]", with: "" +end + # - - - Given (/^I posted a comment successfully$/) do @@ -43,3 +47,4 @@ @comment = Comment.find_by(content: "Comment Test") end + From 93764dd5ca4c0fe8b2497687d822bd7b8c4b5d21 Mon Sep 17 00:00:00 2001 From: natalypatti Date: Wed, 4 Dec 2019 03:25:00 -0300 Subject: [PATCH 19/21] update_user caminho triste --- src/app/features/update_user_data.feature | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/features/update_user_data.feature b/src/app/features/update_user_data.feature index 1e2e5007..cec6aa3d 100644 --- a/src/app/features/update_user_data.feature +++ b/src/app/features/update_user_data.feature @@ -5,6 +5,7 @@ I want to update my user data So that I can change my profile information Background: I am logged in + Given There is an unregistered user And I logged in successfully Scenario: Update my user data information @@ -12,4 +13,11 @@ Scenario: Update my user data information When I fill the username with a new username information And I fill the passwords fields And I click the Salvar button - Then I should see the green success toast \ No newline at end of file + Then I should see the green success toast + +Scenario: User tries to update user name with existing user name + Given I am on the edit user page + And I fill in "user nickname" with "teste002.user" + And I fill the passwords fields + And I click the Salvar button + Then I should see the red failed toast \ No newline at end of file From 60a0687b8d2c921a4150fe665cd1cbe58b1f3022 Mon Sep 17 00:00:00 2001 From: natalypatti Date: Wed, 4 Dec 2019 03:28:27 -0300 Subject: [PATCH 20/21] update_user caminho triste --- src/app/features/update_user_data.feature | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/features/update_user_data.feature b/src/app/features/update_user_data.feature index cec6aa3d..22e10a95 100644 --- a/src/app/features/update_user_data.feature +++ b/src/app/features/update_user_data.feature @@ -20,4 +20,11 @@ Scenario: User tries to update user name with existing user name And I fill in "user nickname" with "teste002.user" And I fill the passwords fields And I click the Salvar button + Then I should see the red failed toast + +Scenario: User tries to update user but put the wrong password + Given I am on the edit user page + And I fill in "user nickname" with "newuser.user" + And I fill in "user password_confirmation" with "wrong password" + And I click the Salvar button Then I should see the red failed toast \ No newline at end of file From dd256da4a92d003f8294a36eb5dd3ac32bf15274 Mon Sep 17 00:00:00 2001 From: natalypatti Date: Wed, 4 Dec 2019 03:36:28 -0300 Subject: [PATCH 21/21] receive_notification caminho triste --- src/app/features/receive_notification.feature | 12 +++++++++--- .../step_definitions/receive_notification_steps.rb | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/features/receive_notification.feature b/src/app/features/receive_notification.feature index ca7ef6cf..158f4f01 100644 --- a/src/app/features/receive_notification.feature +++ b/src/app/features/receive_notification.feature @@ -4,12 +4,18 @@ As a student I want to receive notifications from spotted So that I can follow spotted updates -Background: There is a spotted and a comment created +Scenario: Student clicks on bell button Given There is a comment created And I logged in successfully - -Scenario: Student clicks on bell button Given I accessed a college page successfully Given I click on Ativar Notificações And I click on bell button Then I should see my notifications + +Scenario: Student clicks on bell button but has no notification + Given There is a spotted created + And I logged in successfully + And I am on the college page + And I click on Ativar Notificações + And I click on bell button + Then I shouldnt see my notifications diff --git a/src/app/features/step_definitions/receive_notification_steps.rb b/src/app/features/step_definitions/receive_notification_steps.rb index f758b234..22f2328f 100644 --- a/src/app/features/step_definitions/receive_notification_steps.rb +++ b/src/app/features/step_definitions/receive_notification_steps.rb @@ -4,4 +4,8 @@ Then("I should see my notifications") do expect(page).to have_xpath('.//div', text: "Novo comentário") +end + +Then("I shouldnt see my notifications") do + expect(page).not_to have_xpath('.//div', text: "Novo comentário") end \ No newline at end of file