Skip to content

fix(translate): fallback for empty translatedTitle in toggle _category_.json + tests#160

Merged
luandro merged 3 commits intomainfrom
fix/translate-toggle-category-fallback
Mar 11, 2026
Merged

fix(translate): fallback for empty translatedTitle in toggle _category_.json + tests#160
luandro merged 3 commits intomainfrom
fix/translate-toggle-category-fallback

Conversation

@luandro
Copy link
Copy Markdown
Contributor

@luandro luandro commented Mar 11, 2026

Summary

Scope: scripts/notion-translate/index.ts, scripts/notion-translate/index.test.ts, scripts/verify-locale-output.test.ts only. No changes to docs content, CI config, or other scripts.

  • Adds an explicit fallback in saveTranslatedContentToDisk so that when translatedTitle is empty or whitespace-only, both label and customProps.title in the toggle _category_.json use the English source title (already computed via getTitle(englishPage)) and finally "Untitled" — instead of writing an empty string.
  • Adds three unit tests covering the fallback (empty string, whitespace-only, and happy-path non-empty translated title) and one regression test asserting elementType: "Page" never produces a _category_.json.
  • Adds a locale-output integration test that recursively globs all _category_.json files under i18n/es/ and i18n/pt/ and asserts every label is a non-empty string. Gracefully skips when the content branch is not checked out (ENOENT pattern already used in the file).

Closes #158, closes #159 (part of umbrella #157)

Test plan

  • bunx vitest run scripts/notion-translate/index.test.ts — all new describe blocks pass
  • bunx vitest run scripts/verify-locale-output.test.ts — new _category_.json label test passes (or skips gracefully if content branch not present)
  • Confirm no untracked files (context/tasks/, reviews/, scripts/audit-language-field.ts) were included in the commit

…egory_.json and add tests

When translatedTitle is empty or whitespace-only, fall back to the English
source title (or "Untitled") so _category_.json label/customProps.title are
never blank. Adds unit tests for the fallback and a locale-output regression
test that asserts all translated _category_.json files have non-empty labels.

Closes #158, closes #159
greptile-apps[bot]

This comment was marked as off-topic.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

🐳 Docker Image Published

Your Docker image has been built and pushed for this PR.

Image Reference: docker.io/communityfirst/comapeo-docs-api:pr-160

Platforms: linux/amd64, linux/arm64

Testing

To test this image:

docker pull docker.io/communityfirst/comapeo-docs-api:pr-160
docker run -p 3001:3001 docker.io/communityfirst/comapeo-docs-api:pr-160

Built with commit 889d3a2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

🚀 Preview Deployment

Your documentation preview is ready!

Preview URL: https://pr-160.comapeo-docs.pages.dev

📦 Content: From content branch (no script changes)

💡 Tip: Add a label to force regeneration if you want to test with fresh Notion data.

This preview will update automatically when you push new commits to this PR.


Built with commit 889d3a2

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 11, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0

Note: The previous review noted a capitalization inconsistency ("Untitled" vs "untitled"). This has been addressed in commit 270c660 which changed the fallback to use lowercase "untitled" to match getTitle() default.

Files Reviewed (3 files)

  • scripts/notion-translate/index.ts - Fix implemented correctly with proper fallback logic
  • scripts/notion-translate/index.test.ts - 4 new tests added, comprehensive coverage
  • scripts/verify-locale-output.test.ts - Integration test added for regression prevention

Review Details

The fix is well-implemented. The fallback chain translatedTitle?.trim() || title || "untitled" correctly handles:

  • Empty string translatedTitle → falls back to English title
  • Whitespace-only translatedTitle → falls back to English title
  • Both empty → falls back to "untitled" (lowercase, matching getTitle())

Tests cover all edge cases including a regression test to ensure Page-type content doesn't produce _category_.json files. The integration test provides good ongoing regression prevention.

luandro added 2 commits March 10, 2026 23:04
… in .env.example

Add the missing environment variable entries that three tests in
docker-config.test.ts and docker-smoke-tests.test.ts were asserting:
- OPENAI_API_KEY and OPENAI_MODEL (required for notion-translate scripts)
- API_HOST and API_PORT (used by api-server/server.ts at startup)
- API_KEY_* pattern documentation (used by ApiKeyAuth to load keys from env)
@luandro
Copy link
Copy Markdown
Contributor Author

luandro commented Mar 11, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@luandro luandro merged commit 5ff26bf into main Mar 11, 2026
5 checks passed
@luandro luandro deleted the fix/translate-toggle-category-fallback branch March 11, 2026 10:57
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Deployment Cleanup

The preview deployment for this PR has been cleaned up.

Preview URL was: https://pr-160.comapeo-docs.pages.dev


Note: Cloudflare Pages deployments follow automatic retention policies. Old previews are cleaned up automatically.

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

Labels

None yet

Projects

None yet

1 participant