A platform for community discussion. Free, open, simple.
# frozen_string_literal: true
describe "Viewing sidebar mobile", mobile: true do
fab!(:user)
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
let(:composer) { PageObjects::Components::Composer.new }
let(:edit_categories_modal) { PageObjects::Modals::SidebarEditCategories.new }
before { sign_in(user) }
it "does not display the sidebar by default" do
visit("/latest")
expect(sidebar_dropdown).to be_hidden
end
it "does not display the keyboard shortcuts button" do
visit("/latest")
sidebar_dropdown.click
expect(sidebar_dropdown).to be_visible
expect(sidebar_dropdown).to have_no_keyboard_shortcuts_button
end
it "collapses the sidebar when clicking outside of it" do
visit("/latest")
sidebar_dropdown.click
expect(sidebar_dropdown).to be_visible
sidebar_dropdown.click_outside
expect(sidebar_dropdown).to be_hidden
end
it "lets an admin edit categories from the sidebar action menu" do
user.update!(admin: true)
visit("/latest")
sidebar_dropdown.click
sidebar_dropdown.click_edit_categories_dropdown_option
expect(sidebar_dropdown).to be_hidden
expect(edit_categories_modal).to have_right_title(
I18n.t("js.sidebar.categories_form_modal.title"),
)
end
it "collapses the sidebar when clicking on a link in the sidebar" do
visit("/latest")
sidebar_dropdown.click
expect(sidebar_dropdown).to be_visible
sidebar_dropdown.click_topics_link
expect(sidebar_dropdown).to be_hidden
end
it "collapses the sidebar when clicking on a button in the sidebar" do
visit("/latest")
sidebar_dropdown.click
expect(sidebar_dropdown).to be_visible
sidebar_dropdown.click_categories_header_button
expect(sidebar_dropdown).to be_hidden
end
end