Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions routes/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default withRouteSpec({
<nav>
<ul class="space-y-4">
<li>
<a href="./admin/files/list" class="block px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">File Management</a>
<a href="./files/list" class="block px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">File Management</a>
</li>
<li>
<a href="./admin/events/list" class="block px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">Event Management</a>
<a href="./events/list" class="block px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">Event Management</a>
</li>
</ul>
</nav>
Expand Down
6 changes: 2 additions & 4 deletions tests/fixtures/get-test-server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { afterEach } from "bun:test"
import { tmpdir } from "node:os"
import defaultAxios from "redaxios"
import { startServer } from "./start-server"

Expand All @@ -10,16 +9,15 @@ interface TestFixture {
}

export const getTestServer = async (): Promise<TestFixture> => {
const port = 3001 + Math.floor(Math.random() * 999)
const testInstanceId = Math.random().toString(36).substring(2, 15)
const testDbName = `testdb${testInstanceId}`

const server = await startServer({
port,
port: 0,
testDbName,
})

const url = `http://127.0.0.1:${port}`
const url = `http://127.0.0.1:${server.port}`
const axios = defaultAxios.create({
baseURL: url,
})
Expand Down
20 changes: 20 additions & 0 deletions tests/routes/admin-index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { test, expect } from "bun:test"
import { getTestServer } from "tests/fixtures/get-test-server"

test("admin dashboard links resolve to existing admin routes", async () => {
const { axios } = await getTestServer()

const res = await axios.get("/admin")
const html = res.data as string

expect(html).toContain('href="./files/list"')
expect(html).toContain('href="./events/list"')
expect(html).not.toContain('href="./admin/files/list"')
expect(html).not.toContain('href="./admin/events/list"')

const filesRes = await axios.get("/admin/files/list")
expect(filesRes.status).toBe(200)

const eventsRes = await axios.get("/admin/events/list")
expect(eventsRes.status).toBe(200)
})
Loading