Skip to content

Commit 5d81338

Browse files
committed
replaced the private Stimulus call + polling with the same public UI interaction pattern used in file_tree_spec.rb
1 parent 4be48dd commit 5d81338

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

spec/system/file_tree_duplicate_column_spec.rb

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,16 @@
2020
end
2121

2222
it "shows a duplicate tag for assets with duplicates" do
23-
page.execute_script(<<~JS)
24-
(() => {
25-
const start = Date.now();
26-
const tryExpand = () => {
27-
const el = document.querySelector("[data-controller~='wunderbaum']");
28-
const controller = window.Stimulus?.getControllerForElementAndIdentifier(el, "wunderbaum");
29-
const node = controller?._findNodeByKey?.("#{root_folder.id}");
30-
if (node && !node.expanded) {
31-
node.setExpanded(true);
32-
return;
33-
}
34-
if (Date.now() - start < 2000) setTimeout(tryExpand, 50);
35-
};
36-
tryExpand();
37-
})();
38-
JS
23+
within "#tree" do
24+
find("i.wb-expander", match: :first).click
3925

40-
expect(page).to have_selector(".wb-row .wb-title", text: duplicate_asset.isilon_name, wait: 10)
41-
42-
title = find(".wb-row .wb-title", text: duplicate_asset.isilon_name, wait: 10)
43-
row = title.find(:xpath, "./ancestor::div[contains(@class,'wb-row')]")
44-
45-
within(row) do
46-
expect(page).to have_selector(".duplicate-tag", text: "Duplicate", wait: 10, visible: :all)
26+
expect(page).to have_selector(".wb-row .wb-title", text: duplicate_asset.isilon_name, wait: 10)
27+
expect(page).to have_xpath(
28+
"//div[contains(@class,'wb-row')]" \
29+
"[.//span[contains(@class,'wb-title')][normalize-space()='#{duplicate_asset.isilon_name}']]" \
30+
"//span[contains(@class,'duplicate-tag')][normalize-space()='Duplicate']",
31+
wait: 10
32+
)
4733
end
4834
end
4935
end

0 commit comments

Comments
 (0)