Skip to content

Commit

Permalink
feat: #493 liveview for outline & inbox
Browse files Browse the repository at this point in the history
  • Loading branch information
sorax committed Nov 16, 2023
1 parent 12080f1 commit efa36d6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/radiator_web/live/outline_live/index.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule RadiatorWeb.OutlineLive.Index do
use RadiatorWeb, :live_view

@impl true
def mount(_params, _session, socket) do
{:ok, socket}
end
end
4 changes: 4 additions & 0 deletions lib/radiator_web/live/outline_live/index.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<section>
<h1>Outline</h1>
<h2>Inbox</h2>
</section>
2 changes: 2 additions & 0 deletions lib/radiator_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ defmodule RadiatorWeb.Router do
on_mount: [{RadiatorWeb.UserAuth, :ensure_authenticated}] do
live "/users/settings", UserSettingsLive, :edit
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email

live "/outline", OutlineLive.Index, :index
end
end

Expand Down
37 changes: 37 additions & 0 deletions test/radiator_web/live/outline_live_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
defmodule RadiatorWeb.OutlineLiveTest do
use RadiatorWeb.ConnCase

import Phoenix.LiveViewTest
import Radiator.AccountsFixtures

describe "Outline show page" do
test "can render page if user is logged in", %{conn: conn} do
{:ok, _live, html} = conn |> log_in_user(user_fixture()) |> live(~p"/outline")

assert html =~ "Outline</h1>"
end

test "redirects if user is not logged in", %{conn: conn} do
assert {:error, redirect} = live(conn, ~p"/outline")

assert {:redirect, %{to: path, flash: flash}} = redirect
assert path == ~p"/users/log_in"
assert %{"error" => "You must log in to access this page."} = flash
end
end

describe "Outline has an inbox" do
setup %{conn: conn} do
user = user_fixture()
%{conn: log_in_user(conn, user)}
end

test "inbox has a haeadline", %{conn: conn} do
{:ok, live, _html} = live(conn, ~p"/outline")

assert live
|> element("h2", "Inbox")
|> render() =~ "Inbox"
end
end
end

0 comments on commit efa36d6

Please sign in to comment.