forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport 'User's group endorsement no longer disappears after persona…
…l endorsement removed' to v0.26 (decidim#10311) * User's group endorsement no longer disappears after personal endorsement removed * Fixed group endorsement removal when personal endorsement removed & tests * test-fixes * Improve the spec to wait the endorsement has happened --------- Co-authored-by: JoonasAapro <[email protected]> Co-authored-by: Antti Hukkanen <[email protected]>
- Loading branch information
1 parent
97c17c5
commit a94516d
Showing
2 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "endorse posts", type: :system do | ||
include_context "with a component" | ||
let(:manifest_name) { "blogs" } | ||
let(:organization) { create(:organization) } | ||
let(:author) { create(:user, :confirmed, name: "Tester", organization: organization) } | ||
let!(:post) { create(:post, component: component, title: { en: "Blog post title" }) } | ||
|
||
before do | ||
sign_in author | ||
visit_component | ||
click_link "Blog post title" | ||
end | ||
|
||
context "when endorsing the post without belonging to a user group" do | ||
it "endorses the post" do | ||
click_button("Endorse") | ||
expect(page).to have_content("ENDORSED") | ||
end | ||
end | ||
|
||
context "when endorsing the post while being a part of a group" do | ||
let!(:user_group) do | ||
create( | ||
:user_group, | ||
:verified, | ||
name: "Tester's Organization", | ||
nickname: "test_org", | ||
email: "[email protected]", | ||
users: [author], | ||
organization: organization | ||
) | ||
end | ||
|
||
it "opens a modal where you select identity as a user or a group" do | ||
visit page.current_path | ||
click_button("Endorse") | ||
expect(page).to have_content("SELECT IDENTITY") | ||
expect(page).to have_content("Tester's Organization") | ||
expect(page).to have_content("Tester") | ||
end | ||
|
||
def add_endorsements | ||
click_button "Endorse" | ||
within "#user-identities" do | ||
find("li", text: /\ATester's Organization\z/).click | ||
find("li", text: /\ATester\z/).click | ||
expect(page).to have_css(".selected", count: 2) | ||
click_button "Done" | ||
end | ||
visit current_path | ||
click_button "Endorse" | ||
end | ||
|
||
context "when both identities picked" do | ||
it "endorses the post as a group and a user" do | ||
visit page.current_path | ||
|
||
add_endorsements | ||
|
||
within "#user-identities" do | ||
expect(page).to have_css(".selected", count: 2) | ||
end | ||
end | ||
end | ||
|
||
context "when endorsement cancelled as a user" do | ||
it "doesn't cancel group endorsement" do | ||
visit page.current_path | ||
|
||
add_endorsements | ||
within "#user-identities" do | ||
find(".selected", match: :first).click | ||
expect(page).to have_css(".selected", count: 1) | ||
click_button "Done" | ||
end | ||
visit current_path | ||
click_button "Endorse" | ||
|
||
within "#user-identities" do | ||
expect(page).to have_css(".selected", count: 1) | ||
within ".selected" do | ||
expect(page).to have_text("Tester's Organization", exact: true) | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "when endorsement cancelled as a group" do | ||
it "doesn't cancel user endorsement" do | ||
visit page.current_path | ||
|
||
add_endorsements | ||
within "#user-identities" do | ||
page.all(".selected")[1].click | ||
click_button "Done" | ||
end | ||
visit current_path | ||
click_button "Endorse" | ||
|
||
within "#user-identities" do | ||
expect(page).to have_css(".selected", count: 1) | ||
within ".selected" do | ||
expect(page).to have_text("Tester", exact: true) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters