Skip to content

Commit

Permalink
Merge pull request #373 from projecthydra-labs/feature-test
Browse files Browse the repository at this point in the history
Make dashboard feature test more efficient, fixes #328
  • Loading branch information
jcoyne committed Dec 2, 2015
2 parents 7e51364 + 71c3001 commit c342470
Showing 1 changed file with 40 additions and 54 deletions.
94 changes: 40 additions & 54 deletions spec/features/browse_dashboard_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,67 @@

describe "Browse Dashboard", type: :feature do
let(:user) { FactoryGirl.create(:user) }

let!(:dissertation) { FactoryGirl.create(:public_work, user: user, title: ["Fake PDF Title"], subject: %w(lorem ipsum dolor sit amet)) }

let!(:mp3_work) { FactoryGirl.create(:public_work, user: user, title: ["Test Document MP3"], subject: %w(consectetur adipisicing elit)) }

let!(:audio_work) { FactoryGirl.create(:public_work, user: user, title: ["Fake Wav Files"], subject: %w(sed do eiusmod tempor incididunt ut labore)) }

before do
sign_in user
end

it "searches your files by default" do
visit "/dashboard"
fill_in "q", with: "PDF"
click_button "search-submit-header"
expect(page).to have_content("Fake PDF Title")
end

it 'has buttons for user actions' do
it "lets the user search and display their files" do
expect(page).to have_link("Create Collection")
expect(page).to have_link("Upload")
end

context "within my files page" do
before do
visit "/dashboard/files"
end
# Search
fill_in "q", with: "PDF"
click_button "search-submit-header"
expect(page).to have_content("Fake PDF Title")

it "allows you to search your own works and remove constraints" do
fill_in "q", with: "PDF"
click_button "search-submit-header"
expect(page).to have_content("Fake PDF Title")
within(".constraints-container") do
expect(page).to have_content("You searched for:")
expect(page).to have_css("span.glyphicon-remove")
find(".dropdown-toggle").click
end
expect(page).to have_content("Fake Wav File")
visit "/dashboard/files"
fill_in "q", with: "PDF"
click_button "search-submit-header"
expect(page).to have_content("Fake PDF Title")
within(".constraints-container") do
expect(page).to have_content("You searched for:")
expect(page).to have_css("span.glyphicon-remove")
find(".dropdown-toggle").click
end
expect(page).to have_content("Fake Wav File")

it "allows you to browse facets" do
click_link "Subject"
click_link "more Subjects"
click_link "consectetur"
# Browse facets
click_link "Subject"
click_link "more Subjects"
click_link "consectetur"

within("#document_#{mp3_work.id}") do
expect(page).to have_link("Display all details of Test Document MP3",
href: curation_concerns_generic_work_path(mp3_work))
end
within("#document_#{mp3_work.id}") do
expect(page).to have_link("Display all details of Test Document MP3",
href: curation_concerns_generic_work_path(mp3_work))
end
click_link("Remove constraint Subject: consectetur")

it "refreshes the page" do
# TODO: this would make a good view test.
click_button "Refresh"
within("#document_#{dissertation.id}") do
click_button("Select an action")
expect(page).to have_content("Edit Work")
end
end

it "allows me to delete works in upload_sets", js: true do
first('input#check_all').click
expect {
click_button('Delete Selected')
}.to change { GenericWork.count }.by(-3)
# Refresh the page
click_button "Refresh"
within("#document_#{dissertation.id}") do
click_button("Select an action")
expect(page).to have_content("Edit Work")
end

it "links to my other tabs" do
# TODO: this would make a good view test.
["My Collections", "My Highlights", "Files Shared with Me"].each do |tab|
within("#my_nav") do
click_link(tab)
end
expect(page).to have_content(tab)
# View other tabs
["My Collections", "My Highlights", "Files Shared with Me"].each do |tab|
within("#my_nav") do
click_link(tab)
end
expect(page).to have_content(tab)
end
end

it "allows me to delete works in upload_sets", js: true do
visit "/dashboard/files"
first('input#check_all').click
expect {
click_button('Delete Selected')
}.to change { GenericWork.count }.by(-3)
end
end

0 comments on commit c342470

Please sign in to comment.