-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On #8: Article units integration tests
- Loading branch information
Showing
11 changed files
with
159 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
= link_to t('.add'), article_units_path(unit: unit), class: 'btn btn-mini', remote: true, method: :post, data: {'for-unit': unit} | ||
= link_to t('.add'), article_units_path(unit: unit), class: 'btn btn-mini', remote: true, method: :post, data: {'for-unit': unit, 'e2e-create-unit': unit} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
=link_to t('.delete'), article_unit, method: :delete, class: 'btn btn-mini btn-danger', remote: true, data: { confirm: t('.confirm'), 'for-unit': article_unit.unit } | ||
=link_to t('.delete'), article_unit, method: :delete, class: 'btn btn-mini btn-danger', remote: true, data: { confirm: t('.confirm'), 'for-unit': article_unit.unit, 'e2e-destroy-unit': article_unit.unit } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require_relative '../spec_helper' | ||
|
||
feature ArticleUnitsController do | ||
let(:user) { create(:user, groups: [create(:workgroup, role_article_meta: true)]) } | ||
|
||
before do | ||
login user | ||
create(:article_unit, unit: 'XPP') | ||
end | ||
|
||
describe ':index', :js do | ||
before { visit article_units_path } | ||
|
||
it 'displays units that have already been added along with their translations' do | ||
expect(page).to have_content(/piece/i) | ||
end | ||
|
||
it 'does not display units that have already been added along with their translations' do | ||
expect(page).to have_no_content(/kilogram/i) | ||
end | ||
|
||
it 'allows searching for recommended (translated) units that have not been added yet' do | ||
check 'only_recommended' | ||
fill_in 'article_unit_search', with: 'kilogram' | ||
expect(page).to have_content(/kilogram/i) | ||
end | ||
|
||
it 'does not return search results for units that have neither been added nor translated unless the "only recommended" checkbox is unchecked' do | ||
check 'only_recommended' | ||
fill_in 'article_unit_search', with: 'kiloampere' | ||
expect(page).to have_no_content(/kiloampere/i) | ||
|
||
uncheck 'only_recommended' | ||
|
||
expect(page).to have_content(/kiloampere/i) | ||
end | ||
|
||
it 'allows adding units' do | ||
fill_in 'article_unit_search', with: 'kilogram' | ||
expect(page).to have_content(/kilogram/i) | ||
|
||
find('*[data-e2e-create-unit="KGM"]').click | ||
|
||
# reset search...: | ||
fill_in 'article_unit_search', with: '' | ||
page.has_content?('piece') | ||
|
||
# ... kilogram should *still* be there if it has been added successfully: | ||
expect(page).to have_content(/kilogram/i) | ||
end | ||
|
||
it 'allows deleting units' do | ||
accept_confirm do | ||
find('*[data-e2e-destroy-unit="XPP"]').click | ||
end | ||
|
||
expect(page).to have_css('.alert-success') | ||
|
||
# the unit is still displayed (even if not in the search scope) in case the user wants to re-add it: | ||
expect(page).to have_content(/piece/i) | ||
expect(page).to have_css('a[data-e2e-create-unit="XPP"]') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters