-
Notifications
You must be signed in to change notification settings - Fork 306
fix: return OR results for multiple tags in Drive filter (WPB-27126) #21898
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1914,9 +1914,9 @@ describe('CellsAPI', () => { | |
| ); | ||
| }); | ||
|
|
||
| it('filters by tags when provided', async () => { | ||
| it('creates a Should metadata filter for a single tag', async () => { | ||
| const searchPhrase = 'test'; | ||
| const tags = ['tag1', 'tag2']; | ||
| const tags = ['tag1']; | ||
| const mockResponse: RestNodeCollection = { | ||
| Nodes: [ | ||
| { | ||
|
|
@@ -1938,7 +1938,7 @@ describe('CellsAPI', () => { | |
| Status: { | ||
| Deleted: 'Not', | ||
| }, | ||
| Metadata: [{Namespace: 'usermeta-tags', Term: JSON.stringify(tags.join(','))}], | ||
| Metadata: [{Namespace: 'usermeta-tags', Term: 'tag1', Operation: 'Should'}], | ||
| }, | ||
| Flags: ['WithPreSignedURLs'], | ||
| Limit: '10', | ||
|
|
@@ -1947,6 +1947,34 @@ describe('CellsAPI', () => { | |
| expect(result).toEqual(mockResponse); | ||
| }); | ||
|
|
||
| it('creates one Should metadata filter per selected tag', async () => { | ||
| const searchPhrase = 'test'; | ||
| const tags = ['tag1', 'tag2']; | ||
| const mockResponse: RestNodeCollection = {Nodes: []} as RestNodeCollection; | ||
|
|
||
| mockNodeServiceApi.lookup.mockResolvedValueOnce(createMockResponse(mockResponse)); | ||
|
|
||
| await cellsAPI.searchNodes({phrase: searchPhrase, tags}); | ||
|
|
||
| expect(mockNodeServiceApi.lookup).toHaveBeenCalledWith({ | ||
| Scope: {Root: {Path: ''}, Recursive: true}, | ||
| Filters: { | ||
| Text: {SearchIn: 'BaseName', Term: searchPhrase}, | ||
| Type: 'UNKNOWN', | ||
| Status: { | ||
| Deleted: 'Not', | ||
| }, | ||
| Metadata: [ | ||
| {Namespace: 'usermeta-tags', Term: 'tag1', Operation: 'Should'}, | ||
| {Namespace: 'usermeta-tags', Term: 'tag2', Operation: 'Should'}, | ||
| ], | ||
| }, | ||
| Flags: ['WithPreSignedURLs'], | ||
| Limit: '10', | ||
| Offset: '0', | ||
| }); | ||
| }); | ||
|
|
||
| it('handles empty tags array', async () => { | ||
| const searchPhrase = 'test'; | ||
| const tags: string[] = []; | ||
|
|
@@ -2249,7 +2277,7 @@ describe('CellsAPI', () => { | |
| Type: 'UNKNOWN', | ||
| Status: {Deleted: 'Not', HasPublicLink: true}, | ||
| Metadata: [ | ||
| {Namespace: 'usermeta-tags', Term: JSON.stringify(tags.join(','))}, | ||
| {Namespace: 'usermeta-tags', Term: 'important', Operation: 'Should'}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test only verifies the serialized request shape. It does not verify that the selected tag still restricts the backend result when it is combined with MIME and creator filters. Because the tag uses
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a follow up task to add this test case into cells-integration-tests https://wearezeta.atlassian.net/browse/WPB-27344 |
||
| {Namespace: 'mime', Term: 'image/*', Operation: 'Must'}, | ||
| {Namespace: 'usermeta-owner-uuid', Term: JSON.stringify(creatorId), Operation: 'Must'}, | ||
| ], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request description says single-tag search is unaffected. But the actual request changes from:
to
That changes both the term representation and the explicit operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, "unaffected" was too loose. What I meant is that a single-tag search still returns only the tagged files with the given tag (See the demo)