|
44 | 44 | end |
45 | 45 |
|
46 | 46 | context 'on update' do |
47 | | - before { visit edit_path(model_name: 'player', id: player.id) } |
48 | | - |
49 | 47 | it 'changes the selected value' do |
| 48 | + visit edit_path(model_name: 'player', id: player.id) |
50 | 49 | expect(find('#player_team_id', visible: false).value).to eq teams[0].id.to_s |
51 | 50 | find('input.ra-filtering-select-input').set('Tex') |
52 | 51 | page.execute_script("$('input.ra-filtering-select-input').trigger('focus').trigger('keydown')") |
|
56 | 55 | expect(find('#player_team_id', visible: false).value).to eq teams[1].id.to_s |
57 | 56 | end |
58 | 57 |
|
59 | | - it 'clears the current selection' do |
| 58 | + it 'clears the current selection with making the search box empty' do |
| 59 | + visit edit_path(model_name: 'player', id: player.id) |
60 | 60 | find('input.ra-filtering-select-input').set('') |
61 | 61 | page.execute_script("$('input.ra-filtering-select-input').trigger('keyup')") |
62 | 62 | expect(find('#player_team_id', visible: false).value).to be_empty |
63 | 63 | end |
| 64 | + |
| 65 | + it 'clears the current selection with selecting the clear option' do |
| 66 | + visit edit_path(model_name: 'player', id: player.id) |
| 67 | + within('.filtering-select') { find('.dropdown-toggle').click } |
| 68 | + find('a.ui-menu-item-wrapper', text: /Clear/).click |
| 69 | + expect(find('#player_team_id', visible: false).value).to be_empty |
| 70 | + end |
| 71 | + |
| 72 | + context 'when the field is required' do |
| 73 | + before do |
| 74 | + RailsAdmin.config Player do |
| 75 | + field(:team) { required true } |
| 76 | + end |
| 77 | + visit edit_path(model_name: 'player', id: player.id) |
| 78 | + end |
| 79 | + |
| 80 | + it 'does not show the clear option' do |
| 81 | + within('.filtering-select') { find('.dropdown-toggle').click } |
| 82 | + is_expected.not_to have_css('a.ui-menu-item-wrapper', text: /Clear/) |
| 83 | + end |
| 84 | + end |
64 | 85 | end |
65 | 86 |
|
66 | 87 | it 'prevents duplication when using browser back and forward' do |
|
0 commit comments