DEV: Add system specs for dismiss new on tag routes (#23936)

This commit is contained in:
David Taylor 2023-10-16 10:51:59 +01:00 committed by GitHub
parent 20a765e3ca
commit aa4a5add70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 0 deletions

View File

@ -3,6 +3,7 @@
RSpec.describe "Dismissing New", type: :system do
fab!(:user) { Fabricate(:user) }
let(:discovery) { PageObjects::Pages::Discovery.new }
let(:topic_list_controls) { PageObjects::Components::TopicListControls.new }
let(:topic_list) { PageObjects::Components::TopicList.new }
let(:dismiss_new_modal) { PageObjects::Modals::DismissNew.new }
@ -129,5 +130,47 @@ RSpec.describe "Dismissing New", type: :system do
expect(topic_list).to have_no_topics
end
context "with a tagged topic" do
fab!(:tag) { Fabricate(:tag) }
fab!(:tagged_topic) { Fabricate(:topic, tags: [tag]) }
fab!(:tagged_first_post) { Fabricate(:post, topic: tagged_topic) }
it "works on tag routes" do
sign_in(user)
visit("/tag/#{tag.name}/l/new")
expect(topic_list).to have_topics(count: 1)
expect(topic_list).to have_topic(tagged_first_post.topic)
topic_list_controls.dismiss_new
dismiss_new_modal.click_dismiss
expect(topic_list).to have_no_topics
visit("/new")
expect(topic_list).to have_topic(post1.topic)
end
it "works on regular routes after visiting tagged route" do
sign_in(user)
visit("/tag/#{tag.name}/l/new")
expect(topic_list).to have_topics(count: 1)
discovery.tag_drop.select_row_by_value("all-tags")
expect(topic_list).to have_topics(count: 3)
discovery.nav_item("new").click
topic_list_controls.dismiss_new
dismiss_new_modal.click_dismiss
expect(topic_list).to have_no_topics
end
end
end
end

View File

@ -18,6 +18,10 @@ module PageObjects
def tag_drop
Components::SelectKit.new(".category-breadcrumb .tag-drop")
end
def nav_item(name)
find("#navigation-bar .nav-item_#{name}")
end
end
end
end