2024-04-03 23:43:56 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Homepage", type: :system do
|
|
|
|
fab!(:admin)
|
|
|
|
fab!(:user)
|
|
|
|
fab!(:topics) { Fabricate.times(2, :post).map(&:topic) }
|
|
|
|
fab!(:posts) { Fabricate.times(3, :post, topic: topics[0]) }
|
2024-08-08 20:02:00 +08:00
|
|
|
|
2024-04-03 23:43:56 +08:00
|
|
|
let(:discovery) { PageObjects::Pages::Discovery.new }
|
2024-08-08 20:02:00 +08:00
|
|
|
let(:tooltip) { PageObjects::Components::Tooltips.new("user-tip") }
|
2024-04-03 23:43:56 +08:00
|
|
|
|
|
|
|
context "when user tips are disabled" do
|
|
|
|
before { SiteSetting.enable_user_tips = false }
|
|
|
|
|
|
|
|
it "does not show the 'first notification' tip to the user when disabled" do
|
2024-08-08 20:02:00 +08:00
|
|
|
sign_in(user)
|
|
|
|
visit("/")
|
2024-04-03 23:43:56 +08:00
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
expect(tooltip).to be_not_present
|
2024-04-03 23:43:56 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not show the boostrapping tip to an admin user" do
|
|
|
|
SiteSetting.bootstrap_mode_enabled = true
|
2024-08-08 20:02:00 +08:00
|
|
|
sign_in(admin)
|
|
|
|
visit("/")
|
2024-04-03 23:43:56 +08:00
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
expect(tooltip).to be_not_present
|
2024-04-03 23:43:56 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when user tips are enabled" do
|
|
|
|
before { SiteSetting.enable_user_tips = true }
|
|
|
|
|
|
|
|
it "shows the 'first notification' tip to the user when enabled" do
|
2024-08-08 20:02:00 +08:00
|
|
|
sign_in(user)
|
|
|
|
|
2024-04-03 23:43:56 +08:00
|
|
|
expect(user.user_option.seen_popups).to eq(nil)
|
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
visit("/")
|
2024-04-03 23:43:56 +08:00
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
expect(tooltip).to be_present(text: "Your first notification!")
|
2024-04-03 23:43:56 +08:00
|
|
|
|
2024-05-22 23:59:47 +08:00
|
|
|
# Find an element with no action to simulate clicking outside the user tip
|
|
|
|
find("th.topic-list-data span", text: "Topic").click
|
2024-04-05 00:40:09 +08:00
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
expect(tooltip).to be_not_present
|
2024-04-03 23:43:56 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "shows a second notification once first is dismissed and user visits a topic" do
|
2024-08-08 20:02:00 +08:00
|
|
|
sign_in(user)
|
|
|
|
visit("/")
|
2024-05-08 05:48:44 +08:00
|
|
|
find(".fk-d-tooltip__content .user-tip__buttons .btn-primary").click
|
2024-08-08 20:02:00 +08:00
|
|
|
|
|
|
|
expect(tooltip).to be_not_present
|
2024-04-03 23:43:56 +08:00
|
|
|
|
|
|
|
discovery.topic_list.visit_topic(topics[0])
|
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
expect(tooltip).to be_present(text: "Topic timeline")
|
|
|
|
|
|
|
|
tooltip.find(".user-tip__buttons .btn-primary").click
|
|
|
|
|
|
|
|
expect(tooltip).to be_present(text: "Keep reading!")
|
2024-04-03 23:43:56 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "can skip all tips" do
|
2024-08-08 20:02:00 +08:00
|
|
|
sign_in(user)
|
|
|
|
visit("/")
|
2024-04-03 23:43:56 +08:00
|
|
|
|
2024-08-08 20:02:00 +08:00
|
|
|
tooltip.find(".user-tip__buttons .btn", text: "Skip tips").click
|
|
|
|
|
|
|
|
expect(tooltip).to be_not_present
|
2024-04-03 23:43:56 +08:00
|
|
|
|
|
|
|
discovery.topic_list.visit_topic(topics[0])
|
2024-08-08 20:02:00 +08:00
|
|
|
|
|
|
|
expect(tooltip).to be_not_present
|
2024-04-03 23:43:56 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|