|
@@ -7,7 +7,7 @@ RSpec.describe 'Mobile > Tickets', app: :mobile, authenticated_as: :agent, type:
|
|
|
let(:user) { create(:user, organization: organization) }
|
|
|
let(:group) { create(:group) }
|
|
|
let(:agent) { create(:agent) }
|
|
|
- let(:open_tickets) { create_list(:ticket, 20, customer: user, organization: organization, group: group, created_by_id: user.id, state: Ticket::State.lookup(name: 'open')) }
|
|
|
+ let(:open_tickets) { create_list(:ticket, 20, title: 'Test Ticket', customer: user, organization: organization, group: group, created_by_id: user.id, state: Ticket::State.lookup(name: 'open')) }
|
|
|
let(:overview_tickets) { Ticket::Overviews.tickets_for_overview(Overview.find_by(link: 'all_open'), agent).limit(nil) }
|
|
|
|
|
|
before do
|
|
@@ -24,26 +24,36 @@ RSpec.describe 'Mobile > Tickets', app: :mobile, authenticated_as: :agent, type:
|
|
|
agent.group_names_access_map = Group.all.to_h { |g| [g.name, ['full']] }
|
|
|
end
|
|
|
|
|
|
+ def wait_for_tickets(count:)
|
|
|
+ wait.until do
|
|
|
+ expect(page).to have_css('a[href^="/mobile/tickets/"]:not([href$="/create"])', count: count)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
context 'when on "Open Tickets" view' do
|
|
|
before do
|
|
|
visit '/tickets/view/all_open'
|
|
|
end
|
|
|
|
|
|
- context 'when checking displayed tickets' do
|
|
|
- it 'displays 10 tickets by default' do
|
|
|
- expect(page).to have_link(href: %r{/mobile/tickets/\d+}, count: 10)
|
|
|
- end
|
|
|
-
|
|
|
- it 'loads more tickets when scrolling down' do
|
|
|
- wait.until do
|
|
|
- expect(page).to have_link(href: %r{/mobile/tickets/\d+}, count: 10)
|
|
|
- end
|
|
|
+ context 'when going between list and ticket' do
|
|
|
+ it 'going back keeps the scroll position' do
|
|
|
+ wait_for_tickets(count: 10)
|
|
|
|
|
|
page.scroll_to :bottom
|
|
|
|
|
|
- wait.until do
|
|
|
- expect(page).to have_link(href: %r{/mobile/tickets/\d+}, count: 20)
|
|
|
- end
|
|
|
+ wait_for_tickets(count: 20)
|
|
|
+
|
|
|
+ link = find_link(href: "/mobile/tickets/#{open_tickets[6].id}")
|
|
|
+ position_old = link.evaluate_script('this.getBoundingClientRect().top')
|
|
|
+
|
|
|
+ link.find('span', text: 'Test Ticket').click
|
|
|
+
|
|
|
+ find_button('Go back').click
|
|
|
+
|
|
|
+ expect_current_route '/tickets/view/all_open'
|
|
|
+
|
|
|
+ position_new = find_link(href: "/mobile/tickets/#{open_tickets[6].id}").evaluate_script('this.getBoundingClientRect().top')
|
|
|
+ expect(position_old).to eq(position_new)
|
|
|
end
|
|
|
end
|
|
|
|