-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
274 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="[scrollbar-gutter:stable]" class="h-full"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png" /> | ||
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png" /> | ||
<link rel="manifest" href="/images/site.webmanifest" /> | ||
<link rel="mask-icon" href="/images/safari-pinned-tab.svg" color="#5bbad5" /> | ||
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" /> | ||
<meta name="msapplication-TileColor" content="#da532c" /> | ||
<meta name="theme-color" content="#0f172a" /> | ||
<meta name="csrf-token" content={get_csrf_token()} /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<.live_title suffix=" · Polar"> | ||
<%= "Page Not Found" %> | ||
</.live_title> | ||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} /> | ||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}> | ||
</script> | ||
<%= if domain = System.get_env("PHX_HOST") do %> | ||
<script defer data-domain={domain} src="https://plausible.io/js/script.js"> | ||
</script> | ||
<% end %> | ||
</head> | ||
<body class="h-full bg-slate-950"> | ||
<div class="mx-auto mt-20 max-w-2xl text-center sm:mt-24"> | ||
<p class="text-base font-semibold leading-8 text-indigo-400"><%= gettext("404") %></p> | ||
<h1 class="mt-4 text-3xl font-bold tracking-tight text-white sm:text-5xl"> | ||
<%= gettext("Whoops! Something went wrong.") %> | ||
</h1> | ||
<p class="mt-4 text-base leading-7 text-gray-600 sm:mt-6 sm:text-lg sm:leading-8"> | ||
<% gettext("Sorry, an error happened, we've logged the error.") %> | ||
</p> | ||
</div> | ||
<div class="mx-auto mt-16 flow-root max-w-lg sm:mt-20"> | ||
<h2 class="sr-only"><%= gettext("Check out other pages") %></h2> | ||
<ul role="list" class="-mt-6 divide-y divide-gray-900/5 border-b border-gray-900/5"> | ||
<li class="relative flex gap-x-6 py-6"> | ||
<div class="flex h-10 w-10 flex-none items-center justify-center rounded-lg shadow-sm ring-1 ring-slate-900/10"> | ||
<.icon name="hero-home-solid" class="h-6 w-6 text-indigo-400" /> | ||
</div> | ||
<div class="flex-auto"> | ||
<h3 class="text-sm font-semibold leading-6 text-slate-100"> | ||
<a href="/"> | ||
<span class="absolute inset-0" aria-hidden="true"></span> <%= gettext( | ||
"Take me home" | ||
) %> | ||
</a> | ||
</h3> | ||
<p class="mt-2 text-sm leading-6 text-slate-200"> | ||
<%= gettext("to the place I belong. West Virginia.") %> | ||
</p> | ||
</div> | ||
<div class="flex-none self-center"> | ||
<.icon name="hero-chevron-right-solid" class="h-5 w-5 text-slate-400" /> | ||
</div> | ||
</li> | ||
<li class="relative flex gap-x-6 py-6"> | ||
<div class="flex h-10 w-10 flex-none items-center justify-center rounded-lg shadow-sm ring-1 ring-gray-900/10"> | ||
<.icon name="hero-squares-plus-solid" class="h-6 w-6 text-indigo-400" /> | ||
</div> | ||
<div class="flex-auto"> | ||
<h3 class="text-sm font-semibold leading-6 text-slate-100"> | ||
<a href={~p"/dashboard"}> | ||
<span class="absolute inset-0" aria-hidden="true"></span> <%= gettext("Dashboard") %> | ||
</a> | ||
</h3> | ||
<p class="mt-2 text-sm leading-6 text-slate-200"> | ||
<%= gettext("Go back to the dashboard.") %> | ||
</p> | ||
</div> | ||
<div class="flex-none self-center"> | ||
<.icon name="hero-chevron-right-solid" class="h-5 w-5 text-slate-400" /> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule PolarWeb.SpaceController do | ||
use PolarWeb, :controller | ||
|
||
action_fallback PolarWeb.FallbackController | ||
|
||
def show(conn, %{"space_token" => _space_token}) do | ||
redirect(conn, to: ~p"/") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule PolarWeb.Dashboard.Space.NewLiveTest do | ||
use PolarWeb.ConnCase, async: true | ||
|
||
import Phoenix.LiveViewTest | ||
import Polar.AccountsFixtures | ||
|
||
alias Polar.Repo | ||
alias Polar.Accounts.Space | ||
|
||
setup %{conn: conn} do | ||
user = user_fixture() | ||
|
||
conn = log_in_user(conn, user) | ||
|
||
%{conn: conn} | ||
end | ||
|
||
describe "New space creation" do | ||
test "create space", %{conn: conn} do | ||
{:ok, lv, _html} = live(conn, ~p"/dashboard/spaces/new") | ||
|
||
lv | ||
|> form("#new-space-form", %{"space" => %{"name" => "some-test-space"}}) | ||
|> render_submit() | ||
|
||
space = Repo.get_by!(Space, name: "some-test-space") | ||
|
||
%{"info" => flash} = assert_redirect(lv, ~p"/dashboard/spaces/#{space.id}") | ||
|
||
assert flash =~ "Space successfully created!" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
defmodule PolarWeb.Dashboard.SpaceLiveTest do | ||
use PolarWeb.ConnCase, async: true | ||
|
||
import Phoenix.LiveViewTest | ||
import Polar.AccountsFixtures | ||
|
||
alias Polar.Accounts | ||
|
||
setup %{conn: conn} do | ||
user = user_fixture() | ||
|
||
{:ok, space} = Accounts.create_space(user, %{name: "test-space-123"}) | ||
|
||
conn = log_in_user(conn, user) | ||
|
||
%{conn: conn, user: user, space: space} | ||
end | ||
|
||
describe "Space page" do | ||
test "render space detail", %{conn: conn, space: space} do | ||
{:ok, _lv, html} = live(conn, ~p"/dashboard/spaces/#{space.id}") | ||
|
||
assert html =~ "No credential" | ||
end | ||
|
||
test "create new credential", %{conn: conn, space: space} do | ||
{:ok, lv, _html} = live(conn, ~p"/dashboard/spaces/#{space.id}") | ||
|
||
lv | ||
|> element("a", "Create new credential") | ||
|> render_click() | ||
|
||
assert_redirect(lv, ~p"/dashboard/spaces/#{space.id}/credentials/new") | ||
end | ||
end | ||
|
||
describe "with existing credential" do | ||
setup %{space: space, user: user} do | ||
{:ok, credential} = | ||
Accounts.create_space_credential(space, user, %{ | ||
expires_in: 1_296_000, | ||
name: "test-cred", | ||
type: "lxd" | ||
}) | ||
|
||
%{credential: credential} | ||
end | ||
|
||
test "can see existing credential", %{conn: conn, space: space, credential: credential} do | ||
{:ok, _lv, html} = live(conn, ~p"/dashboard/spaces/#{space.id}") | ||
|
||
assert html =~ credential.name | ||
end | ||
|
||
test "click on view credential", %{conn: conn, space: space, credential: credential} do | ||
{:ok, lv, _html} = live(conn, ~p"/dashboard/spaces/#{space.id}") | ||
|
||
lv | ||
|> element("#credential_#{credential.id} a", "View credential") | ||
|> render_click() | ||
|
||
assert_redirect(lv, ~p"/dashboard/spaces/#{space.id}/credentials/#{credential.id}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
defmodule PolarWeb.DashboardLiveTest do | ||
use PolarWeb.ConnCase, async: true | ||
|
||
import Phoenix.LiveViewTest | ||
import Polar.AccountsFixtures | ||
|
||
alias Polar.Accounts | ||
|
||
setup do | ||
user = user_fixture() | ||
|
||
%{user: user} | ||
end | ||
|
||
describe "Dashboard page" do | ||
test "render dashboard", %{conn: conn, user: user} do | ||
{:ok, _lv, html} = | ||
conn | ||
|> log_in_user(user) | ||
|> live(~p"/dashboard") | ||
|
||
assert html =~ "Your spaces" | ||
assert html =~ "Create new space" | ||
end | ||
|
||
test "redirects if user is not logged in", %{conn: conn} do | ||
assert {:error, redirect} = live(conn, ~p"/dashboard") | ||
|
||
assert {:redirect, %{to: path, flash: _flash}} = redirect | ||
assert path == ~p"/users/log_in" | ||
end | ||
end | ||
|
||
describe "new space" do | ||
setup %{conn: conn} do | ||
user = user_fixture() | ||
|
||
conn = log_in_user(conn, user) | ||
|
||
%{user: user, conn: conn} | ||
end | ||
|
||
test "creates a new space", %{conn: conn} do | ||
{:ok, lv, _html} = live(conn, ~p"/dashboard") | ||
|
||
lv | ||
|> element("a", "Create new space") | ||
|> render_click() | ||
|
||
assert_redirect(lv, ~p"/dashboard/spaces/new") | ||
end | ||
end | ||
|
||
describe "with existing space" do | ||
setup %{conn: conn} do | ||
user = user_fixture() | ||
|
||
{:ok, space} = Accounts.create_space(user, %{name: "example-test-space"}) | ||
|
||
conn = log_in_user(conn, user) | ||
|
||
%{space: space, conn: conn} | ||
end | ||
|
||
test "can see existing space", %{conn: conn, space: space} do | ||
{:ok, _lv, html} = live(conn, ~p"/dashboard") | ||
|
||
assert html =~ space.name | ||
end | ||
|
||
test "can click into space", %{conn: conn, space: space} do | ||
{:ok, lv, _html} = live(conn, ~p"/dashboard") | ||
|
||
lv | ||
|> element("#space_#{space.id} a", "View space") | ||
|> render_click() | ||
|
||
assert_redirect(lv, ~p"/dashboard/spaces/#{space.id}") | ||
end | ||
end | ||
end |