[ai] fix stub endpoint

This commit is contained in:
Devin Zuczek
2026-08-20 18:27:42 -04:00
parent 038e3b3c50
commit e47ce58db3
3 changed files with 41 additions and 30 deletions
+11 -9
View File
@@ -175,29 +175,31 @@ describe('GET /roomieai/user/facts', () => {
})
describe('GET /makerai/user/access', () => {
// Always false — nothing here runs a model. The body is the boolean itself, not an
// envelope, matching econ's `/api/makerai/checkfreetrialeligibility`.
it('refuses access with a bare false', async () => {
const res = await SELF.fetch(`${ORIGIN}/makerai/user/access?roomInstanceSpecificCheck=False`, {
// Granted, and pinned whole: the casing is mixed on purpose (PascalCase `Success`/`Error`
// beside a snake_case `error_id`) and matches neither neighbour on this worker, so a
// "consistency" edit has to fail here rather than on the client.
it('grants access', async () => {
const res = await SELF.fetch(`${ORIGIN}/makerai/user/access?roomInstanceSpecificCheck=True`, {
headers: await bearer(),
})
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('application/json')
expect(await res.text()).toBe('false')
expect(await res.json()).toEqual({ Success: true, Error: null, error_id: null })
})
it('answers the same without the query param', async () => {
// `roomInstanceSpecificCheck` is ignored, so its presence, absence and value change
// nothing.
const granted = { Success: true, Error: null, error_id: null }
const res = await SELF.fetch(`${ORIGIN}/makerai/user/access`, { headers: await bearer() })
expect(await res.text()).toBe('false')
const trueCheck = await SELF.fetch(
`${ORIGIN}/makerai/user/access?roomInstanceSpecificCheck=True`,
expect(await res.json()).toEqual(granted)
const falseCheck = await SELF.fetch(
`${ORIGIN}/makerai/user/access?roomInstanceSpecificCheck=False`,
{
headers: await bearer(),
}
)
expect(await trueCheck.text()).toBe('false')
expect(await falseCheck.json()).toEqual(granted)
})
it('401s without a bearer token', async () => {