/** * Admin (staff) surface: the created fixtures are visible to the admin APIs. */ import { apiClient } from '../helpers/api' import { createFutureSlot, createStoreWithSku, type CreatedSlot, type StoreWithSku, } from '../helpers/fixtures' import { staffSession } from '../helpers/sessions' describe('admin API surface', () => { let store: StoreWithSku let slot: CreatedSlot beforeAll(async () => { store = await createStoreWithSku() slot = await createFutureSlot([store.skuId]) }) it('admin.product.getProducts includes the created SKU', async () => { const staff = await staffSession() const { products } = await apiClient(staff.token).admin.product.getProducts.query() const product = products.find((p) => p.id === store.productId) expect(product).toBeDefined() expect(product!.skus.some((sku) => sku.id === store.skuId)).toBe(true) }) it('admin.slots.getAll returns slots (capped at 20) and the public list has ours', async () => { const staff = await staffSession() const result = await apiClient(staff.token).admin.slots.getAll.query() const list = Array.isArray(result) ? result : ((result as { slots?: { id: number }[] })?.slots ?? []) expect(list.length).toBeGreaterThan(0) // getAll only returns the first 20 slots, and this suite leaves data behind, // so membership is asserted against the unbounded public list instead. expect(list.length).toBeLessThanOrEqual(20) const publicSlots = await apiClient().user.slots.getSlots.query() expect(publicSlots.slots.some((s) => s.id === slot.slotId)).toBe(true) }) })