Skip to content

test: Assert useMediaUpload hook #141

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

Merged
merged 2 commits into from
May 27, 2025
Merged

Conversation

dcalhoun
Copy link
Member

What?

Assert useMediaUpload hook functionality.

Why?

Improve stability.

How?

Add automated test file.

Testing Instructions

N/A, no user-facing changes.

Accessibility Testing Instructions

N/A, no user-facing changes.

Screenshots or screencast

N/A, no user-facing changes.

@dcalhoun dcalhoun added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label May 27, 2025
@dcalhoun dcalhoun marked this pull request as ready for review May 27, 2025 15:16
@dcalhoun dcalhoun requested a review from Copilot May 27, 2025 15:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces automated tests for the useMediaUpload hook to ensure its functionality regarding filter registration, unmount behavior, and interaction with the media library.

  • Added a test file for the hook with multiple assertions covering filter registration and cleanup.
  • Added a mock file for WordPress hooks to support testing.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/components/editor/test/use-media-upload.test.jsx New test file asserting hook behavior including filter addition, removal, and media library interaction.
mocks/@wordpress/hooks.js Provides mock implementations of addFilter and removeFilter for testing purposes.
Comments suppressed due to low confidence (1)

src/components/editor/test/use-media-upload.test.jsx:64

  • [nitpick] Consider renaming 'FilterCallback' to a more descriptive name (e.g., 'MediaUploadComponent') to clarify its role in rendering the filter component.
let FilterCallback;

@dcalhoun dcalhoun force-pushed the test/assert-use-media-upload branch from b9c7a7b to 1a8b6c6 Compare May 27, 2025 15:37
@dcalhoun dcalhoun requested a review from adalpari May 27, 2025 15:48
Copy link

@adalpari adalpari left a comment

Choose a reason for hiding this comment

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

LGTM!

@dcalhoun dcalhoun merged commit 781bf6b into trunk May 27, 2025
11 checks passed
@dcalhoun dcalhoun deleted the test/assert-use-media-upload branch May 27, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants