docbrown/spec/system/user_visits_a_comments_page_spec.rb
ludwiczakpawel 70706d0a62
Comments UI update (#11283)
* tooltips 1.0.1

* tooltips 1.0.1

* init

* .

* drop not needed files

* .

* init

* init

* .

* comments

* border

* missing bits

* build comment JS

* .

* .

* specs

* sloan avatar fix

* bunch of fixes

* specs and fixes

* specs

* .

* swap order of links

* contrast

* js for dropdown

* icons

* op-author

* three dots icon

* reverts

* test: capybara- make sure that we click the dropdown before clicking on edit

* permalink --> link

* tiny fixes

* aria-label on form

* proper alt on user's avatar

* aria has popup

* use UL > LI instead of DIV

* add aria-labels to dropdown items

* another aria-label

* better links: nav

* contrast

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2020-11-18 18:21:19 -05:00

42 lines
1.7 KiB
Ruby

require "rails_helper"
RSpec.describe "Views an article", type: :system, 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", visible: :visible, text: "Author", 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", visible: :visible, text: "Ask Me Anything")
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