Skip to content

test(theming): cover background file picker mime filtering - #62221

Open
mvanhorn wants to merge 1 commit into
nextcloud:masterfrom
mvanhorn:fix/62105-custom-background-file-picker
Open

test(theming): cover background file picker mime filtering#62221
mvanhorn wants to merge 1 commit into
nextcloud:masterfrom
mvanhorn:fix/62105-custom-background-file-picker

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jul 16, 2026

Copy link
Copy Markdown

Summary

This is a regression introduced by commit 15c336f (2026-07-01, "adjust file picker for background image to allow folder navigation"), which replaced the working image filter .setFilter((node) => node.mime.startsWith('image/')) with .setMimeTypeFilter(['image/*']) in the pickFile() function. The intent of that change was correct (a bare setFilter predicate hides folders too, so users could not navigate into subfolders), but the ['image/*'] mimetype-filter path yields an empty browse list in practice, while the other image picker in the codebase (apps/settings/src/components/PersonalInfo/AvatarSection.vue) uses explicit types ['image/png', 'image/jpeg'] rather than the glob. Fix pickFile() by restoring a working image filter that also keeps directories visible for navigation: replace .setMimeTypeFilter(['image/*']) with a folder-aware predicate .setFilter((node) => node.type === 'folder' || node.mime?.startsWith('image/')) (this mirrors the FilePicker's own internal rule of always showing folders plus matching files, and restores the pre-regression image display without reintroducing the folder-navigation problem). This is the delta versus the 2026-07-01 change: it keeps folder navigation but stops the browse list from coming back empty. The fix is self-contained in UserSectionBackground.vue; its only consumer, apps/theming/src/views/UserTheming.vue, needs no change. Add a focused unit test that mocks @nextcloud/dialogs (to capture the filter callback passed to the builder) and @nextcloud/initial-state (the component reads several loadState values at module load), then asserts the predicate accepts a folder node and an image/png node and rejects a text/plain node.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests are included
  • Screenshots before/after for front-end changes
  • Documentation has been updated or is not required
  • Backports requested where applicable
  • Labels added where applicable
  • Milestone added for target branch/version

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@mvanhorn
mvanhorn requested a review from a team as a code owner July 16, 2026 04:55
@mvanhorn
mvanhorn requested review from nfebe, skjnldsv and sorbaugh and removed request for a team July 16, 2026 04:55
Comment thread apps/theming/src/components/__tests__/UserSectionBackground.spec.ts
Comment thread apps/theming/src/components/UserSectionBackground.vue Outdated
@mvanhorn

Copy link
Copy Markdown
Author

Done in 3b6c67f — added .setCanPick so only image files are selectable while .setFilter still lets you navigate folders, and moved the spec out of __tests__/ next to the source. Thanks!

@susnux susnux added bug 3. to review Waiting for reviews labels Jul 18, 2026
@susnux susnux added this to the Nextcloud 35 milestone Jul 18, 2026
@susnux

susnux commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Thank you :)

Please rebase onto current master branch. Also you need to signoff both commits (to pass the DCO check).
Moreover as this is AI generated / assisted please add the matching line for disclosure to your assisted commit according to our AI policy:
https://github.com/nextcloud/.github/blob/master/AI_POLICY.md#disclosure

@susnux susnux added AI assisted community pull requests from community labels Jul 18, 2026
The empty-dialog fix landed on master via the setMimeTypeFilter
change; this adds the missing regression coverage: the picker is
built with an image mime filter and folders stay navigable.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn
mvanhorn force-pushed the fix/62105-custom-background-file-picker branch from 3b6c67f to eb34d29 Compare July 20, 2026 15:38
@mvanhorn

Copy link
Copy Markdown
Author

Rebased onto current master with signoff. While rebasing I found the picker fix itself already landed via the setMimeTypeFilter change, so I slimmed this down to what master is still missing: regression coverage for the picker (image mime filter applied, folders navigable). Can retitle if you'd like.

@mvanhorn mvanhorn changed the title fix: custom background file picker shows an empty file dialog test(theming): cover background file picker mime filtering Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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

Labels

3. to review Waiting for reviews AI assisted bug community pull requests from community feedback-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: can not select custom background

2 participants