From e2d9d0f2b4adaf2992e0ec45fe6d0f2a0f03d5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 11 Oct 2024 04:33:03 +0200 Subject: [PATCH] Fix default dashboard actions factories We had a trait called `:admin_request` for actions that are requests to administrators, but the default factories were also requests to administrators. The tests checking that the "Request" button is not present, which shouldn't pass with the wrong default factories, were passing by coincidence. The issue was that we weren't checking whether that the request had finished before checking that the "Request" button wasn't present. That meant that we were checking that the "Request" button wasn't there right at the moment we pressed the link, before the request was finished. So we're now checking that the request is finished before checking that the button isn't there. On the other hand, the tests checking for the "Request resource" link being present were checking a behavior that's no longer there since commit 9d85b3935, when we changed the conditions affecting that link. --- spec/factories/proposals.rb | 2 +- spec/system/dashboard/dashboard_spec.rb | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/factories/proposals.rb b/spec/factories/proposals.rb index 3b75c707f..15421f33e 100644 --- a/spec/factories/proposals.rb +++ b/spec/factories/proposals.rb @@ -142,7 +142,7 @@ FactoryBot.define do factory :dashboard_action, class: "Dashboard::Action" do title { Faker::Lorem.sentence[0..79].strip } description { Faker::Lorem.sentence } - request_to_administrators { true } + request_to_administrators { false } day_offset { 0 } required_supports { 0 } order { 0 } diff --git a/spec/system/dashboard/dashboard_spec.rb b/spec/system/dashboard/dashboard_spec.rb index 0a9195c4a..aaf7cfb28 100644 --- a/spec/system/dashboard/dashboard_spec.rb +++ b/spec/system/dashboard/dashboard_spec.rb @@ -178,7 +178,7 @@ describe "Proposal's dashboard" do expect(page).to have_content(solved.title) within "div#dashboard_action_#{available.id}" do - expect(page).to have_link("Request resource") + expect(page).to have_link "See resource" end within "div#dashboard_action_#{requested.id}" do @@ -225,7 +225,7 @@ describe "Proposal's dashboard" do expect(page).to have_content(solved.title) within "div#dashboard_action_#{available.id}" do - expect(page).to have_link("Request resource") + expect(page).to have_link "See resource" end within "div#dashboard_action_#{requested.id}" do @@ -308,7 +308,8 @@ describe "Proposal's dashboard" do visit proposal_dashboard_path(proposal) click_link(feature.title) - expect(page).not_to have_button("Request") + expect(page).to have_content feature.description + expect(page).not_to have_button "Request" end scenario "Resource admin request button do not appear on archived proposals" do @@ -323,8 +324,8 @@ describe "Proposal's dashboard" do click_link(feature.title) end - expect(page).not_to have_button("Request") - expect(page).to have_content("This proposal is archived and can not request resources.") + expect(page).to have_content "This proposal is archived and can not request resources." + expect(page).not_to have_button "Request" end scenario "Dashboard has a link to dashboard community" do