Skip to content

fix(style-editor): Now the style editor form is showed in UVE#35497

Open
KevinDavilaDotCMS wants to merge 2 commits intomainfrom
35270-unify-style-editor-schema-definition-use-content-type-tab-as-single-source-of-truth-for-headless-and-traditional-pages-qa-failed-i
Open

fix(style-editor): Now the style editor form is showed in UVE#35497
KevinDavilaDotCMS wants to merge 2 commits intomainfrom
35270-unify-style-editor-schema-definition-use-content-type-tab-as-single-source-of-truth-for-headless-and-traditional-pages-qa-failed-i

Conversation

@KevinDavilaDotCMS
Copy link
Copy Markdown
Member

@KevinDavilaDotCMS KevinDavilaDotCMS commented Apr 28, 2026

2026-04-28.17-35-27.mov
  • Updated tests in and to use instead of for logging warnings.
  • Adjusted the implementation in and to directly call for logging messages related to missing page queries and schema fetch failures.
  • Removed unnecessary imports of from the test files to streamline the codebase.

This change enhances consistency in logging practices across the codebase.

This PR fixes: #35270

…PI and utils tests

- Updated tests in  and  to use  instead of  for logging warnings.
- Adjusted the implementation in  and  to directly call  for logging messages related to missing page queries and schema fetch failures.
- Removed unnecessary imports of  from the test files to streamline the codebase.

This change enhances consistency in logging practices across the codebase.
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 28, 2026

Claude finished @KevinDavilaDotCMS's task in 2m 48s —— View job


Code Review

  • Gather context and read changed files
  • Review utils.ts changes
  • Review spec file changes
  • Review Next.js example change
  • Post findings

Issues Found

🔴 Critical — SSR guard removed (utils.ts)

The typeof window === 'undefined' early-return was deliberately there to prevent fetchStyleEditorSchemas from running during server-side rendering:

// BEFORE (origin/main) — intentional SSR guard
if (typeof window === 'undefined') {
    return [];
}

This was removed in commit a9258919. The current code unconditionally fires an HTTP request to /api/v1/page/{pageId}/contenttype-schema on every call — including SSR.

Why this matters:

  • Style editor schemas are only consumed by the UVE visual editor, which runs in the browser. Fetching them during SSR is useless work.
  • For any SDK user with a Next.js server component calling client.page.get(), every page view now makes an extra round-trip to the DotCMS schema endpoint, even in production where no editor is open.
  • This is a silent performance regression with no benefit for non-editing contexts.

The fix should not be to remove the guard — it should be to fetch schemas conditionally (e.g., only when in UVE/editing mode). That's what fmontes is reacting to with "Hell no..." on line 325.

Fix this →


🟡 Medium — consolaWarnSpy leaks between tests (page-api.spec.ts:921)

// line 921 — no mockImplementation, no mockRestore
const consolaWarnSpy = jest.spyOn(console, 'warn');

Compare to the correctly-handled spy added in the same PR (page-api.spec.ts:876):

const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => undefined);
// ... test ...
debugSpy.mockRestore();

consolaWarnSpy at line 921 has neither mockImplementation(() => undefined) (so console.warn still fires in test output) nor .mockRestore() (so the spy leaks into subsequent tests). The variable name is also stale — it was renamed from consola but kept the consola prefix.


🟡 Medium — Partial consola removal is inconsistent

utils.ts now uses console.* directly, but page-api.ts still uses consola for all its logging. The SDK's own CLAUDE.md lists consola as a runtime dependency and it's the established logging convention in this library. If the goal is to move away from consola, it needs to be done across the entire SDK, not just in one file.


✅ Clean — Next.js example (page.js)

The duplicate import { Page } from "@/views/Page" (double-quoted) that existed before is now removed. The file is clean.

✅ Clean — Error differentiation logic restored

Commit 577511c2 correctly restored the 401/403 → console.warn vs other → console.debug branching that was lost in a9258919. The utils.spec.ts tests covering those paths are thorough and correct.


Summary: The core problem is that the window guard — which prevented style editor schemas from being fetched during SSR — was removed without replacing it with a more targeted condition. The PR description says this fixes the style editor not showing in UVE, but the fix affects all rendering contexts, not just UVE. The right approach is to only skip the schema fetch in SSR or to add a flag that opts in to fetching schemas (e.g., when the SDK is in editing mode).

Comment on lines -321 to -325
if (error instanceof DotHttpError && (error.status === 401 || error.status === 403)) {
consola.warn(
`[DotCMS PageClient]: Style editor schemas request failed with ${error.status} — ` +
'make sure your DotCMS client is configured with a valid authToken that has READ access to the page.'
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hell no...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Frontend PR changes Angular/TypeScript frontend code Area : SDK PR changes SDK libraries

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Unify Style Editor schema definition: use content type tab as single source of truth for headless and traditional pages

2 participants