docbrown/spec/system/user_visits_a_comments_page_spec.rb
Mac Siri 842e6880b8
Routine rubocop fix on /spec (#19217)
* Softrun rubocop

* Hardrun rubocop (-A)

* Change a rubocop rule

* Add missing cops

* Undo & redo rubocop -A
2023-03-21 09:55:26 -04:00

42 lines
1.7 KiB
Ruby

require "rails_helper"
RSpec.describe "Views an article", js: true do
let(:user) { create(:user) }
let(:co_author) { create(:user) }
let(:article) { create(:article, user: user, co_author_ids: [co_author.id]) }
let(:ama_article) { create(:article, user: user, tags: "ama") }
let!(:comment) { create(:comment, commentable: article) }
let!(:child_comment) { create(:comment, parent: comment, commentable: article) }
it "shows all comments" do
create(:comment, commentable: article)
visit "#{article.path}/comments"
expect(page).to have_selector(".single-comment-node", visible: :visible, count: 3)
expect(page).not_to have_selector(".spec-op-author")
end
it "shows op marker on author and co-author comments" do
create(:comment, user: user, commentable: article)
create(:comment, user: co_author, commentable: article)
visit "#{article.path}/comments"
expect(page).to have_selector(".spec-op-author[data-tooltip='Author']", visible: :visible, count: 2)
end
it "shows special op marker on ama articles" do
create(:comment, user: user, commentable: ama_article)
visit "#{ama_article.path}/comments"
expect(page).to have_selector(".spec-op-author[data-tooltip='Ask Me Anything']", visible: :visible)
end
it "shows a thread" do
visit "#{article.path}/comments/#{comment.id_code_generated}"
expect(page).to have_selector(".single-comment-node", visible: :visible, count: 2)
expect(page).to have_selector(".comment--deep-0#comment-node-#{comment.id}", visible: :visible, count: 1)
expect(page).to have_selector(".comment--deep-1#comment-node-#{child_comment.id}", visible: :visible, count: 1)
end
end