Fix #13 add basic admin panel for now

This commit is contained in:
Devin Zuczek
2026-07-17 17:43:18 -04:00
parent b77389012e
commit 9065bf5e54
15 changed files with 901 additions and 238 deletions
+26 -6
View File
@@ -7,22 +7,42 @@ it('rejects unauthenticated account reads', async () => {
expect(await res.json()).toEqual({ error: 'not signed in' })
})
it('requires a password to sign up', async () => {
it('refuses manual signups (disabled)', async () => {
const res = await SELF.fetch('https://example.com/api/signup', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({}),
body: JSON.stringify({ password: 'whatever' }),
})
expect(res.status).toBe(400)
expect(await res.json()).toEqual({ error: 'A password is required.' })
expect(res.status).toBe(403)
expect(await res.json()).toEqual({ error: 'Account creation is currently disabled.' })
})
it('requires credentials to log in', async () => {
const res = await SELF.fetch('https://example.com/api/login', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ accountId: '1' }),
body: JSON.stringify({ username: 'alice' }),
})
expect(res.status).toBe(400)
expect(await res.json()).toEqual({ error: 'Account id and password are required.' })
expect(await res.json()).toEqual({ error: 'Username and password are required.' })
})
it('rejects an unauthenticated maintenance broadcast', async () => {
const res = await SELF.fetch('https://example.com/api/maintenance', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ startsInMinutes: 15 }),
})
expect(res.status).toBe(401)
expect(await res.json()).toEqual({ error: 'not signed in' })
})
it('rejects an unauthenticated coach message', async () => {
const res = await SELF.fetch('https://example.com/api/coach-message', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ messageContent: 'hello all' }),
})
expect(res.status).toBe(401)
expect(await res.json()).toEqual({ error: 'not signed in' })
})