diff --git a/app/assets/stylesheets/components/show.scss b/app/assets/stylesheets/components/show.scss index 913efdc6..8eb1cc96 100644 --- a/app/assets/stylesheets/components/show.scss +++ b/app/assets/stylesheets/components/show.scss @@ -57,3 +57,7 @@ } } } + +#document-file-type-list-extra { + margin-top: -25px; +} diff --git a/app/views/catalog/_show_sidebar.html.erb b/app/views/catalog/_show_sidebar.html.erb index c679751a..154c0c52 100644 --- a/app/views/catalog/_show_sidebar.html.erb +++ b/app/views/catalog/_show_sidebar.html.erb @@ -8,11 +8,48 @@ + + + + + diff --git a/spec/fixtures/files/pdc_describe_data/89.json b/spec/fixtures/files/pdc_describe_data/89.json index 899a92f8..ea3dd5cb 100644 --- a/spec/fixtures/files/pdc_describe_data/89.json +++ b/spec/fixtures/files/pdc_describe_data/89.json @@ -232,61 +232,61 @@ "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig16a.hdf" }, { - "filename": "10.34770/bm4s-t361/89/Fig16b.hdf", + "filename": "10.34770/bm4s-t361/89/Fig16b.ccc", "size": 17264, "display_size": "16.9 KB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig16b.hdf" }, { - "filename": "10.34770/bm4s-t361/89/Fig1a.png", + "filename": "10.34770/bm4s-t361/89/Fig1a.bbb", "size": 72628, "display_size": "70.9 KB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig1a.png" }, { - "filename": "10.34770/bm4s-t361/89/Fig1b.png", + "filename": "10.34770/bm4s-t361/89/Fig1b.aaa", "size": 301258, "display_size": "294 KB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig1b.png" }, { - "filename": "10.34770/bm4s-t361/89/Fig2.png", + "filename": "10.34770/bm4s-t361/89/Fig2.pdf", "size": 225329, "display_size": "220 KB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig2.png" }, { - "filename": "10.34770/bm4s-t361/89/Fig3a.png", + "filename": "10.34770/bm4s-t361/89/Fig3a.py", "size": 669489, "display_size": "654 KB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig3a.png" }, { - "filename": "10.34770/bm4s-t361/89/Fig3b.png", + "filename": "10.34770/bm4s-t361/89/Fig3b.rb", "size": 1524537, "display_size": "1.45 MB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig3b.png" }, { - "filename": "10.34770/bm4s-t361/89/Fig4.hdf", + "filename": "10.34770/bm4s-t361/89/Fig4.xls", "size": 11307376, "display_size": "10.8 MB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig4.hdf" }, { - "filename": "10.34770/bm4s-t361/89/Fig5_7_8a.hdf", + "filename": "10.34770/bm4s-t361/89/Fig5_7_8a.doc", "size": 40511960, "display_size": "38.6 MB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig5_7_8a.hdf" }, { - "filename": "10.34770/bm4s-t361/89/Fig6.hdf", + "filename": "10.34770/bm4s-t361/89/Fig6.tiff", "size": 151856, "display_size": "148 KB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig6.hdf" }, { - "filename": "10.34770/bm4s-t361/89/Fig8b.hdf", + "filename": "10.34770/bm4s-t361/89/Fig8b.jpg", "size": 32944056, "display_size": "31.4 MB", "url": "https://g-ef94ef.f0ad1.36fe.data.globus.org/10.34770/bm4s-t361/89/Fig8b.hdf" @@ -320,4 +320,4 @@ "embargo_date": null, "created_at": "2023-08-18T13:47:14Z", "updated_at": "2024-02-23T11:05:11Z" -} \ No newline at end of file +} diff --git a/spec/system/show_pdc_describe_record_spec.rb b/spec/system/show_pdc_describe_record_spec.rb index 64fa83b7..066037c8 100644 --- a/spec/system/show_pdc_describe_record_spec.rb +++ b/spec/system/show_pdc_describe_record_spec.rb @@ -51,6 +51,29 @@ third_filename_spot = find(:xpath, "//table[@id='files-table']/tbody/tr[3]/td[1]").text expect(third_filename_spot).to eq("Fig10a.hdf") end + + it 'shows file types when there is more than 10 in sidebar' do + visit '/catalog/doi-10-34770-bm4s-t361' + # initially only first ten file types are shown + expect(page).to have_content("Show More") + expect(page).to have_selector('#document-file-type-list-toggle', visible: true) + inital_file_types = find(:xpath, "//*[@id='document-file-type-list']/div/span[2]").text + expect(inital_file_types).to eq("hdf(12), ccc(1), bbb(1), aaa(1), pdf(1), py(1), rb(1), xls(1), doc(1), tiff(1)") + expect(page).to have_selector('#document-file-type-list-extra', visible: false) + # clicks the Show More button to show the rest of the file types + find(:xpath, "//*[@id='document-file-type-list-toggle']/span").click + expect(page).to have_content("Show Less") + expect(inital_file_types).to eq("hdf(12), ccc(1), bbb(1), aaa(1), pdf(1), py(1), rb(1), xls(1), doc(1), tiff(1)") + rest_of_file_types = find(:xpath, "//*[@id='document-file-type-list-extra']/div/span[2]").text + expect(rest_of_file_types).to eq("jpg(1), txt(1)") + expect(page).to have_selector('#document-file-type-list-extra', visible: true) + # Clicks the Show Less button to hide the rest of the file types + find(:xpath, "//*[@id='document-file-type-list-toggle']/span").click + expect(page).to have_content("Show More") + expect(inital_file_types).to eq("hdf(12), ccc(1), bbb(1), aaa(1), pdf(1), py(1), rb(1), xls(1), doc(1), tiff(1)") + expect(page).to have_selector('#document-file-type-list-extra', visible: false) + end + it 'correctly sorts by file size' do visit '/catalog/doi-10-34770-bm4s-t361' sleep(0.1) # wait for the files to load via AJAX