|
38 | 38 |
|
39 | 39 | before do
|
40 | 40 | allow(EnterpriseToken).to receive(:allows_to?).and_return(true)
|
| 41 | + login_as admin |
41 | 42 | end
|
42 | 43 |
|
43 | 44 | it "lets you create, update and delete a custom field of type hierarchy" do
|
44 |
| - login_as admin |
45 |
| - |
46 | 45 | # region CustomField creation
|
47 | 46 |
|
48 | 47 | custom_field_index_page.visit!
|
|
77 | 76 | fill_in "Name", with: "", fill_options: { clear: :backspace }
|
78 | 77 | fill_in "Name", with: hierarchy_name
|
79 | 78 | click_on "Save"
|
80 |
| - expect(page).to have_css(".PageHeader-title", text: hierarchy_name) |
| 79 | + expect(page).to have_heading(hierarchy_name) |
81 | 80 |
|
82 | 81 | # endregion
|
83 | 82 |
|
|
158 | 157 |
|
159 | 158 | # endregion
|
160 | 159 | end
|
| 160 | + |
| 161 | + context "when navigating the hierarchy" do |
| 162 | + let(:service) { CustomFields::Hierarchy::HierarchicalItemService.new } |
| 163 | + let(:custom_field) { create(:wp_custom_field, field_format: "hierarchy", hierarchy_root: nil) } |
| 164 | + let!(:root) { service.generate_root(custom_field).value! } |
| 165 | + let!(:luke) { service.insert_item(parent: root, label: "Luke", short: "LS").value! } |
| 166 | + let!(:r2d2) { service.insert_item(parent: luke, label: "R2-D2", short: "R2").value! } |
| 167 | + let!(:mouse) { service.insert_item(parent: r2d2, label: "Mouse Droid", short: "MD").value! } |
| 168 | + let!(:c3po) { service.insert_item(parent: luke, label: "C-3PO", short: "3PO").value! } |
| 169 | + let!(:mara) { service.insert_item(parent: root, label: "Mara", short: "MJ").value! } |
| 170 | + |
| 171 | + before do |
| 172 | + custom_field.reload |
| 173 | + hierarchy_page.add_custom_field_state(custom_field) |
| 174 | + |
| 175 | + visit custom_field_item_path(root.custom_field_id, luke) |
| 176 | + end |
| 177 | + |
| 178 | + it "can navigate and keep the tab selection (regression #63921)" do |
| 179 | + # Expect items to be loaded and the tab nav to be selected correctly |
| 180 | + expect(page).to have_test_selector("op-custom-fields--hierarchy-item", count: 2) |
| 181 | + hierarchy_page.expect_tab "Items" |
| 182 | + |
| 183 | + # Navigating to an item will keep the tab nav selection |
| 184 | + page.find_test_selector("op-custom-fields--hierarchy-item", text: "C-3PO").click |
| 185 | + hierarchy_page.expect_tab "Items" |
| 186 | + end |
| 187 | + end |
161 | 188 | end
|
0 commit comments