Skip to content

Conversation

@gabriellsh
Copy link
Member

@gabriellsh gabriellsh commented May 19, 2025

Proposed changes (including videos or screenshots)

The filtering by actor was not working, and 2 issues were identified:

  1. The tests for the endpoint were not properly testing the endpoint. Firstly, neither the end test function was being called at the end of the test, nor were the promises being awaited. This means every possible error was being ommited. Also in the filtering tests, the result was only being asserted by verifying if the result was an array, and not ensuring that the results match the passed query.
  2. The actor filter arrives in the endpoint function as an object, and being directly passed to the query. When passing objects in a mongo query, it only matches if there's a full match between the objects. This means that passing actor: { type: 'user' } returns no records, because actor has many more properties, thus not an exact match.

Firstly the tests were improved by awaiting the promises, and adding extra assertions, guaranteeing that they are failing with the current implementation, and that the filters are working properly.

Then the issue was fixed by mapping the actor object properties to a proper mongo query, transforming actor: { type: 'user', _id: 'xxx' } to { 'actor.type': 'user', 'actor._id': 'xxx' }.

This PR should fix the issue, and ensure it doesn't happen again due to fixed/improved tests.

Issue(s)

CORE-1159

Steps to test or reproduce

Further comments

@gabriellsh gabriellsh requested a review from a team as a code owner May 19, 2025 18:31
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented May 19, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented May 19, 2025

🦋 Changeset detected

Latest commit: f0ec90a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented May 19, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-36027/

Built to branch gh-pages at 2025-05-20 00:07 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@gabriellsh gabriellsh added this to the 7.7.0 milestone May 19, 2025
@codecov
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.61%. Comparing base (b1e5fd0) to head (f0ec90a).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #36027      +/-   ##
===========================================
- Coverage    64.73%   64.61%   -0.12%     
===========================================
  Files         3107     3256     +149     
  Lines        93094    96255    +3161     
  Branches     17748    18045     +297     
===========================================
+ Hits         60267    62198    +1931     
- Misses       30040    31125    +1085     
- Partials      2787     2932     +145     
Flag Coverage Δ
e2e 58.40% <ø> (+0.01%) ⬆️
unit 71.46% <ø> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gabriellsh gabriellsh added the stat: QA assured Means it has been tested and approved by a company insider label May 19, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label May 19, 2025
@kodiakhq kodiakhq bot merged commit de565f7 into develop May 20, 2025
49 checks passed
@kodiakhq kodiakhq bot deleted the fix/auditSettingsActorFilter branch May 20, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants