|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +Given 'a Digital Object with two Digital Object Components has been created' do |
| 4 | + visit "#{STAFF_URL}/digital_objects/new" |
| 5 | + |
| 6 | + fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}" |
| 7 | + fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}" |
| 8 | + |
| 9 | + click_on 'Add Date' |
| 10 | + select 'Single', from: 'digital_object_dates__0__date_type_' |
| 11 | + fill_in 'digital_object_dates__0__begin_', with: '2000-01-01' |
| 12 | + |
| 13 | + click_on 'Save' |
| 14 | + |
| 15 | + wait_for_ajax |
| 16 | + expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created" |
| 17 | + @digital_object_id = current_url.split('::digital_object_').pop |
| 18 | + |
| 19 | + click_on 'Add Child' |
| 20 | + wait_for_ajax |
| 21 | + fill_in 'Label', with: "Digital Object Component A Label #{@uuid}" |
| 22 | + click_on 'Save' |
| 23 | + wait_for_ajax |
| 24 | + expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" |
| 25 | + @digital_object_component_first_id = current_url.split('::digital_object_component_').pop |
| 26 | + |
| 27 | + within '#tree-container' do |
| 28 | + click_on "Digital Object Title #{@uuid}" |
| 29 | + end |
| 30 | + |
| 31 | + click_on 'Add Child' |
| 32 | + wait_for_ajax |
| 33 | + fill_in 'Label', with: "Digital Object Component B Label #{@uuid}" |
| 34 | + click_on 'Save' |
| 35 | + wait_for_ajax |
| 36 | + expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" |
| 37 | + @digital_object_component_second_id = current_url.split('::digital_object_component_').pop |
| 38 | +end |
| 39 | + |
| 40 | +Given 'a Digital Object with two nested Digital Object Components has been created' do |
| 41 | + visit "#{STAFF_URL}/digital_objects/new" |
| 42 | + |
| 43 | + fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}" |
| 44 | + fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}" |
| 45 | + |
| 46 | + click_on 'Add Date' |
| 47 | + select 'Single', from: 'digital_object_dates__0__date_type_' |
| 48 | + fill_in 'digital_object_dates__0__begin_', with: '2000-01-01' |
| 49 | + |
| 50 | + click_on 'Save' |
| 51 | + |
| 52 | + wait_for_ajax |
| 53 | + expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created" |
| 54 | + @digital_object_id = current_url.split('::digital_object_').pop |
| 55 | + |
| 56 | + click_on 'Add Child' |
| 57 | + wait_for_ajax |
| 58 | + fill_in 'Label', with: "Digital Object Component A Label #{@uuid}" |
| 59 | + click_on 'Save' |
| 60 | + wait_for_ajax |
| 61 | + expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" |
| 62 | + @digital_object_component_first_id = current_url.split('::digital_object_component_').pop |
| 63 | + |
| 64 | + click_on 'Add Child' |
| 65 | + wait_for_ajax |
| 66 | + fill_in 'Label', with: "Digital Object Component B Label #{@uuid}" |
| 67 | + click_on 'Save' |
| 68 | + wait_for_ajax |
| 69 | + expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created as child of on Digital Object Digital Object Title #{@uuid}" |
| 70 | + @digital_object_component_second_id = current_url.split('::digital_object_component_').pop |
| 71 | +end |
| 72 | + |
| 73 | +When 'the user selects the second Digital Object Component' do |
| 74 | + click_on "Digital Object Component B Label #{@uuid}" |
| 75 | + |
| 76 | + wait_for_ajax |
| 77 | +end |
| 78 | + |
| 79 | +When 'the user selects the first Digital Object Component' do |
| 80 | + click_on "Digital Object Component A Label #{@uuid}" |
| 81 | + |
| 82 | + wait_for_ajax |
| 83 | +end |
| 84 | + |
| 85 | +Then 'the button has text {string}' do |text| |
| 86 | + expect(page).to have_text text |
| 87 | +end |
| 88 | + |
| 89 | +Then 'the second Digital Object Component is pasted as a child of the Digital Object Component' do |
| 90 | + expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1" |
| 91 | + expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-2" |
| 92 | +end |
| 93 | + |
| 94 | +Then 'the second Digital Object Component moves a level up' do |
| 95 | + expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1" |
| 96 | + expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-1" |
| 97 | +end |
| 98 | + |
| 99 | +Then 'the second Digital Object Component moves one position up' do |
| 100 | + wait_for_ajax |
| 101 | + |
| 102 | + elements = all('.table-row.largetree-node.indent-level-1') |
| 103 | + |
| 104 | + tries = 0 |
| 105 | + while elements[0][:id] == '' |
| 106 | + break if tries == 3 |
| 107 | + |
| 108 | + sleep 3 |
| 109 | + tries += 1 |
| 110 | + elements = all('.table-row.largetree-node.indent-level-1') |
| 111 | + end |
| 112 | + |
| 113 | + puts "\n\n\n\nelements[0][:id].inspect" |
| 114 | + puts elements[0][:id].inspect |
| 115 | + puts elements[1][:id].inspect |
| 116 | + |
| 117 | + expect(elements[0][:id]).to eq "digital_object_component_#{@digital_object_component_second_id}" |
| 118 | + expect(elements[1][:id]).to eq "digital_object_component_#{@digital_object_component_first_id}" |
| 119 | +end |
| 120 | + |
| 121 | +When 'the user selects the first Digital Object Component from the dropdown menu' do |
| 122 | + within '.dropdown-menu' do |
| 123 | + find('.rounded-0.dropdown-item.cursor-default.move-node.move-node-down-into', match: :first).hover |
| 124 | + end |
| 125 | + |
| 126 | + element = find("[data-tree_id=\"digital_object_component_#{@digital_object_component_first_id}\"]") |
| 127 | + element.click |
| 128 | +end |
| 129 | + |
| 130 | +Then 'the second Digital Object Component moves as a child into the first Digital Object Component' do |
| 131 | + expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1" |
| 132 | + expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-2" |
| 133 | +end |
0 commit comments