Skip to content

Commit 8cac676

Browse files
committed
Optimize folder_asset_rendering_spec by moving heavy assertions out of system spec
- Keep spec/system/folder_asset_rendering_spec.rb focused on browser-level Wunderbaum behavior: folder rows render folder affordances, expanding a folder reveals asset rows, and asset rows render asset-specific controls. - Move payload-shape assertions into spec/requests/volumes/file_tree_spec.rb, where they run faster and more directly verify the JSON contract. The request coverage now checks that folder nodes omit asset-only fields, while asset nodes include the fields needed to render asset-only columns. - Test-only change. No production behavior changed. Assertions were added to the existing request spec instead of a new spec file to keep the diff minimal.
1 parent 16c5f33 commit 8cac676

2 files changed

Lines changed: 56 additions & 37 deletions

File tree

spec/requests/volumes/file_tree_spec.rb

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
RSpec.describe "Volumes file tree endpoints", type: :request do
66
let!(:volume) { create(:volume) }
77
let!(:user) { create(:user, email: "tester@temple.edu") }
8+
let!(:assignee) { create(:user, name: "Assigned User", email: "assigned@example.com") }
9+
let!(:migration_status) { create(:migration_status, :default) }
810

911
before { sign_in user }
1012

@@ -34,8 +36,13 @@
3436
create(:isilon_asset, parent_folder: folder_c,
3537
isilon_name: "scan_beta_001.tif",
3638
isilon_path: "#{folder_c.full_path}/scan_beta_001.tif",
39+
migration_status: migration_status,
40+
assigned_to: assignee,
41+
notes: "asset notes",
3742
aspace_collection: aspace_collection,
38-
contentdm_collection: contentdm_collection)
43+
contentdm_collection: contentdm_collection,
44+
preservica_reference_id: "pres-123",
45+
aspace_linking_status: true)
3946
end
4047

4148
def parsed
@@ -77,6 +84,29 @@ def parsed
7784
match = json.find { |h| h["id"] == folder.id }
7885
expect(match["descendant_assets_count"]).to eq(3)
7986
end
87+
88+
it "omits asset-only rendering fields from folder payloads" do
89+
get file_tree_volume_path(volume, format: :json)
90+
91+
expect(response).to have_http_status(:ok)
92+
93+
match = parsed.find { |h| h["id"] == root.id }
94+
expect(match).to include(
95+
"folder" => true,
96+
"assigned_to" => "Unassigned",
97+
"key" => root.id.to_s,
98+
"notes" => nil
99+
)
100+
expect(match.keys).not_to include(
101+
"migration_status",
102+
"migration_status_id",
103+
"contentdm_collection_id",
104+
"aspace_collection_id",
105+
"preservica_reference_id",
106+
"aspace_linking_status",
107+
"url"
108+
)
109+
end
80110
end
81111

82112
describe "GET /volumes/:id/file_tree_assets" do
@@ -95,8 +125,16 @@ def parsed
95125
expect(keys).to include("a-#{asset.id}")
96126
match = body.find { |h| h["key"] == "a-#{asset.id}" }
97127
expect(match["path"]).to eq([ root.id, folder_a.id, folder_b.id, folder_c.id ])
128+
expect(match["assigned_to"]).to eq(assignee.name)
129+
expect(match["assigned_to_id"]).to eq(assignee.id)
130+
expect(match["migration_status"]).to eq(migration_status.name)
131+
expect(match["migration_status_id"]).to eq(migration_status.id)
132+
expect(match["notes"]).to eq("asset notes")
98133
expect(match["aspace_collection_id"]).to eq(aspace_collection.id)
99134
expect(match["contentdm_collection_id"]).to eq(contentdm_collection.id)
135+
expect(match["preservica_reference_id"]).to eq("pres-123")
136+
expect(match["aspace_linking_status"]).to eq("t")
137+
expect(match["url"]).to end_with("/admin/isilon_assets/#{asset.id}")
100138
end
101139
end
102140

spec/system/folder_asset_rendering_spec.rb

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,51 @@
22

33
RSpec.describe "Wunderbaum folder vs asset rendering", type: :system do
44
let!(:volume) { create(:volume, name: "TestVol") }
5-
65
let!(:root_folder) do
76
create(
87
:isilon_folder,
98
volume: volume,
109
parent_folder: nil,
11-
full_path: "RootFolder"
10+
full_path: "/TestVol/RootFolder"
1211
)
1312
end
14-
1513
let!(:asset) do
1614
create(
1715
:isilon_asset,
1816
parent_folder: root_folder,
1917
isilon_name: "my_asset.txt"
2018
)
2119
end
22-
2320
let!(:user) { create(:user, email: "tester@temple.edu") }
2421

2522
before do
2623
driven_by :cuprite
2724
sign_in user
28-
visit volume_path(volume)
2925
end
3026

31-
it "renders only allowed interactions for folders" do
32-
folder_row = page
33-
.all(".wb-row", visible: true)
34-
.find { |row| row.has_css?(".wb-expander") }
35-
36-
expect(folder_row).to be_present
37-
38-
expect(folder_row).to have_css("[data-colid='assigned_to']")
39-
expect(folder_row).to have_css("[data-colid='notes']")
40-
expect(folder_row).to have_css(".wb-select-like[data-colid='assigned_to']")
27+
it "renders folder and asset-specific affordances in Wunderbaum" do
28+
visit volume_path(volume)
4129

42-
expect(folder_row).not_to have_css("[data-colid='migration_status']")
43-
expect(folder_row).not_to have_css("[data-colid='contentdm_collection_id']")
44-
expect(folder_row).not_to have_css("[data-colid='aspace_collection_id']")
45-
expect(folder_row).not_to have_css("[data-colid='aspace_linking_status']")
46-
end
30+
folder_row = find(
31+
:xpath,
32+
"//div[contains(@class,'wb-row')][.//span[contains(@class,'wb-title')][normalize-space(text())='RootFolder']]",
33+
wait: 10
34+
)
4735

48-
it "renders all applicable columns for assets" do
49-
folder_row = page
50-
.all(".wb-row", visible: true)
51-
.find { |row| row.has_css?(".wb-expander") }
36+
expect(folder_row).to have_css("[data-colid='assigned_to'].wb-select-like", text: "Unassigned")
37+
expect(folder_row).not_to have_css("a.asset-link")
38+
expect(folder_row).not_to have_css("input[type='checkbox']")
5239

5340
folder_row.find(".wb-expander").click
5441

55-
expect(page).to have_css(".wb-row", text: "my_asset.txt")
56-
57-
asset_row = page
58-
.all(".wb-row", visible: true)
59-
.find { |row| row.has_css?("a.asset-link") }
60-
61-
expect(asset_row).to be_present
42+
asset_row = find(
43+
:xpath,
44+
"//div[contains(@class,'wb-row')][.//a[contains(@class,'asset-link')][normalize-space(text())='my_asset.txt']]",
45+
wait: 10
46+
)
6247

48+
expect(asset_row).to have_css("a.asset-link", text: "my_asset.txt")
6349
expect(asset_row).to have_css("input[name='notes']")
64-
expect(asset_row).to have_css("[data-colid='assigned_to']")
65-
expect(asset_row).to have_css("[data-colid='migration_status']")
66-
expect(asset_row).to have_css("[data-colid='contentdm_collection_id']")
67-
expect(asset_row).to have_css("[data-colid='aspace_collection_id']")
68-
expect(asset_row).to have_css("[data-colid='preservica_reference_id']")
6950
expect(asset_row).to have_css("input[type='checkbox']")
7051
end
7152
end

0 commit comments

Comments
 (0)