Skip to content

Commit

Permalink
Add snapshot test for index
Browse files Browse the repository at this point in the history
  • Loading branch information
raffomania committed Jan 28, 2025
1 parent 61efaae commit f8ed7c2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
82 changes: 82 additions & 0 deletions src/tests/snapshots/linkblocks__tests__users__can_login-2.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
source: src/tests/users.rs
expression: index.dom.htmls()
---
<head>
<link rel="stylesheet" href="/assets/preflight.css" />
<link rel="stylesheet" href="/assets/railwind.css" />
<script src="/assets/htmx.1.9.9.js"></script>
<meta name="color-scheme" content="dark" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>linkblocks</title>
</head>
<body class="w-full h-full text-gray-200 bg-neutral-800">

<div class="flex-row-reverse h-full sm:flex">
<main class="sm:overflow-y-auto sm:grow">

<header class="mx-4 mt-3 mb-4">
<h1 class="text-xl font-bold">Welcome to linkblocks!</h1>
</header>



<ul class="flex flex-col max-w-sm gap-2 px-4 pb-4">
<li>
<a class="block p-4 border rounded border-neutral-700 hover:bg-neutral-700" href="/bookmarks/create">Add a bookmark</a
>
</li>
<li>
<a class="block p-4 border rounded border-neutral-700 hover:bg-neutral-700" href="/lists/create">Create a list</a
>
</li>
<li class="">
<a class="block px-4 py-2 border rounded border-neutral-700 hover:bg-neutral-700" href="/profile">Install the bookmarklet</a
>
</li>
</ul>


</main>

<aside id="nav" class="bg-neutral-900 sm:max-w-[18rem] sm:w-1/3 sm:max-h-full flex flex-col sm:flex-col-reverse sm:border-r border-neutral-700 border-t sm:border-t-0">
<div class="sm:overflow-y-auto sm:flex-1">
<div class="sticky top-0 flex items-center justify-between px-2 pt-2 sm:top-0 bg-neutral-900">
<h3 class="px-2 py-1 text-sm font-bold tracking-tight text-neutral-400">
Lists
</h3>
<a href="/lists/create" class="block px-3 text-xl rounded hover:bg-neutral-800 text-neutral-400">+</a
>
</div>
<ul class="pb-2">

<li>
<a class="block px-4 py-1 overflow-hidden text-ellipsis whitespace-nowrap hover:bg-neutral-800" href="/bookmarks/unsorted">
Unsorted bookmarks
</a>
</li>


<li>
<a class="block px-4 py-1 overflow-hidden text-ellipsis whitespace-nowrap hover:bg-neutral-800 text-neutral-400" href="/lists/unpinned">
Unpinned lists
</a>
</li>
</ul>
</div>

<header class="sticky bottom-0 flex justify-between p-2 leading-8 bg-neutral-900">
<a href="/" class="px-2 font-bold rounded hover:bg-neutral-800">test</a
>

<form action="/logout" method="post">
<button class="px-3 rounded text-neutral-400 hover:bg-neutral-800">
Logout
</button>
</form>
</header>
</aside>

</div>

</body>
9 changes: 8 additions & 1 deletion src/tests/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ async fn can_login(pool: Pool<Postgres>) -> anyhow::Result<()> {
let cookie = cookie.to_str()?.split_once(';').unwrap().0;

// Check that we can access the index using the auth cookie
app.req().header(header::COOKIE, cookie).get("/").await;
let index = app
.req()
.header(header::COOKIE, cookie)
.get("/")
.await
.test_page()
.await;
insta::assert_snapshot!(index.dom.htmls());

Ok(())
}

0 comments on commit f8ed7c2

Please sign in to comment.