refactor: add 'translatableString' fieldType#1190
Conversation
|
Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR removes the custom TranslatableStringField implementation and registers a built-in Sequence Diagram(s)sequenceDiagram
participant Editor as Editor UI
participant Fields as Fields Registry (toPuckFields)
participant Override as TranslatableStringFieldOverride
participant Doc as PageSet/Document
participant Input as EmbeddedStringInput
Editor->>Fields: load component schema (includes translatableString)
Fields->>Override: resolve field override for translatableString
Override->>Doc: read available locales and current locale
Override->>Input: render embedded input for current locale
Input->>Override: user edits value
Override->>Fields: onChange -> emit updated translatable object (current locale or all locales)
Fields->>Editor: update component data
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/visual-editor/src/fields/TranslatableStringField.test.tsx (1)
93-97: Consider using a more explicit assertion for DOM element presence.
querySelectorreturnsnullwhen the element isn't found, andtoBeDefined()passes fornull. While the test likely works because the element exists, usingtoBeTruthy()ortoBeInTheDocument()(from@testing-library/jest-dom) would be more explicit.💡 Suggested improvement
- expect(container.querySelector(".ve-pt-3")).toBeDefined(); + expect(container.querySelector(".ve-pt-3")).toBeTruthy();Or if
@testing-library/jest-domis available:- expect(container.querySelector(".ve-pt-3")).toBeDefined(); + expect(container.querySelector(".ve-pt-3")).toBeInTheDocument();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/visual-editor/src/fields/TranslatableStringField.test.tsx` around lines 93 - 97, The assertion using container.querySelector(".ve-pt-3") with toBeDefined is too permissive; update the test in TranslatableStringField.test.tsx to assert element presence explicitly by replacing toBeDefined with either toBeTruthy() or, if `@testing-library/jest-dom` is available, toBeInTheDocument() for clearer semantics, and ensure the appropriate jest-dom matchers are imported/registered if you choose to use toBeInTheDocument(); keep the rest of the expectation (screen.getByTestId("entity-input").dataset.filter) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/visual-editor/src/editor/README.md`:
- Line 248: The link fragment "(##YextEntityFieldSelector)" is invalid; replace
it with the proper heading fragment form that matches the generated anchor for
the "YextEntityFieldSelector" heading (e.g., "#yextentityfieldselector" or the
exact kebab-case fragment generated by the doc tool) inside the README text so
the cross-reference resolves; locate the occurrence in the `YextField`
description and update the fragment to the correct heading fragment for the
`YextEntityFieldSelector` section.
In `@packages/visual-editor/src/editor/YextField.tsx`:
- Around line 118-121: The change removed "translatableString" from the
YextFieldConfig type union which breaks callers using YextField(..., { type:
"translatableString" }); restore compatibility by including "translatableString"
back into the YextFieldConfig (the union derived from YextPuckFields in
YextField.tsx) so that YextField, YextFieldConfig, and any code referencing
YextPuckFields still accept that type; update the type declaration that
currently excludes "translatableString" to keep it allowed (while you may still
map it to the default handling path inside YextField).
---
Nitpick comments:
In `@packages/visual-editor/src/fields/TranslatableStringField.test.tsx`:
- Around line 93-97: The assertion using container.querySelector(".ve-pt-3")
with toBeDefined is too permissive; update the test in
TranslatableStringField.test.tsx to assert element presence explicitly by
replacing toBeDefined with either toBeTruthy() or, if `@testing-library/jest-dom`
is available, toBeInTheDocument() for clearer semantics, and ensure the
appropriate jest-dom matchers are imported/registered if you choose to use
toBeInTheDocument(); keep the rest of the expectation
(screen.getByTestId("entity-input").dataset.filter) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: abd75ad7-2314-4303-9106-4f87f784c80c
📒 Files selected for processing (25)
packages/visual-editor/src/components/Locator.tsxpackages/visual-editor/src/components/LocatorResultCard.tsxpackages/visual-editor/src/components/contentBlocks/CtaWrapper.tsxpackages/visual-editor/src/components/contentBlocks/Phone.tsxpackages/visual-editor/src/components/contentBlocks/image/Image.tsxpackages/visual-editor/src/components/footer/CopyrightMessageSlot.tsxpackages/visual-editor/src/components/footer/FooterExpandedLinkSectionSlot.tsxpackages/visual-editor/src/components/footer/FooterExpandedLinksWrapper.tsxpackages/visual-editor/src/components/footer/FooterLinksSlot.tsxpackages/visual-editor/src/components/header/HeaderLinks.tsxpackages/visual-editor/src/components/pageSections/Breadcrumbs.tsxpackages/visual-editor/src/components/pageSections/ProductSection/ProductCard.tsxpackages/visual-editor/src/editor/ParentData.tsxpackages/visual-editor/src/editor/README.mdpackages/visual-editor/src/editor/TranslatableStringField.tsxpackages/visual-editor/src/editor/YextField.test.tsxpackages/visual-editor/src/editor/YextField.tsxpackages/visual-editor/src/editor/index.tspackages/visual-editor/src/fields/TranslatableStringField.test.tsxpackages/visual-editor/src/fields/TranslatableStringField.tsxpackages/visual-editor/src/fields/fields.tspackages/visual-editor/src/fields/index.tspackages/visual-editor/src/internal/puck/constant-value-fields/EnhancedCallToAction.tsxpackages/visual-editor/src/internal/puck/constant-value-fields/Image.tsxpackages/visual-editor/src/internal/puck/constant-value-fields/Text.tsx
💤 Files with no reviewable changes (2)
- packages/visual-editor/src/editor/index.ts
- packages/visual-editor/src/editor/TranslatableStringField.tsx
auto-screenshot-update: true
asanehisa
left a comment
There was a problem hiding this comment.
ditto ben's comments. also wonder if wanna move our files from internal/puck/constant-value-fields/ elsewhere?
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
No description provided.