diff --git a/packages/next/src/views/API/index.client.tsx b/packages/next/src/views/API/index.client.tsx index 6cb7fdcb89..909db51a2e 100644 --- a/packages/next/src/views/API/index.client.tsx +++ b/packages/next/src/views/API/index.client.tsx @@ -187,7 +187,7 @@ export const APIViewClient: React.FC = () => { max={10} min={0} name="depth" - onChange={(value) => setDepth(value.toString())} + onChange={(value) => setDepth(value?.toString())} path="depth" step={1} /> diff --git a/test/admin/e2e.spec.ts b/test/admin/e2e.spec.ts index 9e53df24bc..4411bcc383 100644 --- a/test/admin/e2e.spec.ts +++ b/test/admin/e2e.spec.ts @@ -312,6 +312,15 @@ describe('admin', () => { await expect(page.locator('#field-sidebarField')).toBeDisabled() }) + test('collection — depth field should have value 0 when empty', async () => { + const { id } = await createPost() + await page.goto(`${postsUrl.edit(id)}/api`) + + const depthField = page.locator('#field-depth') + await depthField.fill('') + await expect(depthField).toHaveValue('0') + }) + test('global — should not show API tab when disabled in config', async () => { await page.goto(postsUrl.global(noApiViewGlobalSlug)) await expect(page.locator('.doc-tabs__tabs-container')).not.toContainText('API')