Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core/inputs): fix issues with calling onPathFocus for PT-input #5794

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

skogsmaskin
Copy link
Member

@skogsmaskin skogsmaskin commented Feb 19, 2024

Description

I discovered some issues in #5786.

  • Forgot to call onPathFocus on anything else than spans.
  • There was an issue where it was testing for inlineBlocks against the wrong member key, not correctly identifying inline blocks.
  • Added missing tests that should have discovered these issues.
  • Added some more code comments as the code isn't too easy to understand.

I have added some Playwright-CT tests for this functionality now that test the values emitted by onPathFocus for focus on spans, inline blocks, and block objects.

What to review

The bi-directionality and production of paths for various types of content should now be fully covered by the tests.

Testing

Notes for release

N/A - should use notes from #5786

…spans

We forgot to call this normally for anything else than spans.
Also added some code comments.
@skogsmaskin skogsmaskin requested a review from a team February 19, 2024 19:10
@skogsmaskin skogsmaskin requested a review from a team as a code owner February 19, 2024 19:10
@skogsmaskin skogsmaskin requested review from jtpetty and removed request for a team February 19, 2024 19:10
Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Feb 19, 2024 7:29pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 7:29pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Feb 19, 2024 7:29pm

Copy link
Contributor

github-actions bot commented Feb 19, 2024

Component Testing Report Updated Feb 19, 2024 7:32 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 17s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 0s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 19s 9 0 0

Copy link
Contributor

No changes to documentation

Test that spans are reported with .text and everything else not.
Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

LGTM (just a minor question/comment). Thanks for adding tests! ❤️

const pushPath = (path: Path) => paths.push(path)
await mount(<FocusTrackingStory document={document} onPathFocus={pushPath} />)
const {getFocusedPortableTextEditor} = testHelpers({page})
const $pte = await getFocusedPortableTextEditor('field-body')
Copy link
Member

Choose a reason for hiding this comment

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

Not a huge deal, but is there any particular meaning behind the $-prefix here? I guess it's because these refer to DOM elements, but my impression is that it's not a commonly used convention these days, since you can easily tell from the type anyway(?)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's to signal that it's a (synchronous) Locator instance.
The test suite started with this convention, and I think the Playwright documentation used to have this convention in their examples, but I can't find them anymore. I'm all in for not using them, but then we should follow the same convention everywhere within our test suite.

@skogsmaskin skogsmaskin added this pull request to the merge queue Feb 20, 2024
Merged via the queue into next with commit 0f114b1 Feb 20, 2024
40 checks passed
@skogsmaskin skogsmaskin deleted the fix/add-missing-invocation branch February 20, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants