docbrown/spec/system/articles/moderator_moderates_an_article.rb
Vaidehi Joshi b1de4cb1cf
Add Percy 🦔 (#7783) [deploy]
* Add Percy to Gemfile, rails helper

* Percy snapshots for using the editor

* Add PERCY_TOKEN to sample_application.yml

* Percy snapshots for visiting the homepage

* Percy snapshots for viewing an article's comments

* Percy snapshots for creating an article

* Percy snapshots for editing an article

* Percy snapshots for logged in/out user

* Remove empty spec file

* Percy snapshots for settings page

* Percy snapshots for reading list

* Percy snapshots for admin view

* Percy snapshots for moderator view

* Percy snapshots for authentication views

* Percy snapshots for article and tag views

* Percy snapshots for editing/deleting comment views

* Percy snapshots for admin views

* Percy snapshots for comment views

* Percy snapshots for organization views

* Percy snapshots for pro membership views

* Percy snapshots for podcast views

* Percy snapshots for user views

* Percy snapshots for dashboard views

* Percy snapshots for homepage views

* Percy snapshots for video views

* Add js: true in tests that require it for Percy

* Percy dependency cleanup

* Add the Percy agent
* Remove the PERCY_TOKEN from sample_application.yml
* Move the Percy gem into the "test" group in the Gemfile

* Remove duplicate snapshots, provide unique names to snapshots

* Set seed on Faker::Config for deterministic Percy snapshots

* Freeze time in js: true tests for determinstic snapshots

* Upgrade Percy to v0.26.3

* Add percy: true flag for Percy snapshotting tests

* Add more percy: true flags
2020-05-18 11:35:53 -07:00

41 lines
1.5 KiB
Ruby

require "rails_helper"
RSpec.describe "Views an article", type: :system do
let_it_be(:user) { create(:user) }
let_it_be(:moderator) { create(:user, :trusted) }
let_it_be(:article, reload: true) { create(:article, :with_notification_subscription, user: user) }
let(:timestamp) { "2019-03-04T10:00:00Z" }
before do
sign_in moderator
visit "/#{user.username}/#{article.slug}/mod"
end
it "shows an article", js: true, percy: true do
visit "/#{user.username}/#{article.slug}"
Percy.snapshot(page, name: "Moderators: renders an article")
expect(page).to have_content(article.title)
end
it "lets moderators visit /mod", js: true, percy: true do
visit "/#{user.username}/#{article.slug}/mod"
Percy.snapshot(page, name: "Moderators: renders /mod")
expect(page).to have_content("Moderate: #{article.title}")
expect(page).to have_selector('button[data-category="thumbsdown"][data-reactable-type="Article"]')
expect(page).to have_selector('button[data-category="vomit"][data-reactable-type="Article"]')
expect(page).to have_selector('button[data-category="vomit"][data-reactable-type="User"]')
expect(page).to have_selector("button.level-rating-button")
end
it "shows hidden comments on /mod" do
commentor = create(:user)
create(:comment, commentable: article, user: commentor, hidden_by_commentable_user: true)
visit "/#{user.username}/#{article.slug}/mod"
expect(page).to have_content("Hidden Comments")
expect(page).to have_selector("ul#hidden-comments")
end
end