mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Switch sidebar section link identifier to data attribute (#21051)
Data attribute is less restrictive than relying on the class attribute
This commit is contained in:

committed by
GitHub

parent
3b045a2016
commit
2eb60c9713
@ -10,6 +10,7 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
fab!(:message) { Fabricate(:chat_message, chat_channel: category_channel) }
|
||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
|
||||
let(:sidebar_component) { PageObjects::Components::Sidebar.new }
|
||||
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
|
||||
|
||||
before do
|
||||
@ -134,7 +135,7 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
visit("/t/-/#{topic.id}")
|
||||
chat_page.open_from_header
|
||||
chat_drawer_page.close
|
||||
find("a[class*='sidebar-section-link-#{category_channel.slug}']").click
|
||||
sidebar_component.click_link(category_channel.name)
|
||||
|
||||
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
|
||||
end
|
||||
@ -146,7 +147,7 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
chat_page.open_from_header
|
||||
chat_drawer_page.maximize
|
||||
visit("/")
|
||||
find("a[class*='sidebar-section-link-#{category_channel.slug}']").click
|
||||
sidebar_component.click_link(category_channel.name)
|
||||
|
||||
expect(page).to have_current_path(
|
||||
chat.channel_path(category_channel.slug, category_channel.id),
|
||||
@ -247,23 +248,19 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
|
||||
it "activates the channel in the sidebar" do
|
||||
visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
|
||||
expect(page).to have_css(
|
||||
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||
)
|
||||
|
||||
expect(sidebar_component).to have_section_link(category_channel.name, active: true)
|
||||
end
|
||||
|
||||
it "does not have multiple channels marked active in the sidebar" do
|
||||
chat_page.visit_channel(dm_channel)
|
||||
expect(page).to have_css(
|
||||
".sidebar-section-link-#{other_user.username}.sidebar-section-link--active",
|
||||
)
|
||||
|
||||
page.find(".sidebar-section-link-#{category_channel.slug}").click
|
||||
expect(page).to have_css(
|
||||
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||
)
|
||||
expect(sidebar_component).to have_section_link(other_user.username, active: true)
|
||||
|
||||
expect(page).to have_css(".sidebar-section-link--active", count: 1)
|
||||
sidebar_component.click_section_link(category_channel.name)
|
||||
|
||||
expect(sidebar_component).to have_section_link(category_channel.name, active: true)
|
||||
expect(sidebar_component).to have_one_active_section_link
|
||||
end
|
||||
end
|
||||
|
||||
@ -280,9 +277,7 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
|
||||
find("#site-logo").click
|
||||
|
||||
expect(page).not_to have_css(
|
||||
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||
)
|
||||
expect(sidebar_component).not_to have_section_link(category_channel.name, active: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -290,11 +285,9 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
it "activates the channel in the sidebar" do
|
||||
visit("/")
|
||||
chat_page.open_from_header
|
||||
find("a[class*='#{category_channel.slug}']").click
|
||||
sidebar_component.click_link(category_channel.name)
|
||||
|
||||
expect(page).to have_css(
|
||||
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||
)
|
||||
expect(sidebar_component).to have_section_link(category_channel.name, active: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -302,12 +295,11 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
it "deactivates the channel in the sidebar" do
|
||||
visit("/")
|
||||
chat_page.open_from_header
|
||||
find("a[class*='sidebar-section-link-#{category_channel.slug}']").click
|
||||
|
||||
sidebar_component.click_link(category_channel.name)
|
||||
chat_drawer_page.close
|
||||
|
||||
expect(page).not_to have_css(
|
||||
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||
)
|
||||
expect(sidebar_component).not_to have_section_link(category_channel.name, active: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user