|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
| 3 | +def pick_date(input_selector, date_num) |
| 4 | + page.find(input_selector).click |
| 5 | + sleep 0.3 |
| 6 | + picker = page.find('.xdsoft_datetimepicker', visible: true) |
| 7 | + picker.find(".xdsoft_calendar td.xdsoft_date[data-date=\"#{date_num}\"]", match: :first).click |
| 8 | + sleep 0.2 |
| 9 | + picker.find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
| 10 | + sleep 0.2 |
| 11 | +end |
| 12 | + |
3 | 13 | describe 'authors index', type: :feature, js: true do |
4 | 14 | before do |
5 | 15 | add_author_resource |
|
12 | 22 |
|
13 | 23 | context 'filter by Date column' do |
14 | 24 | before do |
15 | | - page.find('input#q_birthday_gteq').click |
16 | | - |
17 | | - page.find('.xdsoft_datetimepicker', visible: true) |
18 | | - .find('.xdsoft_calendar td.xdsoft_date[data-date="1"]').click |
19 | | - page.find('.xdsoft_datetimepicker', visible: true) |
20 | | - .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
21 | | - |
22 | | - page.find('input#q_birthday_lteq').click |
23 | | - |
24 | | - page.find('.xdsoft_datetimepicker', visible: true) |
25 | | - .find('.xdsoft_calendar td.xdsoft_date[data-date="20"]').click |
26 | | - page.find('.xdsoft_datetimepicker', visible: true) |
27 | | - .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
| 25 | + pick_date('input#q_birthday_gteq', 1) |
| 26 | + pick_date('input#q_birthday_lteq', 20) |
28 | 27 | end |
29 | 28 |
|
30 | 29 | it 'can set date from/to' do |
|
55 | 54 | last_name: "from-the-future", |
56 | 55 | created_at: (Time.now.change(day: 20) + 2.hours).to_formatted_s(:db)) |
57 | 56 |
|
58 | | - # chose 01 and 20 day of the current month |
59 | | - |
60 | | - page.find('input#q_created_at_gteq_datetime_picker').click |
61 | | - |
62 | | - page.find('.xdsoft_datetimepicker', visible: true) |
63 | | - .find('.xdsoft_calendar td.xdsoft_date[data-date="1"]').click |
64 | | - page.find('.xdsoft_datetimepicker', visible: true) |
65 | | - .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
66 | | - |
67 | | - page.find('input#q_created_at_lteq_datetime_picker').click |
68 | | - |
69 | | - page.find('.xdsoft_datetimepicker', visible: true) |
70 | | - .find('.xdsoft_calendar td.xdsoft_date[data-date="20"]').click |
71 | | - page.find('.xdsoft_datetimepicker', visible: true) |
72 | | - .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
| 57 | + pick_date('input#q_created_at_gteq_datetime_picker', 1) |
| 58 | + pick_date('input#q_created_at_lteq_datetime_picker', 20) |
73 | 59 |
|
74 | 60 | @value_from = page.find('#q_created_at_gteq_datetime_picker').value |
75 | 61 | @value_to = page.find('#q_created_at_lteq_datetime_picker').value |
|
99 | 85 | Author.create!(name: 'Ron', last_name: 'Two', updated_at: (Time.now.change(day: 20) - 1.hour).to_formatted_s(:db)) |
100 | 86 | Author.create!(name: 'Rey', last_name: 'future', updated_at: Time.now.change(day: 21).to_formatted_s(:db)) |
101 | 87 |
|
102 | | - # chose 01 and 20 day of the current month |
103 | | - page.find('input#q_last_seen_at_gteq_datetime_picker').click |
104 | | - page.find('.xdsoft_datetimepicker', visible: true) |
105 | | - .find('.xdsoft_calendar td.xdsoft_date[data-date="1"]').click |
106 | | - page.find('.xdsoft_datetimepicker', visible: true) |
107 | | - .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
108 | | - |
109 | | - page.find('input#q_last_seen_at_lteq_datetime_picker').click |
110 | | - page.find('.xdsoft_datetimepicker', visible: true) |
111 | | - .find('.xdsoft_calendar td.xdsoft_date[data-date="20"]').click |
112 | | - page.find('.xdsoft_datetimepicker', visible: true) |
113 | | - .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
| 88 | + pick_date('input#q_last_seen_at_gteq_datetime_picker', 1) |
| 89 | + pick_date('input#q_last_seen_at_lteq_datetime_picker', 20) |
114 | 90 |
|
115 | 91 | @value_from = page.find('#q_last_seen_at_gteq_datetime_picker').value |
116 | 92 | @value_to = page.find('#q_last_seen_at_lteq_datetime_picker').value |
|
0 commit comments