diff --git a/app/views/js/templates/_story.js.erb b/app/views/js/templates/_story.js.erb deleted file mode 100644 index 9e6ec6f65..000000000 --- a/app/views/js/templates/_story.js.erb +++ /dev/null @@ -1,54 +0,0 @@ - diff --git a/spec/system/keyboard_shortcuts_spec.rb b/spec/system/keyboard_shortcuts_spec.rb index 9051acfb4..c2f9602a0 100644 --- a/spec/system/keyboard_shortcuts_spec.rb +++ b/spec/system/keyboard_shortcuts_spec.rb @@ -27,6 +27,24 @@ def create_stories_and_visit expect(page).to have_css("li.story.open", count: 1) end + it "wraps the cursor to the first story when pressing j at the end" do + login_as(default_user) + create_stories_and_visit + + send_keys("j", "j", "j") + + expect(find("li.story.open")).to have_text("First Story") + end + + it "wraps the cursor to the last story when pressing k at the top" do + login_as(default_user) + create_stories_and_visit + + send_keys("j", "k") + + expect(find("li.story.open")).to have_text("Second Story") + end + it "moves cursor without opening with n" do login_as(default_user) create_stories_and_visit diff --git a/spec/system/stories_index_spec.rb b/spec/system/stories_index_spec.rb index 5b3b79183..bd4ab30fe 100644 --- a/spec/system/stories_index_spec.rb +++ b/spec/system/stories_index_spec.rb @@ -160,6 +160,30 @@ def open_story_and_find_unread_icon(story_title) expect(page).to have_css(".story.read") end + it "persists read state across page reload", :aggregate_failures do + create(:story, title: "My Story") + login_as(default_user) + visit news_path + + find(".story-preview", text: "My Story").click + expect(page).to have_css(".story.read") + + visit news_path + expect(page).to have_no_text("My Story") + end + + it "marks a story as read when opened in a background tab with ctrl-click", + :aggregate_failures do + create(:story, title: "My Story") + login_as(default_user) + visit news_path + + find(".story-preview", text: "My Story").click(:control) + + expect(page.windows.size).to eq(2) + expect(page).to have_css(".story.read") + end + it "displays stories in newest-first order by default" do create(:story, title: "Older Story", published: 2.days.ago) create(:story, title: "Newer Story", published: 1.day.ago) @@ -207,6 +231,18 @@ def open_story_and_find_unread_icon(story_title) expect(page).to have_title("(1)") end + it "clears the unread count in the title when the last story is read", + :aggregate_failures do + create(:story, title: "My Story") + login_as(default_user) + visit news_path + expect(page).to have_title("(1)") + + find(".story-preview", text: "My Story").click + + expect(page).to have_no_title("(1)") + end + it "allows viewing a story with hot keys" do create(:story, title: "My Story", body: "My Body") login_as(default_user)