Move dashboard system tests to resources component specs
We're making the `new_actions_since_last_login` parameter optional in order to simplify the tests.
This commit is contained in:
@@ -138,116 +138,6 @@ describe "Proposal's dashboard" do
|
||||
expect(page).not_to have_content(action.title)
|
||||
end
|
||||
|
||||
scenario "Dashboard progress show available resources for proposal draft" do
|
||||
available = create(:dashboard_action, :resource, :active)
|
||||
|
||||
requested = create(:dashboard_action, :resource, :admin_request, :active)
|
||||
executed_action = create(:dashboard_executed_action, action: requested,
|
||||
proposal: proposal,
|
||||
executed_at: Time.current)
|
||||
_task = create(:dashboard_administrator_task, :pending, source: executed_action)
|
||||
|
||||
solved = create(:dashboard_action, :resource, :admin_request, :active)
|
||||
executed_solved_action = create(:dashboard_executed_action, action: solved,
|
||||
proposal: proposal,
|
||||
executed_at: Time.current)
|
||||
_solved_task = create(:dashboard_administrator_task, :done, source: executed_solved_action)
|
||||
|
||||
unavailable = create(:dashboard_action, :resource, :active,
|
||||
required_supports: proposal.votes_for.size + 1_000)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
within ".dashboard-resources" do
|
||||
expect(page).to have_content("Polls")
|
||||
expect(page).to have_content("E-mail")
|
||||
expect(page).to have_content("Poster")
|
||||
expect(page).to have_content(available.title)
|
||||
expect(page).to have_content(unavailable.title)
|
||||
expect(page).to have_content(requested.title)
|
||||
expect(page).to have_content(solved.title)
|
||||
|
||||
within "div#dashboard_action_#{available.id}" do
|
||||
expect(page).to have_link "See resource"
|
||||
end
|
||||
|
||||
within "div#dashboard_action_#{requested.id}" do
|
||||
expect(page).to have_content("Resource already requested")
|
||||
end
|
||||
|
||||
within "div#dashboard_action_#{unavailable.id}" do
|
||||
expect(page).to have_content("1.000 supports required")
|
||||
end
|
||||
|
||||
within "div#dashboard_action_#{solved.id}" do
|
||||
expect(page).to have_link("See resource")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Dashboard progress show available resources for published proposal" do
|
||||
proposal.update!(published_at: Date.current)
|
||||
available = create(:dashboard_action, :resource, :active)
|
||||
|
||||
requested = create(:dashboard_action, :resource, :admin_request, :active)
|
||||
executed_action = create(:dashboard_executed_action, action: requested,
|
||||
proposal: proposal,
|
||||
executed_at: Time.current)
|
||||
_task = create(:dashboard_administrator_task, :pending, source: executed_action)
|
||||
|
||||
solved = create(:dashboard_action, :resource, :admin_request, :active)
|
||||
executed_solved_action = create(:dashboard_executed_action, action: solved,
|
||||
proposal: proposal,
|
||||
executed_at: Time.current)
|
||||
_solved_task = create(:dashboard_administrator_task, :done, source: executed_solved_action)
|
||||
|
||||
unavailable = create(:dashboard_action, :resource, :active,
|
||||
required_supports: proposal.votes_for.size + 1_000)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
within ".dashboard-resources" do
|
||||
expect(page).to have_content("Polls")
|
||||
expect(page).to have_content("E-mail")
|
||||
expect(page).to have_content("Poster")
|
||||
expect(page).to have_content(available.title)
|
||||
expect(page).to have_content(unavailable.title)
|
||||
expect(page).to have_content(requested.title)
|
||||
expect(page).to have_content(solved.title)
|
||||
|
||||
within "div#dashboard_action_#{available.id}" do
|
||||
expect(page).to have_link "See resource"
|
||||
end
|
||||
|
||||
within "div#dashboard_action_#{requested.id}" do
|
||||
expect(page).to have_content("Resource already requested")
|
||||
end
|
||||
|
||||
within "div#dashboard_action_#{unavailable.id}" do
|
||||
expect(page).to have_content("1.000 supports required")
|
||||
end
|
||||
|
||||
within "div#dashboard_action_#{solved.id}" do
|
||||
expect(page).to have_link("See resource")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Dashboard progress dont show resources with published_proposal: true" do
|
||||
available = create(:dashboard_action, :resource, :active, published_proposal: true)
|
||||
unavailable = create(:dashboard_action, :resource, :active,
|
||||
required_supports: proposal.votes_for.size + 1_000,
|
||||
published_proposal: true)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
within ".dashboard-resources" do
|
||||
expect(page).to have_content("Polls")
|
||||
expect(page).to have_content("E-mail")
|
||||
expect(page).to have_content("Poster")
|
||||
expect(page).not_to have_content(available.title)
|
||||
expect(page).not_to have_content(unavailable.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Dashboard has a link to resources on main menu" do
|
||||
feature = create(:dashboard_action, :resource, :active)
|
||||
|
||||
@@ -480,29 +370,6 @@ describe "Proposal's dashboard" do
|
||||
describe "detect_new_actions_after_last_login" do
|
||||
before { proposal.author.update!(current_sign_in_at: 1.day.ago) }
|
||||
|
||||
scenario "Display tag 'new' on resouce when it is new for author since last login" do
|
||||
resource = create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
published_proposal: false)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
within "#dashboard_action_#{resource.id}" do
|
||||
expect(page).to have_content("New")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Not display tag 'new' on resouce when there is not new resources since last login" do
|
||||
resource = create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
published_proposal: false)
|
||||
proposal.author.update!(current_sign_in_at: Date.current)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
within "#dashboard_action_#{resource.id}" do
|
||||
expect(page).not_to have_content("New")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Display tag 'new' on proposed_action when it is new for author since last login" do
|
||||
proposed_action = create(:dashboard_action, :proposed_action, :active, day_offset: 0,
|
||||
published_proposal: false)
|
||||
|
||||
Reference in New Issue
Block a user