diff --git a/spec/system/authentication_spec.rb b/spec/system/authentication_spec.rb index 686b61744..16ad32b59 100644 --- a/spec/system/authentication_spec.rb +++ b/spec/system/authentication_spec.rb @@ -1,11 +1,37 @@ # frozen_string_literal: true RSpec.describe "authentication" do - it "redirects to login when accessing a protected page while logged out" do - create(:user) + before { create(:user) } + it "redirects to login when accessing news while logged out" do visit(news_path) expect(page).to have_current_path(login_path) end + + it "redirects to login when accessing starred while logged out" do + visit(starred_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing archive while logged out" do + visit(archive_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing feeds while logged out" do + visit(feeds_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing a feed while logged out" do + feed = create(:feed) + + visit("/feed/#{feed.id}") + + expect(page).to have_current_path(login_path) + end end diff --git a/spec/system/feed_edit_spec.rb b/spec/system/feed_edit_spec.rb index 02d13e345..86e23d38b 100644 --- a/spec/system/feed_edit_spec.rb +++ b/spec/system/feed_edit_spec.rb @@ -26,6 +26,23 @@ def visit_edit_feed expect(page).to have_content("Updated the feed") end + it "pre-selects the feed's current group in the dropdown" do + login_as(default_user) + feed = create(:feed, :with_group) + a11y_skip = [ + "aria-required-children", + "color-contrast", + "label", + "landmark-one-main", + "page-has-heading-one", + "region", + "select-name" + ] + visit("/feeds/#{feed.id}/edit", a11y_skip:) + + expect(page).to have_select("group-id", selected: feed.group.name) + end + it "allows removing a group from a feed" do login_as(default_user) feed = create(:feed, :with_group) diff --git a/spec/system/feed_show_spec.rb b/spec/system/feed_show_spec.rb index c60103967..1673ae6b0 100644 --- a/spec/system/feed_show_spec.rb +++ b/spec/system/feed_show_spec.rb @@ -81,6 +81,22 @@ def create_and_visit_feed(story_title: nil) expect(page).to have_content("Read Story") end + it "navigates home with the home button" do + login_as(default_user) + create_and_visit_feed + + find_by_id("home").click + + expect(page).to have_current_path(news_path) + end + + it "shows the unread count in the page title" do + login_as(default_user) + create_and_visit_feed(story_title: "My Story") + + expect(page).to have_title("(1)") + end + it "only marks stories from the current feed as read" do login_as(default_user) other_feed = create(:feed) diff --git a/spec/system/heroku_spec.rb b/spec/system/heroku_spec.rb new file mode 100644 index 000000000..2a0a2e3d0 --- /dev/null +++ b/spec/system/heroku_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +RSpec.describe "heroku setup" do + it "displays the heroku setup page without authentication" do + visit("/heroku") + + expect(page).to have_content("One more thing") + end + + it "displays the scheduler task instructions" do + visit("/heroku") + + expect(page).to have_content("rake lazy_fetch") + end + + it "links to the home page" do + visit("/heroku") + + expect(page).to have_link("Okay, it's ready!", href: "/") + end +end diff --git a/spec/system/profile_spec.rb b/spec/system/profile_spec.rb index c3fcc85d4..0e3a31ee5 100644 --- a/spec/system/profile_spec.rb +++ b/spec/system/profile_spec.rb @@ -42,6 +42,13 @@ def fill_in_password_fields(existing_password, new_password) expect(default_user.reload).to be_stories_order_asc end + it "reflects the current stories order in the dropdown" do + default_user.update!(stories_order: "asc") + visit(edit_profile_path) + + expect(page).to have_select("Stories feed order", selected: "Oldest first") + end + it "rejects username change with wrong password" do fill_in_username_fields("wrong_password") click_on("Update username") diff --git a/spec/system/starred_spec.rb b/spec/system/starred_spec.rb index abfafa236..daf47caa2 100644 --- a/spec/system/starred_spec.rb +++ b/spec/system/starred_spec.rb @@ -98,4 +98,26 @@ def create_starred_stories(count) expect(page).to have_content("2 of 2") end + + it "navigates to the previous page" do + login_as(default_user) + create_starred_stories(21) + visit(starred_path) + click_on("Next") + + click_on("Previous") + + expect(page).to have_content("1 of 2") + end + + it "navigates to the previous page with arrow keys" do + login_as(default_user) + create_starred_stories(21) + visit(starred_path) + send_keys(:arrow_right) + + send_keys(:arrow_left) + + expect(page).to have_content("1 of 2") + end end diff --git a/spec/system/stories_index_spec.rb b/spec/system/stories_index_spec.rb index 4b84a4895..bb9592e2e 100644 --- a/spec/system/stories_index_spec.rb +++ b/spec/system/stories_index_spec.rb @@ -183,6 +183,15 @@ def open_story_and_find_unread_icon(story_title) expect(titles).to eq(["Older Story", "Newer Story"]) end + it "shows the unread count in the page title" do + create(:story, title: "My Story") + login_as(default_user) + + visit news_path + + expect(page).to have_title("(1)") + end + it "allows viewing a story with hot keys" do create(:story, title: "My Story", body: "My Body") login_as(default_user)