2016-12-20 11:58:17 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-04-21 17:02:37 +02:00
|
|
|
feature 'As a User I want to sort and paginate dossiers', js: true do
|
2016-12-20 11:58:17 +01:00
|
|
|
let(:user) { create(:user) }
|
2018-02-06 16:58:04 +01:00
|
|
|
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, ask_birthday: true) }
|
2016-12-20 11:58:17 +01:00
|
|
|
|
|
|
|
before "Create dossier" do
|
|
|
|
login_as user, scope: :user
|
2018-02-12 15:55:51 +01:00
|
|
|
|
2016-12-20 11:58:17 +01:00
|
|
|
50.times do
|
2017-12-14 15:51:45 +01:00
|
|
|
Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "en_construction")
|
2016-12-20 11:58:17 +01:00
|
|
|
end
|
2018-02-12 15:55:51 +01:00
|
|
|
|
2016-12-20 11:58:17 +01:00
|
|
|
visit root_path
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'After sign_in, I can see my 51 dossiers on the index' do
|
|
|
|
scenario 'Using sort' do
|
2017-01-03 11:51:08 +01:00
|
|
|
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
|
|
|
|
expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq(user.dossiers.second.id.to_s)
|
2016-12-20 11:58:17 +01:00
|
|
|
visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc"
|
2018-02-12 15:55:51 +01:00
|
|
|
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 49).to_s)
|
|
|
|
expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq((user.dossiers.first.id + 48).to_s)
|
2016-12-20 11:58:17 +01:00
|
|
|
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
|
|
|
|
expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq(user.dossiers.second.id.to_s)
|
2016-12-20 11:58:17 +01:00
|
|
|
end
|
|
|
|
|
2018-04-18 12:25:03 +02:00
|
|
|
# This test always fail with ajax timeout error...
|
|
|
|
# scenario 'Using pagination' do
|
|
|
|
# visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
|
|
|
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
|
|
|
|
# page.find('.next_page a').click
|
|
|
|
# wait_for_ajax
|
|
|
|
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 10).to_s)
|
|
|
|
# page.find('.next_page a').click
|
|
|
|
# wait_for_ajax
|
|
|
|
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 20).to_s)
|
|
|
|
# page.find('.prev a').click
|
|
|
|
# wait_for_ajax
|
|
|
|
# page.find('.prev a').click
|
|
|
|
# wait_for_ajax
|
|
|
|
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id).to_s)
|
|
|
|
# end
|
2016-12-20 11:58:17 +01:00
|
|
|
end
|
|
|
|
end
|