|
56 | 56 |
|
57 | 57 | # handles opening + closing of the modal, as well as the actions performed within the modal |
58 | 58 | def perform_modal_actions |
59 | | - # Open the modal |
60 | | - click_button 'Add a repository' |
61 | | - expect(page).to have_text('Repository search') |
| 59 | + open_modal |
62 | 60 |
|
63 | 61 | within('#modal-search-repositories') do |
64 | | - # Search for the Repository |
65 | | - fill_in 'research_output_search_term', with: @model.name |
66 | | - click_button 'Apply filter(s)' |
67 | | - expect(page).to have_text(@model.description) |
68 | | - # Select the repository and make sure it no longer appears in the search results |
69 | | - click_link 'Select' |
70 | | - expect(page).not_to have_text(@model.description) |
71 | | - |
72 | | - # Using JS to click on button, as click_button '.modal-header button.btn-close' did not work. |
73 | | - modal_close_button = find('.modal-header button.btn-close') |
74 | | - # Close the modal |
75 | | - execute_script('arguments[0].click();', modal_close_button) |
| 62 | + search_and_select_repository_within_modal |
| 63 | + close_modal |
76 | 64 | end |
77 | 65 | # Verify that the selection was added to the main page's dom |
78 | 66 | expect(page).not_to have_text('Repository search') |
79 | 67 | expect(page).to have_text(@model.description) |
80 | 68 | end |
| 69 | + |
| 70 | + def open_modal |
| 71 | + # Open the modal |
| 72 | + click_button 'Add a repository' |
| 73 | + expect(page).to have_text('Repository search') |
| 74 | + end |
| 75 | + |
| 76 | + def search_and_select_repository_within_modal |
| 77 | + # Search for the Repository |
| 78 | + fill_in 'research_output_search_term', with: @model.name |
| 79 | + click_button 'Apply filter(s)' |
| 80 | + expect(page).to have_text(@model.description) |
| 81 | + # Select the repository and make sure it no longer appears in the search results |
| 82 | + click_link 'Select' |
| 83 | + expect(page).not_to have_text(@model.description) |
| 84 | + end |
| 85 | + |
| 86 | + def close_modal |
| 87 | + # Using JS to click on button, as click_button '.modal-header button.btn-close' did not work. |
| 88 | + modal_close_button = find('.modal-header button.btn-close') |
| 89 | + # Close the modal |
| 90 | + execute_script('arguments[0].click();', modal_close_button) |
| 91 | + end |
81 | 92 | end |
0 commit comments