These blocks are no longer used: * `allowed_phase_list` isn't used since commit04605d5d5* `level_two_user` isn't used since commit26d14cbd0* `heading` in `budgets/stats_spec` was added inc2457e36abut never used * `translatable` was added in44d137a4cbut it's overwritten in all the contexts. * `annotation` isn't used since commit79d00e7b9* `admin` in `tags/budget_investments_spec` isn't used since8a2e15980* `budget` in `welcome_spec` was added in87be6f302but never used
116 lines
3.8 KiB
Ruby
116 lines
3.8 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Commenting legislation annotations" do
|
|
let(:user) { create(:user) }
|
|
|
|
describe "Merged comment threads" do
|
|
let!(:draft_version) { create(:legislation_draft_version, :published) }
|
|
let!(:annotation1) do
|
|
create(:legislation_annotation,
|
|
draft_version: draft_version,
|
|
text: "my annotation",
|
|
ranges: [{ "start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5 }])
|
|
end
|
|
let!(:annotation2) do
|
|
create(:legislation_annotation,
|
|
draft_version: draft_version,
|
|
text: "my other annotation",
|
|
ranges: [{ "start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10 }])
|
|
end
|
|
let!(:comment1) { annotation1.comments.first }
|
|
let!(:comment2) { annotation2.comments.first }
|
|
|
|
before do
|
|
login_as user
|
|
|
|
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
|
|
|
expect(page).to have_css ".annotator-hl"
|
|
first(:css, ".annotator-hl").click
|
|
|
|
within(".comment-box") do
|
|
expect(page).to have_content "my annotation"
|
|
expect(page).to have_content "my other annotation"
|
|
end
|
|
end
|
|
|
|
scenario "View comments of annotations in an included range" do
|
|
within("#annotation-link") do
|
|
find(".icon-expand").click
|
|
end
|
|
|
|
expect(page).to have_css(".comment", count: 2)
|
|
expect(page).to have_content("my annotation")
|
|
expect(page).to have_content("my other annotation")
|
|
end
|
|
|
|
scenario "Reply on a single annotation thread and display it in the merged annotation thread" do
|
|
within(".comment-box #annotation-#{annotation1.id}-comments") do
|
|
first(:link, "0 replies").click
|
|
end
|
|
|
|
click_link "Reply"
|
|
|
|
within "#js-comment-form-comment_#{comment1.id}" do
|
|
fill_in "Leave your comment", with: "replying in single annotation thread"
|
|
click_button "Publish reply"
|
|
end
|
|
|
|
within "#comment_#{comment1.id}" do
|
|
expect(page).to have_content "replying in single annotation thread"
|
|
end
|
|
|
|
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
|
|
|
expect(page).to have_css ".annotator-hl"
|
|
first(:css, ".annotator-hl").click
|
|
|
|
within(".comment-box") do
|
|
expect(page).to have_content "my annotation"
|
|
expect(page).to have_content "my other annotation"
|
|
end
|
|
|
|
within("#annotation-link") do
|
|
find(".icon-expand").click
|
|
end
|
|
|
|
expect(page).to have_css(".comment", count: 3)
|
|
expect(page).to have_content("my annotation")
|
|
expect(page).to have_content("my other annotation")
|
|
expect(page).to have_content("replying in single annotation thread")
|
|
end
|
|
|
|
scenario "Reply on a multiple annotation thread and display it in the single annotation thread" do
|
|
within("#annotation-link") do
|
|
find(".icon-expand").click
|
|
end
|
|
|
|
within("#comment_#{comment2.id}") do
|
|
click_link "Reply"
|
|
end
|
|
|
|
within "#js-comment-form-comment_#{comment2.id}" do
|
|
fill_in "Leave your comment", with: "replying in multiple annotation thread"
|
|
click_button "Publish reply"
|
|
end
|
|
|
|
within "#comment_#{comment2.id}" do
|
|
expect(page).to have_content "replying in multiple annotation thread"
|
|
end
|
|
|
|
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
|
|
|
expect(page).to have_css ".annotator-hl"
|
|
first(:css, ".annotator-hl").click
|
|
|
|
within(".comment-box #annotation-#{annotation2.id}-comments") do
|
|
first(:link, "1 reply").click
|
|
end
|
|
|
|
expect(page).to have_css(".comment", count: 2)
|
|
expect(page).to have_content("my other annotation")
|
|
expect(page).to have_content("replying in multiple annotation thread")
|
|
end
|
|
end
|
|
end
|