|
| 1 | +# frozen_string_literal: true |
| 2 | + |
1 | 3 | require 'spec_helper'
|
2 | 4 |
|
3 | 5 | RSpec.feature 'Combine custom filtering' do
|
|
6 | 8 | scenario 'The user search user, change pagination and change page', js: true do
|
7 | 9 | visit admin_users_path
|
8 | 10 |
|
9 |
| - #page_sizes => [3, 10] |
10 |
| - within(".pagination-per-page") { click_on "10" } |
11 |
| - expect(page).to have_selector('tr.editable', count: 8) |
| 11 | + # page_sizes => [3, 10] |
| 12 | + within('.pagination-per-page') { click_link '10' } |
| 13 | + expect(page).to have_css('tr.editable', count: 8) |
12 | 14 |
|
13 |
| - fill_in "filter", with: "test" |
| 15 | + fill_in 'filter', with: 'test' |
14 | 16 | sleep 1
|
15 |
| - expect(page).to have_selector('tr.editable', count: 4) |
| 17 | + expect(page).to have_css('tr.editable', count: 4) |
16 | 18 |
|
17 |
| - within(".pagination-per-page") { click_on "3" } |
18 |
| - within(".pagination") { click_on "2" } |
19 |
| - expect(page).to have_selector('tr.editable', count: 1) |
| 19 | + within('.pagination-per-page') { click_link '3' } |
| 20 | + within('.pagination') { click_link '2' } |
| 21 | + expect(page).to have_css('tr.editable', count: 1) |
20 | 22 | end
|
21 | 23 |
|
22 | 24 | scenario 'The user sort users and change page', js: true do
|
23 | 25 | visit admin_users_path
|
24 | 26 |
|
25 | 27 | find('.name a.sortable').click
|
26 |
| - expect(page).to have_content("Aaron") |
27 |
| - expect(page).to_not have_content("Jane") |
| 28 | + expect(page).to have_content('Aaron') |
| 29 | + expect(page).to_not have_content('Jane') |
28 | 30 |
|
29 |
| - within(".pagination") { click_on "2" } |
30 |
| - expect(page).to have_content("Jane") |
31 |
| - expect(page).to_not have_content("Aaron") |
| 31 | + within('.pagination') { click_link '2' } |
| 32 | + expect(page).to have_content('Jane') |
| 33 | + expect(page).to_not have_content('Aaron') |
32 | 34 | end
|
33 | 35 |
|
34 | 36 | scenario 'The user combine filters', js: true do
|
35 | 37 | visit admin_users_path
|
36 | 38 |
|
37 |
| - fill_in "filter", with: "email" |
| 39 | + fill_in 'filter', with: 'email' |
38 | 40 | find('input#boolean').click
|
39 |
| - expect(page).to have_selector('tr.editable', count: 2) |
| 41 | + expect(page).to have_css('tr.editable', count: 2) |
40 | 42 | end
|
41 | 43 |
|
42 | 44 | scenario 'The user combine filters and sort users', js: true do
|
43 | 45 | visit admin_users_path
|
44 | 46 |
|
45 |
| - fill_in "filter", with: "test" |
| 47 | + fill_in 'filter', with: 'test' |
46 | 48 | find('input#boolean').click
|
47 | 49 | wait_for_ajax
|
48 |
| - expect(page).to have_selector('tr.editable', count: 2) |
| 50 | + expect(page).to have_css('tr.editable', count: 2) |
49 | 51 |
|
50 | 52 | click_link 'Name'
|
51 |
| - expect(page).to have_selector('tr.editable', count: 2) |
52 |
| - expect(page.find(:css, "tbody > tr:nth-child(1)")).to have_content("Edward") |
53 |
| - expect(page.find(:css, "tbody > tr:nth-child(2)")).to have_content("Robin") |
| 53 | + expect(page).to have_css('tr.editable', count: 2) |
| 54 | + expect(page.find(:css, 'tbody > tr:nth-child(1)')).to have_content('Edward') |
| 55 | + expect(page.find(:css, 'tbody > tr:nth-child(2)')).to have_content('Robin') |
54 | 56 | end
|
55 | 57 |
|
56 | 58 | scenario 'The user combine filters, sort and change page', js: true do
|
57 | 59 | visit admin_users_path
|
58 | 60 |
|
59 | 61 | check 'boolean'
|
60 | 62 | wait_for_ajax
|
61 |
| - expect(find(:css, '.email a.sortable')[:href]).to include("boolean") |
| 63 | + expect(find(:css, '.email a.sortable')[:href]).to include('boolean') |
62 | 64 |
|
63 | 65 | click_link 'Email'
|
64 |
| - expect(page.find(:css, "tbody > tr:nth-child(2)")).to have_content("Lisa") |
| 66 | + expect(page.find(:css, 'tbody > tr:nth-child(2)')).to have_content('Lisa') |
65 | 67 |
|
66 |
| - within(".pagination") { click_on "2" } |
67 |
| - expect(page.find(:css, "tbody > tr:nth-child(1)")).to have_content("Robin") |
68 |
| - expect(page.find(:css, '.count')).to have_content("4") |
| 68 | + within('.pagination') { click_link '2' } |
| 69 | + expect(page.find(:css, 'tbody > tr:nth-child(1)')).to have_content('Robin') |
| 70 | + expect(page.find(:css, '.count')).to have_content('4') |
69 | 71 | end
|
70 | 72 | end
|
0 commit comments