Skip to content

A platform for community discussion. Free, open, simple.

DEV: Reduce redundant setup and app loads in system tests (#44467)

Alan Guo Xiang Tan0000031f1e77
diff --git a/frontend/discourse/app/lib/sidebar/admin-sidebar.js b/frontend/discourse/app/lib/sidebar/admin-sidebar.js
index d115dba757c..ea2375e8789 100644
--- a/frontend/discourse/app/lib/sidebar/admin-sidebar.js
+++ b/frontend/discourse/app/lib/sidebar/admin-sidebar.js
@@ -389,7 +389,6 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
"service:site-settings"
);
const site = getOwnerWithFallback(this).lookup("service:site");
- const store = getOwnerWithFallback(this).lookup("service:store");
const router = getOwnerWithFallback(this).lookup("service:router");
const session = getOwnerWithFallback(this).lookup("service:session");
const designWizard = getOwnerWithFallback(this).lookup(
@@ -432,24 +431,6 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
}
}
- // Mods cannot access themes
- if (currentUser.admin) {
- store.findAll("theme").then((themes) => {
- this.adminSidebarStateManager.setLinkKeywords(
- "admin_themes_and_components",
- themes.content
- .filter((theme) => !theme.component)
- .map((theme) => theme.name)
- );
- this.adminSidebarStateManager.setLinkKeywords(
- "admin_themes_and_components",
- themes.content
- .filter((theme) => theme.component)
- .map((theme) => theme.name)
- );
- });
- }
-
if (siteSettings.enable_form_templates) {
this.adminNavManager.amendLinksToSection("appearance", [
{
diff --git a/plugins/discourse-events/spec/system/post_event_spec.rb b/plugins/discourse-events/spec/system/post_event_spec.rb
index 03100fdba4e..774200b6846 100644
--- a/plugins/discourse-events/spec/system/post_event_spec.rb
+++ b/plugins/discourse-events/spec/system/post_event_spec.rb
@@ -148,16 +148,15 @@ describe "Post event" do
expect(composer).to have_value(/end=2024-06-03/)
end
- context "when showLocalTime is set and the event crosses midnight relative to the viewer",
- timezone: "Australia/Brisbane" do
+ context "when showLocalTime is set and the event crosses midnight relative to the viewer" do
it "renders the preview badge in the event timezone, not the viewer's" do
- # 2025-09-07 22:30 Europe/Paris == 2025-09-08 06:30 Australia/Brisbane,
- # so without showLocalTime the viewer would see "Sep 8" in the badge.
+ # 2025-09-07 00:30 Europe/Paris == 2025-09-06 22:30 UTC,
+ # so without showLocalTime the viewer would see "Sep 6" in the badge.
# With showLocalTime, the preview must stay anchored to the event timezone.
visit("/new-topic")
composer.fill_title("Local time preview test")
composer.fill_content <<~MD
- [event start='2025-09-07 22:30' timezone='Europe/Paris' showLocalTime='true' status='public']
+ [event start='2025-09-07 00:30' timezone='Europe/Paris' showLocalTime='true' status='public']
[/event]
MD
@@ -208,7 +207,7 @@ describe "Post event" do
end
end
- context "when showing local time", timezone: "Australia/Brisbane" do
+ context "when showing local time" do
it "correctly shows month/day" do
page.driver.with_playwright_page do |pw_page|
pw_page.clock.install(time: Time.new(2025, 6, 5, 22, 0, 0))
@@ -216,7 +215,7 @@ describe "Post event" do
title = "My FR test meetup event"
raw = <<~MD
- [event showLocalTime='true' start='2025-09-07 17:30' timezone='Europe/Paris']
+ [event showLocalTime='true' start='2025-09-07 00:30' timezone='Europe/Paris']
[/event]
MD
post = PostCreator.create(admin, title:, raw:)
diff --git a/plugins/discourse-events/spec/system/upcoming_events_spec.rb b/plugins/discourse-events/spec/system/upcoming_events_spec.rb
index 4dcb2c66b8d..962c8fe6c9f 100644
--- a/plugins/discourse-events/spec/system/upcoming_events_spec.rb
+++ b/plugins/discourse-events/spec/system/upcoming_events_spec.rb
@@ -448,6 +448,8 @@ describe "Upcoming Events" do
end
context "in different timezone", timezone: "Europe/London" do
+ fab!(:admin) { Fabricate(:admin, timezone: "Europe/London") }
+
it "navigates to current date in day view", time: Time.utc(2025, 6, 2, 19, 00) do
visit("/upcoming-events/day/2025/8/1")
@@ -478,6 +480,8 @@ describe "Upcoming Events" do
end
context "in different timezone", timezone: "Europe/London" do
+ fab!(:admin) { Fabricate(:admin, timezone: "Europe/London") }
+
it "navigates to next day" do
visit("/upcoming-events/day/2025/8/4")
@@ -527,6 +531,8 @@ describe "Upcoming Events" do
end
context "in different timezone", timezone: "Europe/London" do
+ fab!(:admin) { Fabricate(:admin, timezone: "Europe/London") }
+
it "navigates to previous day" do
visit("/upcoming-events/day/2025/8/1")
diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb
index 2a3cc6eb0a3..3b14bade08c 100644
--- a/spec/fabricators/user_fabricator.rb
+++ b/spec/fabricators/user_fabricator.rb
@@ -6,6 +6,7 @@ Fabricator(:user, class_name: :user) do
transient refresh_auto_groups: false
transient trust_level: nil
transient search_index: false
+ transient timezone: "Etc/UTC"
transient composition_mode: UserOption.composition_mode_types[:markdown]
transient seen_before: false
@@ -24,10 +25,13 @@ Fabricator(:user, class_name: :user) do
end
SearchIndexer.disable if transients[:search_index]
- # TODO (martin) It would be good to remove this at some point once specs are updated
+ # TODO (martin) It would be good to remove the composition mode override once specs are updated
# to use the rich editor by default. Otherwise, if this is not done, there are tons
# of specs failing when setting SiteSetting.default_composition_mode default to rich
- user.user_option.update!(composition_mode: transients[:composition_mode])
+ user.user_option.update!(
+ composition_mode: transients[:composition_mode],
+ timezone: transients[:timezone],
+ )
if transients[:seen_before]
user.update!(last_seen_at: 2.days.ago, previous_visit_at: 2.days.ago)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index c0af60f3361..5fe908bf50c 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1500,6 +1500,8 @@ RSpec.describe User do
end
describe "update_timezone_if_missing" do
+ subject(:user) { Fabricate(:user, last_seen_at: 1.day.ago, timezone: nil) }
+
let(:timezone) { nil }
it "does nothing if timezone is nil" do
diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rb
index 59a4d370aee..ec06c72212f 100644
--- a/spec/requests/session_controller_spec.rb
+++ b/spec/requests/session_controller_spec.rb
@@ -315,6 +315,8 @@ RSpec.describe SessionController do
end
context "when timezone param is provided" do
+ let(:user) { Fabricate(:user, timezone: nil) }
+
it "sets the user_option timezone for the user" do
post "/session/email-login/#{email_token.token}.json",
params: {
@@ -3504,6 +3506,8 @@ RSpec.describe SessionController do
end
context "when timezone param is provided" do
+ let(:user) { Fabricate(:user, timezone: nil) }
+
it "sets the user_option timezone for the user" do
post "/session.json",
params: {
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 8baf021637f..88dbf99c8c8 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -413,6 +413,8 @@ RSpec.describe UsersController do
end
it "sets the users timezone if the param is present" do
+ user1.user_option.update!(timezone: nil)
+
get "/u/password-reset/#{email_token.token}"
expect(user1.user_option.timezone).to eq(nil)
diff --git a/spec/support/shared_contexts/prosemirror_editor_context.rb b/spec/support/shared_contexts/prosemirror_editor_context.rb
index 18ffaaae44d..7f37150f0e6 100644
--- a/spec/support/shared_contexts/prosemirror_editor_context.rb
+++ b/spec/support/shared_contexts/prosemirror_editor_context.rb
@@ -9,13 +9,6 @@ RSpec.shared_context "with prosemirror editor" do
)
end
- fab!(:tag)
- fab!(:category_with_emoji) do
- Fabricate(:category, slug: "cat", emoji: "cat", style_type: "emoji")
- end
- fab!(:category_with_icon) { Fabricate(:category, icon: "bell", style_type: "icon") }
- fab!(:category_without_icon, :category)
-
let(:cdp) { PageObjects::CDP.new }
let(:composer) { PageObjects::Components::Composer.new }
let(:rich) { composer.rich_editor }
diff --git a/spec/system/about_page_spec.rb b/spec/system/about_page_spec.rb
index 6a3cf3743b7..de871c653da 100644
--- a/spec/system/about_page_spec.rb
+++ b/spec/system/about_page_spec.rb
@@ -105,6 +105,7 @@ describe "About page" do
about_page.visit
expect(about_page.site_activities).to have_no_activity_item("visitors")
+ expect(about_page).to have_no_traffic_info_footer
end
end
@@ -118,6 +119,7 @@ describe "About page" do
expect(about_page.site_activities.visitors).to have_text(
"0 visitors, about 0 from the EU",
)
+ expect(about_page).to have_traffic_info_footer
end
end
end
@@ -172,24 +174,6 @@ describe "About page" do
expect(about_page.site_activities.likes).to have_all_time_period
end
end
-
- describe "traffic info footer" do
- it "is displayed when the display_eu_visitor_stats setting is true" do
- SiteSetting.display_eu_visitor_stats = true
-
- about_page.visit
-
- expect(about_page).to have_traffic_info_footer
- end
-
- it "is not displayed when the display_eu_visitor_stats setting is false" do
- SiteSetting.display_eu_visitor_stats = false
-
- about_page.visit
-
- expect(about_page).to have_no_traffic_info_footer
- end
- end
end
describe "our admins section" do
@@ -197,7 +181,7 @@ describe "About page" do
fab!(:admins) { Fabricate.times(8, :admin) }
- it "displays only the 6 most recently seen admins when there are more than 6 admins" do
+ it "orders the admins list, expands and collapses it, and opens a user card" do
admins[0].update!(last_seen_at: 4.minutes.ago)
admins[1].update!(last_seen_at: 1.minute.ago)
admins[2].update!(last_seen_at: 10.minutes.ago)
@@ -210,10 +194,6 @@ describe "About page" do
expect(displayed_admins.map { |u| u[:username] }.first(3)).to eq(
[admins[1].username, admins[0].username, admins[2].username],
)
- end
-
- it "allows expanding and collapsing the list of admins" do
- about_page.visit
displayed_admins = about_page.admins_list.users
expect(displayed_admins.size).to eq(6)
@@ -233,6 +213,9 @@ describe "About page" do
displayed_admins = about_page.admins_list.users
expect(displayed_admins.size).to eq(6)
+
+ about_page.admins_list.users.first[:node].click
+ expect(about_page).to have_css("#user-card")
end
it "doesn't show an expand/collapse button when there are fewer than 6 admins" do
@@ -274,13 +257,6 @@ describe "About page" do
*admins.pluck(:name),
)
end
-
- it "opens the user card when a user is clicked" do
- about_page.visit
-
- about_page.admins_list.users.first[:node].click
- expect(about_page).to have_css("#user-card")
- end
end
describe "our moderators section" do
@@ -288,7 +264,7 @@ describe "About page" do
fab!(:moderators) { Fabricate.times(9, :moderator) }
- it "displays only the 6 most recently seen moderators when there are more than 6 moderators" do
+ it "orders the moderators list, expands and collapses it, and opens a user card" do
moderators[5].update!(last_seen_at: 5.hours.ago)
moderators[4].update!(last_seen_at: 2.hours.ago)
moderators[1].update!(last_seen_at: 13.hours.ago)
@@ -301,10 +277,6 @@ describe "About page" do
expect(displayed_mods.map { |u| u[:username] }.first(3)).to eq(
[moderators[4].username, moderators[5].username, moderators[1].username],
)
- end
-
- it "allows expanding and collapsing the list of moderators" do
- about_page.visit
displayed_mods = about_page.moderators_list.users
expect(displayed_mods.size).to eq(6)
@@ -324,6 +296,9 @@ describe "About page" do
displayed_mods = about_page.moderators_list.users
expect(displayed_mods.size).to eq(6)
+
+ about_page.moderators_list.users.last[:node].click
+ expect(about_page).to have_css("#user-card")
end
it "doesn't show an expand/collapse button when there are fewer than 6 moderators" do
@@ -365,13 +340,6 @@ describe "About page" do
*moderators.pluck(:name),
)
end
-
- it "opens the user card when a user is clicked" do
- about_page.visit
-
- about_page.moderators_list.users.last[:node].click
- expect(about_page).to have_css("#user-card")
- end
end
describe "extra groups" do
diff --git a/spec/system/admin_site_texts_spec.rb b/spec/system/admin_site_texts_spec.rb
index e7a3b7dbbd5..4d292ae9af1 100644
--- a/spec/system/admin_site_texts_spec.rb
+++ b/spec/system/admin_site_texts_spec.rb
@@ -15,8 +15,8 @@ describe "Admin Site Texts Page" do
expect(site_texts_page).to have_translation_key("js.skip_to_main_content")
expect(site_texts_page).to have_translation_value(I18n.t("js.skip_to_main_content"))
- site_texts_page.visit
site_texts_page.search("js.skip_to_main_content")
+ expect(site_texts_page).to have_highlighted_translation_key("js.skip_to_main_content")
expect(site_texts_page).to have_translation_key("js.skip_to_main_content")
expect(site_texts_page).to have_translation_value(I18n.t("js.skip_to_main_content"))
end
@@ -27,8 +27,8 @@ describe "Admin Site Texts Page" do
expect(site_texts_page).to have_translation_key("themes.other_error")
expect(site_texts_page).to have_translation_value(I18n.t("themes.other_error"))
- site_texts_page.visit
site_texts_page.search("themes.other_error")
+ expect(site_texts_page).to have_highlighted_translation_key("themes.other_error")
expect(site_texts_page).to have_translation_key("themes.other_error")
expect(site_texts_page).to have_translation_value(I18n.t("themes.other_error"))
end
@@ -42,9 +42,8 @@ describe "Admin Site Texts Page" do
I18n.t("js.skip_to_main_content", locale: "it"),
)
- site_texts_page.visit
- site_texts_page.select_locale("it")
site_texts_page.search("js.skip_to_main_content")
+ expect(site_texts_page).to have_highlighted_translation_key("js.skip_to_main_content")
expect(site_texts_page).to have_translation_key("js.skip_to_main_content")
expect(site_texts_page).to have_translation_value(
I18n.t("js.skip_to_main_content", locale: "it"),
diff --git a/spec/system/composer/prosemirror_autocomplete_spec.rb b/spec/system/composer/prosemirror_autocomplete_spec.rb
index ca236a23bac..f1b9953fe28 100644
--- a/spec/system/composer/prosemirror_autocomplete_spec.rb
+++ b/spec/system/composer/prosemirror_autocomplete_spec.rb
@@ -3,6 +3,13 @@
describe "Composer - ProseMirror - Autocomplete" do
include_context "with prosemirror editor"
+ fab!(:tag)
+ fab!(:category_with_emoji) do
+ Fabricate(:category, slug: "cat", emoji: "cat", style_type: "emoji")
+ end
+ fab!(:category_with_icon) { Fabricate(:category, icon: "bell", style_type: "icon") }
+ fab!(:category_without_icon, :category)
+
it "triggers an autocomplete on mention" do
open_composer
composer.type_content("@#{current_user.username}")
diff --git a/spec/system/composer/prosemirror_keymap_spec.rb b/spec/system/composer/prosemirror_keymap_spec.rb
index 70b15f68d19..5db0ec56abe 100644
--- a/spec/system/composer/prosemirror_keymap_spec.rb
+++ b/spec/system/composer/prosemirror_keymap_spec.rb
@@ -3,6 +3,10 @@
describe "Composer - ProseMirror - Keyboard shortcuts" do
include_context "with prosemirror editor"
+ fab!(:category_with_emoji) do
+ Fabricate(:category, slug: "cat", emoji: "cat", style_type: "emoji")
+ end
+
it "supports Ctrl + B to create a bold text" do
open_composer
composer.type_content([SystemHelpers::PLATFORM_KEY_MODIFIER, "b"])
diff --git a/spec/system/composer/prosemirror_pasting_spec.rb b/spec/system/composer/prosemirror_pasting_spec.rb
index e04797184ba..109fc767a45 100644
--- a/spec/system/composer/prosemirror_pasting_spec.rb
+++ b/spec/system/composer/prosemirror_pasting_spec.rb
@@ -316,7 +316,7 @@ describe "Composer - ProseMirror - Pasting content" do
end
context "when pasting tables" do
- it "fills incomplete rows" do
+ it "normalizes pasted tables and handles empty rows" do
cdp.allow_clipboard
open_composer
@@ -347,11 +347,9 @@ describe "Composer - ProseMirror - Pasting content" do
MARKDOWN
expect(composer).to have_value(markdown)
- end
-
- it "normalizes column counts when header has fewer columns than body rows" do
- cdp.allow_clipboard
- open_composer
+ composer.clear_content
+ composer.toggle_rich_editor
+ composer.focus
html = <<~HTML
<table>
@@ -376,11 +374,9 @@ describe "Composer - ProseMirror - Pasting content" do
MARKDOWN
expect(composer).to have_value(markdown)
- end
-
- it "normalizes nested table column counts" do
- cdp.allow_clipboard
- open_composer
+ composer.clear_content
+ composer.toggle_rich_editor
+ composer.focus
html = <<~HTML
<table>
@@ -421,11 +417,9 @@ describe "Composer - ProseMirror - Pasting content" do
MARKDOWN
expect(composer).to have_value(markdown)
- end
-
- it "handles tables with empty rows without crashing" do
- cdp.allow_clipboard
- open_composer
+ composer.clear_content
+ composer.toggle_rich_editor
+ composer.focus
html = <<~HTML
<table>
diff --git a/spec/system/content_localization_spec.rb b/spec/system/content_localization_spec.rb
index ab255b064a9..a5d97d31d56 100644
--- a/spec/system/content_localization_spec.rb
+++ b/spec/system/content_localization_spec.rb
@@ -492,6 +492,7 @@ describe "Content Localization" do
Fabricate(
:post,
topic: topic,
+ user: admin,
locale: "ja",
raw: "Japanese content for post #{post_number}",
cooked: "<p>日本語コンテンツ #{post_number}</p>",
@@ -540,12 +541,19 @@ describe "Content Localization" do
Fabricate(
:post,
topic: late_localization_topic,
+ user: admin,
locale: "en",
raw: "English post #{index + 1}",
)
end
late_post =
- Fabricate(:post, topic: late_localization_topic, locale: "ja", raw: "最初のページより後の投稿")
+ Fabricate(
+ :post,
+ topic: late_localization_topic,
+ user: admin,
+ locale: "ja",
+ raw: "最初のページより後の投稿",
+ )
Fabricate(
:post_localization,
post: late_post,
diff --git a/spec/system/custom_sidebar_sections_spec.rb b/spec/system/custom_sidebar_sections_spec.rb
index 05bd480b330..81106ced4e3 100644
--- a/spec/system/custom_sidebar_sections_spec.rb
+++ b/spec/system/custom_sidebar_sections_spec.rb
@@ -38,145 +38,130 @@ describe "Custom sidebar sections" do
include_examples "creating custom sections"
- it "allows the user to create custom section with /my link" do
+ it "allows the user to create sections with different link formats" do
sign_in user
visit("/latest")
sidebar.click_add_section_button
- section_modal.fill_name("My section")
+ section_modal.fill_name("Preferences section")
section_modal.fill_link("My preferences", "/my/preferences")
section_modal.save
- expect(sidebar).to have_section("My section")
+ expect(section_modal).to be_closed
+ expect(sidebar).to have_section("Preferences section")
expect(sidebar).to have_section_link("My preferences", target: "_self")
- end
-
- it "prioritizes exact url matches over ember routes" do
- sidebar_section = SidebarSection.find_by(section_type: "community")
- sidebar_url = Fabricate(:sidebar_url, name: "Topics", value: "/latest")
- sidebar_url_2 =
- Fabricate(:sidebar_url, name: "Sorted latest", value: "/latest?ascending=true&order=posts")
- Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url)
- Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url_2)
-
- sign_in user
-
- visit("/latest?ascending=true&order=posts")
- expect(sidebar).to have_exact_url_match_link("Sorted latest")
- expect(sidebar).to have_no_active_links
- expect(sidebar).to have_no_exact_url_match_link("everything")
-
- visit("/latest")
- expect(sidebar).to have_active_link("everything")
- expect(sidebar).to have_no_exact_url_match_link("Sorted latest")
- end
-
- it "allows the user to create custom section with `/` path" do
- SiteSetting.top_menu = "read|posted|latest"
-
- sign_in user
- visit("/latest")
sidebar.click_add_section_button
- section_modal.fill_name("My section")
- section_modal.fill_link("Home", "/")
- section_modal.save
-
- expect(sidebar).to have_section("My section")
- expect(sidebar).to have_section_link("Home", href: "/")
-
- sidebar.click_section_link("Home")
- expect(page).to have_css("#navigation-bar .active a[href='/read']")
- end
-
- it "allows the user to create custom section with /pub link" do
- sign_in user
- visit("/latest")
-
- sidebar.click_add_section_button
- section_modal.fill_name("My section")
+ section_modal.fill_name("Published page section")
section_modal.fill_link("Published Page", "/pub/test")
section_modal.save
- expect(sidebar).to have_section("My section")
+ expect(section_modal).to be_closed
+ expect(sidebar).to have_section("Published page section")
expect(sidebar).to have_section_link("Published Page", target: "_self")
- end
- it "allows the user to create custom section with external link" do
- sign_in user
- visit("/latest")
sidebar.click_add_section_button
expect(section_modal).to be_visible
expect(section_modal).to have_disabled_save
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
- section_modal.fill_name("My section")
+ section_modal.fill_name("External link section")
section_modal.fill_link("Discourse Homepage", "https://discourse.org")
expect(section_modal).to have_enabled_save
section_modal.save
- expect(sidebar).to have_section("My section")
+ expect(section_modal).to be_closed
+ expect(sidebar).to have_section("External link section")
expect(sidebar).to have_section_link(
"Discourse Homepage",
href: "https://discourse.org",
target: "_blank",
)
- end
- it "allows the user to create custom section with anchor" do
- sign_in user
- visit("/latest")
sidebar.click_add_section_button
expect(section_modal).to be_visible
expect(section_modal).to have_disabled_save
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
- section_modal.fill_name("My section")
+ section_modal.fill_name("Anchor section")
section_modal.fill_link("Faq", "/faq#anchor")
section_modal.save
- expect(sidebar).to have_section("My section")
+ expect(section_modal).to be_closed
+ expect(sidebar).to have_section("Anchor section")
expect(sidebar).to have_section_link("Faq", target: "_self", href: "/faq#anchor")
- end
- it "allows the user to create custom section with query param" do
- sign_in user
- visit("/latest")
sidebar.click_add_section_button
expect(section_modal).to be_visible
expect(section_modal).to have_disabled_save
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
- section_modal.fill_name("My section")
+ section_modal.fill_name("Query section")
section_modal.fill_link("Faq", "/faq?a=b")
section_modal.save
- expect(sidebar).to have_section("My section")
+ expect(section_modal).to be_closed
+ expect(sidebar).to have_section("Query section")
expect(sidebar).to have_section_link("Faq", target: "_self", href: "/faq?a=b")
- end
- it "allows the user to create custom section with anchor link" do
- sign_in user
- visit("/latest")
sidebar.click_add_section_button
expect(section_modal).to be_visible
expect(section_modal).to have_disabled_save
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
- section_modal.fill_name("My section")
+ section_modal.fill_name("Heading section")
section_modal.fill_link("Faq", "/faq#someheading")
section_modal.save
- expect(sidebar).to have_section("My section")
+ expect(section_modal).to be_closed
+ expect(sidebar).to have_section("Heading section")
expect(sidebar).to have_section_link("Faq", target: "_self", href: "/faq#someheading")
end
+ it "prioritizes exact url matches over ember routes" do
+ sidebar_section = SidebarSection.find_by(section_type: "community")
+ sidebar_url = Fabricate(:sidebar_url, name: "Topics", value: "/latest")
+ sidebar_url_2 =
+ Fabricate(:sidebar_url, name: "Sorted latest", value: "/latest?ascending=true&order=posts")
+ Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url)
+ Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url_2)
+
+ sign_in user
+
+ visit("/latest?ascending=true&order=posts")
+ expect(sidebar).to have_exact_url_match_link("Sorted latest")
+ expect(sidebar).to have_no_active_links
+ expect(sidebar).to have_no_exact_url_match_link("everything")
+
+ visit("/latest")
+ expect(sidebar).to have_active_link("everything")
+ expect(sidebar).to have_no_exact_url_match_link("Sorted latest")
+ end
+
+ it "allows the user to create custom section with `/` path" do
+ SiteSetting.top_menu = "read|posted|latest"
+
+ sign_in user
+ visit("/latest")
+
+ sidebar.click_add_section_button
+ section_modal.fill_name("My section")
+ section_modal.fill_link("Home", "/")
+ section_modal.save
+
+ expect(sidebar).to have_section("My section")
+ expect(sidebar).to have_section_link("Home", href: "/")
+
+ sidebar.click_section_link("Home")
+ expect(page).to have_css("#navigation-bar .active a[href='/read']")
+ end
+
it "allows typing in the icon picker filter input" do
sign_in user
visit("/latest")
diff --git a/spec/system/lightbox_spec.rb b/spec/system/lightbox_spec.rb
index c357deb93a4..499d6d9fe27 100644
--- a/spec/system/lightbox_spec.rb
+++ b/spec/system/lightbox_spec.rb
@@ -25,10 +25,15 @@ describe "Lightbox | Photoswipe" do
post.update(cooked: cpp.html)
end
- it "has the correct lightbox elements" do
+ it "lets the user inspect a single image and quote it into the composer" do
topic_page.visit_topic(topic)
- topic_page.post_by_number(1).find("a.lightbox").click
+ lightbox_link = topic_page.post_by_number(1).find("a.lightbox")
+ lightbox_image = lightbox_link.find("img", visible: :all)
+ expected_width = lightbox_link["data-target-width"].presence || lightbox_image["width"]
+ expected_height = lightbox_link["data-target-height"].presence || lightbox_image["height"]
+ expected_src = lightbox_image["data-orig-src"].presence || lightbox_link["href"]
+ lightbox_link.click
expect(lightbox).to be_visible
@@ -41,17 +46,14 @@ describe "Lightbox | Photoswipe" do
expect(lightbox).to have_download_button
expect(lightbox).to have_original_image_button
expect(lightbox).to have_image_info_button
- end
- it "quotes the image into the composer" do
- topic_page.visit_topic(topic)
+ lightbox.image_info_button.click
- lightbox_link = topic_page.post_by_number(1).find("a.lightbox")
- lightbox_image = lightbox_link.find("img", visible: :all)
- expected_width = lightbox_link["data-target-width"].presence || lightbox_image["width"]
- expected_height = lightbox_link["data-target-height"].presence || lightbox_image["height"]
- expected_src = lightbox_image["data-orig-src"].presence || lightbox_link["href"]
- lightbox_link.click
+ expect(lightbox).to have_caption_details("2400×3600 1.21 KB")
+
+ lightbox.image_info_button.click
+
+ expect(lightbox).to have_no_caption_details
expect(lightbox).to have_quote_button
@@ -73,23 +75,6 @@ describe "Lightbox | Photoswipe" do
expect(lightbox).to have_no_image_info_button
end
-
- it "can toggle image info" do
- topic_page.visit_topic(topic)
-
- topic_page.post_by_number(1).find("a.lightbox").click
-
- expect(lightbox).to be_visible
- expect(lightbox).to have_no_caption_details
-
- lightbox.image_info_button.click
-
- expect(lightbox).to have_caption_details("2400×3600 1.21 KB")
-
- lightbox.image_info_button.click
-
- expect(lightbox).to have_no_caption_details
- end
end
context "with multiple images" do
@@ -192,7 +177,7 @@ describe "Lightbox | Photoswipe" do
post.update(cooked: cpp.html)
end
- it "toggles UI by tapping image" do
+ it "lets the user toggle image controls and information before closing the lightbox" do
topic_page.visit_topic(topic)
topic_page.post_by_number(1).find("a.lightbox").click
@@ -204,23 +189,6 @@ describe "Lightbox | Photoswipe" do
tap_screen_at(screen_center_x, screen_center_y)
expect(lightbox).to have_ui_visible
- end
-
- it "closes lightbox by tapping backdrop" do
- topic_page.visit_topic(topic)
- topic_page.post_by_number(1).find("a.lightbox").click
-
- expect(lightbox).to be_visible
-
- tap_screen_at(50, 50)
-
- expect(lightbox).to be_hidden
- end
-
- it "toggles image info by clicking button" do
- topic_page.visit_topic(topic)
-
- topic_page.post_by_number(1).find("a.lightbox").click
expect(lightbox).to be_visible
expect(lightbox).to have_no_caption_details
@@ -232,6 +200,12 @@ describe "Lightbox | Photoswipe" do
lightbox.image_info_button.click
expect(lightbox).to have_no_caption_details
+
+ expect(lightbox).to be_visible
+
+ tap_screen_at(50, 50)
+
+ expect(lightbox).to be_hidden
end
end
diff --git a/spec/system/login_spec.rb b/spec/system/login_spec.rb
index 016a0740d53..265b6aea05b 100644
--- a/spec/system/login_spec.rb
+++ b/spec/system/login_spec.rb
@@ -131,12 +131,15 @@ shared_examples "login scenarios" do
context "when login is required" do
before { SiteSetting.login_required = true }
- it "cannot browse annonymously" do
+ it "keeps topics private until the user logs in" do
visit "/"
screenshot_marker(label: "login-required")
expect(page).to have_css(".login-welcome")
expect(page).to have_css(".site-logo")
+ expect(page.body).not_to include(topic.title)
+ expect(page.body).not_to include(topic2.title)
+
find(".login-welcome .login-button").click
screenshot_marker(label: "login-form")
@@ -174,15 +177,6 @@ shared_examples "login scenarios" do
expect(page).to have_current_path("/new-topic?category_id=#{category.id}")
end
- it "does not leak topics" do
- visit "/"
-
- expect(page).to have_css(".login-welcome")
-
- expect(page.body).not_to include(topic.title)
- expect(page.body).not_to include(topic2.title)
- end
-
it "does not leak category metadata if homepage is /categories" do
SiteSetting.top_menu = "categories|latest|new|top"
visit "/"
@@ -417,22 +411,7 @@ shared_examples "login scenarios" do
expect(reset_password_page).to have_logged_in_user
end
- it "can reset password with TOTP" do
- login_form.open.fill_username("john").forgot_password
- find("button.forgot-password-reset").click
-
- reset_password_link = wait_for_email_link(user, :reset_password)
- visit reset_password_link
- totp = ROTP::TOTP.new(user_second_factor.data).now
- find(".second-factor-token-input").fill_in(with: totp)
- find(".password-reset .btn-primary").click
- find("#new-account-password").fill_in(with: "newsuperpassword")
- find(".change-password-form .btn-primary").click
-
- expect(page).to have_css(".header-dropdown-toggle.current-user")
- end
-
- it "shows error correctly when TOTP code is invalid" do
+ it "lets the user retry an invalid TOTP code and reset their password" do
login_form.open.fill_username("john").forgot_password
find("button.forgot-password-reset").click
@@ -446,6 +425,14 @@ shared_examples "login scenarios" do
text: "Invalid authentication code. Each code can only be used once.",
)
expect(page).to have_css(".second-factor-token-input")
+
+ totp = ROTP::TOTP.new(user_second_factor.data).now
+ find(".second-factor-token-input").fill_in(with: totp)
+ find(".password-reset .btn-primary").click
+ find("#new-account-password").fill_in(with: "newsuperpassword")
+ find(".change-password-form .btn-primary").click
+
+ expect(page).to have_css(".header-dropdown-toggle.current-user")
end
it "can reset password with a backup code" do
diff --git a/spec/system/page_objects/cdp.rb b/spec/system/page_objects/cdp.rb
index 27008e4e6be..f132ddc60fe 100644
--- a/spec/system/page_objects/cdp.rb
+++ b/spec/system/page_objects/cdp.rb
@@ -162,7 +162,7 @@ module PageObjects
"Network.emulateNetworkConditions",
params: {
offline: false,
- latency: 20_000,
+ latency: 0,
downloadThroughput: -1,
uploadThroughput: 1,
},
diff --git a/spec/system/page_objects/components/logo.rb b/spec/system/page_objects/components/logo.rb
index d64ed75bd9d..518bbd8891c 100644
--- a/spec/system/page_objects/components/logo.rb
+++ b/spec/system/page_objects/components/logo.rb
@@ -6,7 +6,7 @@ module PageObjects
SELECTOR = "#site-logo"
def click
- find(SELECTOR).click
+ find(".d-header .title a").click
end
def hover
diff --git a/spec/system/page_objects/components/topic_list.rb b/spec/system/page_objects/components/topic_list.rb
index 90a7266fb87..211008429da 100644
--- a/spec/system/page_objects/components/topic_list.rb
+++ b/spec/system/page_objects/components/topic_list.rb
@@ -90,6 +90,10 @@ module PageObjects
find("#{topic_list_item_class(topic)} a.raw-topic-link").click
end
+ def scroll_to_topic_at_index(index)
+ page.scroll_to(all(TOPIC_LIST_ITEM_SELECTOR)[index], align: :top)
+ end
+
def scroll_page_down(amount: 50)
page.execute_script(<<~JS, amount)
const listArea = document.querySelector("#list-area");
diff --git a/spec/system/page_objects/pages/admin_site_texts.rb b/spec/system/page_objects/pages/admin_site_texts.rb
index ba0ea0a8af2..241438cafcf 100644
--- a/spec/system/page_objects/pages/admin_site_texts.rb
+++ b/spec/system/page_objects/pages/admin_site_texts.rb
@@ -17,6 +17,10 @@ module PageObjects
has_css?(".site-text-id", text: key)
end
+ def has_highlighted_translation_key?(key)
+ has_css?(".site-text-id .text-highlight", text: key, exact_text: true)
+ end
+
def has_translation_value?(value)
has_css?(".site-text-value", text: value)
end
diff --git a/spec/system/post_menu_spec.rb b/spec/system/post_menu_spec.rb
index 3e9ae9dd13d..95c3f914630 100644
--- a/spec/system/post_menu_spec.rb
+++ b/spec/system/post_menu_spec.rb
@@ -165,11 +165,6 @@ describe "Post menu" do
describe "bookmark" do
before { SiteSetting.post_menu_hidden_items = "" }
- it "does not display the bookmark button when the user is anonymous" do
- topic_page.visit_topic(post.topic)
- expect(topic_page).to have_no_post_action_button(post, :bookmark)
- end
-
it "works as expected" do
sign_in(user)
@@ -200,16 +195,21 @@ describe "Post menu" do
end
end
- describe "delete / recover" do
+ describe "action visibility" do
before { SiteSetting.post_menu_hidden_items = "" }
- it "displays the delete button only when the user can delete the post" do
+ it "shows post action buttons according to the user's permissions" do
# do not display the edit button when unlogged
topic_page.visit_topic(post.topic)
expect(topic_page).to have_no_post_action_button(post, :delete)
expect(topic_page).to have_no_post_action_button(post2, :delete)
+ # do not display the edit button when unlogged
+ expect(topic_page).to have_no_post_action_button(post, :flag)
+ expect(topic_page).to have_no_post_action_button(post2, :flag)
+ expect(topic_page).to have_no_post_action_button(post, :bookmark)
+
# display the delete button only for the post that `user` can delete
sign_in(user)
@@ -218,6 +218,10 @@ describe "Post menu" do
expect(topic_page).to have_no_post_action_button(post, :delete)
expect(topic_page).to have_post_action_button(post2, :delete)
+ # display the flag button only for the post that `user` can flag
+ expect(topic_page).to have_post_action_button(post, :flag)
+ expect(topic_page).to have_post_action_button(post2, :flag)
+
# display the delete button for the all the posts because an admin is logged
sign_in(admin)
@@ -225,7 +229,15 @@ describe "Post menu" do
expect(topic_page).to have_post_action_button(post, :delete)
expect(topic_page).to have_post_action_button(post2, :delete)
+
+ # display the flag button for the all the posts because an admin is logged
+ expect(topic_page).to have_post_action_button(post, :flag)
+ expect(topic_page).to have_post_action_button(post2, :flag)
end
+ end
+
+ describe "delete / recover" do
+ before { SiteSetting.post_menu_hidden_items = "" }
it "displays the recover button only when the user can recover the post" do
PostDestroyer.new(user, post2).destroy
@@ -414,30 +426,6 @@ describe "Post menu" do
describe "flag" do
before { SiteSetting.post_menu_hidden_items = "" }
- it "displays the flag button only when the user can flag the post" do
- # do not display the edit button when unlogged
- topic_page.visit_topic(post.topic)
-
- expect(topic_page).to have_no_post_action_button(post, :flag)
- expect(topic_page).to have_no_post_action_button(post2, :flag)
-
- # display the flag button only for the post that `user` can flag
- sign_in(user)
-
- topic_page.visit_topic(post.topic)
-
- expect(topic_page).to have_post_action_button(post, :flag)
- expect(topic_page).to have_post_action_button(post2, :flag)
-
- # display the flag button for the all the posts because an admin is logged
- sign_in(admin)
-
- topic_page.visit_topic(post.topic)
-
- expect(topic_page).to have_post_action_button(post, :flag)
- expect(topic_page).to have_post_action_button(post2, :flag)
- end
-
it "works as expected" do
sign_in(user)
diff --git a/spec/system/scroll_manager_service_spec.rb b/spec/system/scroll_manager_service_spec.rb
index 7bcf3fee132..1e74b55080c 100644
--- a/spec/system/scroll_manager_service_spec.rb
+++ b/spec/system/scroll_manager_service_spec.rb
@@ -20,14 +20,12 @@ describe "Ember route-scroll-manager service" do
expect(page).to have_css("body.navigation-topics")
expect(discovery.topic_list).to have_topics
- page.execute_script <<~JS
- document.querySelectorAll('.topic-list-item')[10].scrollIntoView(true);
- JS
+ discovery.topic_list.scroll_to_topic_at_index(10)
topic_list_scroll_y = current_scroll_y
expect(topic_list_scroll_y).to be > 0
- find(".sidebar-section-link[data-link-name='all-categories']").click
+ find(".sidebar-section-link[data-link-name='all-categories']").send_keys(:enter)
expect(page).to have_css("body.navigation-categories")
expect(current_scroll_y).to eq(0)
@@ -47,7 +45,7 @@ describe "Ember route-scroll-manager service" do
visit("/t/#{topic.slug}/#{topic.id}")
expect(page).to have_css("#post_20")
- page.execute_script("window.scrollTo(0, document.body.scrollHeight)")
+ page.scroll_to(:bottom)
expect(current_scroll_y).to be > 0
click_logo
diff --git a/spec/system/signup_spec.rb b/spec/system/signup_spec.rb
index e08b081b5c2..0cd9651d781 100644
--- a/spec/system/signup_spec.rb
+++ b/spec/system/signup_spec.rb
@@ -16,7 +16,7 @@ shared_examples "signup scenarios" do
context "when anyone can create an account" do
before { Jobs.run_immediately! }
- it "can signup" do
+ it "can sign up, activate the account, and access 2FA preferences" do
signup_page
.open
.fill_email(invite.email)
@@ -26,19 +26,6 @@ shared_examples "signup scenarios" do
screenshot_marker(label: "signup")
- signup_page.click_create_account
-
- expect(page).to have_current_path("/u/account-created")
- end
-
- it "can signup and activate account" do
- signup_page
- .open
- .fill_email(invite.email)
- .fill_username("john")
- .fill_password("supersecurepassword")
- expect(signup_page).to have_valid_fields
-
signup_page.click_create_account
expect(page).to have_current_path("/u/account-created")
@@ -55,29 +42,6 @@ shared_examples "signup scenarios" do
expect(page).to have_current_path("/")
expect(page).to have_css(".header-dropdown-toggle.current-user")
- end
-
- it "can access 2FA preferences screen after signing up and activating account" do
- signup_page
- .open
- .fill_email(invite.email)
- .fill_username("john")
- .fill_password("supersecurepassword")
- expect(signup_page).to have_valid_fields
-
- signup_page.click_create_account
- expect(page).to have_current_path("/u/account-created")
-
- mail = ActionMailer::Base.deliveries.first
- expect(mail.to).to contain_exactly(invite.email)
- activation_link = mail.body.to_s[%r{/u/activate-account/\S+}]
-
- visit activation_link
-
- activate_account.click_activate_account
- activate_account.click_continue
-
- expect(page).to have_css(".header-dropdown-toggle.current-user")
visit "/u/john/preferences/security"
diff --git a/spec/system/social_authentication_spec.rb b/spec/system/social_authentication_spec.rb
index d55ccead8e5..8f75038b1f4 100644
--- a/spec/system/social_authentication_spec.rb
+++ b/spec/system/social_authentication_spec.rb
@@ -19,8 +19,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_facebook_auth
- visit("/")
-
signup_page.open.click_social_button("facebook")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -39,8 +37,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_google_auth
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -55,8 +51,6 @@ shared_examples "social authentication scenarios" do
context "when the email is not verified" do
it "needs to verify email" do
mock_google_auth(verified: false)
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -76,8 +70,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_github_auth
- visit("/")
-
signup_page.open.click_social_button("github")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -91,8 +83,6 @@ shared_examples "social authentication scenarios" do
context "when the email is not verified" do
it "needs to verify email" do
mock_github_auth(verified: false)
- visit("/")
-
signup_page.open.click_social_button("github")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -112,8 +102,6 @@ shared_examples "social authentication scenarios" do
it "lets user input Name when no name is provided" do
mock_github_auth(name: "")
- visit("/")
-
signup_page.open.click_social_button("github")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -130,8 +118,6 @@ shared_examples "social authentication scenarios" do
it "works with a provided name" do
mock_github_auth(name: "Some Name")
- visit("/")
-
signup_page.open.click_social_button("github")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -151,8 +137,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_twitter_auth
- visit("/")
-
signup_page.open.click_social_button("twitter")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -167,8 +151,6 @@ shared_examples "social authentication scenarios" do
context "when the email is not verified" do
it "needs to verify email" do
mock_twitter_auth(verified: false)
- visit("/")
-
signup_page.open.click_social_button("twitter")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -187,8 +169,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_discord_auth
- visit("/")
-
signup_page.open.click_social_button("discord")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -207,8 +187,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_linkedin_auth
- visit("/")
-
signup_page.open.click_social_button("linkedin_oidc")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -227,8 +205,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form" do
mock_google_auth
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -251,8 +227,6 @@ shared_examples "social authentication scenarios" do
it "fills the signup form and disables the inputs" do
mock_google_auth
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -276,8 +250,6 @@ shared_examples "social authentication scenarios" do
it "creates the account directly" do
mock_google_auth
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@@ -285,8 +257,6 @@ shared_examples "social authentication scenarios" do
it "shows signup form when no username can be derived" do
SiteSetting.use_email_for_username_and_name_suggestions = false
mock_google_auth(name: "")
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(signup_page).to be_open
expect(signup_page).to have_no_password_input
@@ -443,8 +413,6 @@ shared_examples "social authentication scenarios" do
it "logs in user" do
mock_facebook_auth
- visit("/")
-
signup_page.open.click_social_button("facebook")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@@ -488,8 +456,6 @@ shared_examples "social authentication scenarios" do
it "shows suspended message" do
mock_facebook_auth
- visit("/")
-
signup_page.open.click_social_button("facebook")
expect(page).to have_css(
@@ -506,8 +472,6 @@ shared_examples "social authentication scenarios" do
it "logs in user" do
mock_google_auth
- visit("/")
-
signup_page.open.click_social_button("google_oauth2")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@@ -519,8 +483,6 @@ shared_examples "social authentication scenarios" do
it "logs in user" do
mock_github_auth
- visit("/")
-
signup_page.open.click_social_button("github")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@@ -538,8 +500,6 @@ shared_examples "social authentication scenarios" do
)
mock_twitter_auth
- visit("/")
-
signup_page.open.click_social_button("twitter")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@@ -551,8 +511,6 @@ shared_examples "social authentication scenarios" do
it "logs in user" do
mock_discord_auth
- visit("/")
-
signup_page.open.click_social_button("discord")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@@ -565,8 +523,6 @@ shared_examples "social authentication scenarios" do
it "logs in user" do
mock_linkedin_auth
- visit("/")
-
signup_page.open.click_social_button("linkedin_oidc")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
diff --git a/spec/system/unified_new_topic_list_spec.rb b/spec/system/unified_new_topic_list_spec.rb
index 6beb9af944a..e3643e925df 100644
--- a/spec/system/unified_new_topic_list_spec.rb
+++ b/spec/system/unified_new_topic_list_spec.rb
@@ -34,7 +34,7 @@ describe "Unified new topic list" do
context "when unified new is enabled" do
before { SiteSetting.enable_unified_new = true }
- it "shows all new topics and replies by default" do
+ it "lets the user switch between all new topics, topics, and replies" do
visit("/new")
expect(topic_list).to have_topics(count: 6)
@@ -53,24 +53,7 @@ describe "Unified new topic list" do
expect(tabs_toggle.all_tab).to be_active
expect(tabs_toggle.replies_tab).to be_inactive
expect(tabs_toggle.topics_tab).to be_inactive
- end
-
- it "respects the subset query param and activates the appropriate tab" do
- visit("/new?subset=topics")
-
- expect(tabs_toggle.all_tab).to be_inactive
- expect(tabs_toggle.replies_tab).to be_inactive
- expect(tabs_toggle.topics_tab).to be_active
-
- visit("/new?subset=replies")
-
- expect(tabs_toggle.all_tab).to be_inactive
- expect(tabs_toggle.replies_tab).to be_active
- expect(tabs_toggle.topics_tab).to be_inactive
- end
- it "shows only new topics when the user switches to the Topics tab" do
- visit("/new")
tabs_toggle.topics_tab.click
expect(topic_list).to have_topics(count: 3)
@@ -86,10 +69,12 @@ describe "Unified new topic list" do
expect(tabs_toggle.topics_tab).to have_count(3)
expect(page).to have_current_path("/new?subset=topics")
- end
- it "shows only topics with new replies when the user switches to the Replies tab" do
- visit("/new")
+ tabs_toggle.all_tab.click
+
+ expect(tabs_toggle.all_tab).to be_active
+ expect(topic_list).to have_topics(count: 6)
+
tabs_toggle.replies_tab.click
expect(topic_list).to have_topics(count: 3)
@@ -107,6 +92,20 @@ describe "Unified new topic list" do
expect(page).to have_current_path("/new?subset=replies")
end
+ it "respects the subset query param and activates the appropriate tab" do
+ visit("/new?subset=topics")
+
+ expect(tabs_toggle.all_tab).to be_inactive
+ expect(tabs_toggle.replies_tab).to be_inactive
+ expect(tabs_toggle.topics_tab).to be_active
+
+ visit("/new?subset=replies")
+
+ expect(tabs_toggle.all_tab).to be_inactive
+ expect(tabs_toggle.replies_tab).to be_active
+ expect(tabs_toggle.topics_tab).to be_inactive
+ end
+
it "strips out the subset query params when switching back to the All tab from any of the other tabs" do
visit("/new")
tabs_toggle.replies_tab.click
@@ -141,7 +140,7 @@ describe "Unified new topic list" do
end
context "when the /new topic list is scoped to a category" do
- it "shows new topics and replies in the category" do
+ it "lets the user switch between new topics and replies in the category" do
visit("/c/#{category.slug}/#{category.id}/l/new")
expect(topic_list).to have_topics(count: 2)
expect(topic_list).to have_topic(new_reply_in_category)
@@ -153,10 +152,7 @@ describe "Unified new topic list" do
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)
- end
- it "shows only new topics in the category when the user switches to the Topics tab" do
- visit("/c/#{category.slug}/#{category.id}/l/new")
tabs_toggle.topics_tab.click
expect(topic_list).to have_topics(count: 1)
@@ -172,10 +168,12 @@ describe "Unified new topic list" do
expect(page).to have_current_path(
"/c/#{category.slug}/#{category.id}/l/new?subset=topics",
)
- end
- it "shows only topics with new replies in the category when the user switches to the Replies tab" do
- visit("/c/#{category.slug}/#{category.id}/l/new")
+ tabs_toggle.all_tab.click
+
+ expect(tabs_toggle.all_tab).to be_active
+ expect(topic_list).to have_topics(count: 2)
+
tabs_toggle.replies_tab.click
expect(topic_list).to have_topics(count: 1)
@@ -223,7 +221,7 @@ describe "Unified new topic list" do
end
context "when the /new topic list is scoped to a tag" do
- it "shows new topics and replies with the tag" do
+ it "lets the user switch between new topics and replies with the tag" do
visit("/tag/#{tag.slug}/#{tag.id}/l/new")
expect(topic_list).to have_topics(count: 2)
[new_reply_with_tag, new_topic_with_tag].each do |topic|
@@ -236,10 +234,7 @@ describe "Unified new topic list" do
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)
- end
- it "shows only new topics with the tag when the user switches to the Topics tab" do
- visit("/tag/#{tag.slug}/#{tag.id}/l/new")
tabs_toggle.topics_tab.click
expect(topic_list).to have_topics(count: 1)
@@ -253,10 +248,11 @@ describe "Unified new topic list" do
expect(tabs_toggle.topics_tab).to have_count(1)
expect(page).to have_current_path("/tag/#{tag.slug}/#{tag.id}/l/new?subset=topics")
- end
- it "shows only topics with new replies with the tag when the user switches to the Replies tab" do
- visit("/tag/#{tag.slug}/#{tag.id}/l/new")
+ tabs_toggle.all_tab.click
+
+ expect(tabs_toggle.all_tab).to be_active
+ expect(topic_list).to have_topics(count: 2)
tabs_toggle.replies_tab.click
diff --git a/spec/system/user_page/user_preferences_profile_spec.rb b/spec/system/user_page/user_preferences_profile_spec.rb
index d2b57af9d01..e9c3e22ea53 100644
--- a/spec/system/user_page/user_preferences_profile_spec.rb
+++ b/spec/system/user_page/user_preferences_profile_spec.rb
@@ -10,7 +10,10 @@ describe "User preferences | Profile" do
describe "changing bio" do
it "correctly updates the bio" do
+ user.user_option.update!(timezone: nil)
+
user_preferences_profile_page.visit(user)
+ expect(user.user_option.reload.timezone).to be_present
user_preferences_profile_page.expand_profile_details
user_preferences_profile_page.fill_bio(with: "I am a human.")