mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
## Summary - Regenerates `packages/api-types` for the content endpoints now that the Platform API's `notebook` content type has landed (list/get/upsert `type` enums, plus `UpsertContentBody`'s notebook cell shape with `_id`/`y_series`). Unrelated schema drift from the same regen (Warehouse, SSO, notification exceptions, etc.) is excluded — only the content-endpoint hunks are applied. - Removes every local widening cast added while the API support was pending (`content-query.ts`, `content-infinite-query.ts`, `notebook-query.ts`, `notebook-upsert-mutation.ts`, `sql-folders-query.ts`). - What remains is scoped and renamed to match: draft ids (`generateDraftId`/`isDraftId`), used only for cells created client-side in the editor before their first save, dropped before they'd ever reach the backend as a fake `_id`. ## Test plan - [x] `pnpm typecheck` — clean - [x] `pnpm --filter studio test` — full suite passes (518 files / 5471 tests) - [x] `pnpm --filter studio run lint:ratchet` — no new warnings - [x] `pnpm format` / prettier — clean <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved notebook cell tracking during editing, reordering, insertion, and deletion. * Preserved existing cell identifiers while removing temporary draft identifiers before saving. * Improved chart configuration for selecting and displaying multiple Y-axis series. * Strengthened notebook validation and content persistence behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import { HttpResponse } from 'msw'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getNotebook } from './notebook-query'
|
|
import type { components } from '@/data/api'
|
|
import { addAPIMock } from '@/tests/lib/msw'
|
|
|
|
const NOTEBOOK_ID = 'd3aadd77-7c3c-4de7-aa5c-5aa8ac270b44'
|
|
|
|
const NOTEBOOK_ROW: components['schemas']['GetUserContentByIdResponse'] = {
|
|
id: NOTEBOOK_ID,
|
|
type: 'notebook',
|
|
name: 'Signup funnel',
|
|
description: '',
|
|
favorite: false,
|
|
folder_id: null,
|
|
inserted_at: '2024-01-01T00:00:00.000Z',
|
|
updated_at: '2024-01-01T00:00:00.000Z',
|
|
visibility: 'project',
|
|
owner_id: 1,
|
|
project_id: 1,
|
|
content: {
|
|
schema_version: 1,
|
|
cells: [],
|
|
},
|
|
}
|
|
|
|
describe('getNotebook', () => {
|
|
it('returns notebook data when the fetched content is type: notebook', async () => {
|
|
addAPIMock({
|
|
method: 'get',
|
|
path: '/platform/projects/:ref/content/item/:id',
|
|
response: () =>
|
|
HttpResponse.json<components['schemas']['GetUserContentByIdResponse']>(NOTEBOOK_ROW),
|
|
})
|
|
|
|
const result = await getNotebook({ projectRef: 'default', id: NOTEBOOK_ID })
|
|
|
|
expect(result.type).toBe('notebook')
|
|
expect(result.content).toEqual({ schema_version: 1, cells: [] })
|
|
})
|
|
|
|
it('throws when the fetched content is not a notebook', async () => {
|
|
addAPIMock({
|
|
method: 'get',
|
|
path: '/platform/projects/:ref/content/item/:id',
|
|
response: () =>
|
|
HttpResponse.json<components['schemas']['GetUserContentByIdResponse']>({
|
|
id: NOTEBOOK_ID,
|
|
type: 'report',
|
|
name: 'A report',
|
|
description: '',
|
|
favorite: false,
|
|
folder_id: null,
|
|
inserted_at: '2024-01-01T00:00:00.000Z',
|
|
updated_at: '2024-01-01T00:00:00.000Z',
|
|
visibility: 'project',
|
|
owner_id: 1,
|
|
project_id: 1,
|
|
content: {},
|
|
}),
|
|
})
|
|
|
|
await expect(getNotebook({ projectRef: 'default', id: NOTEBOOK_ID })).rejects.toThrow(
|
|
/is not a notebook/
|
|
)
|
|
})
|
|
})
|