Skip to content

Commit

Permalink
[STT-56] api: Return search hits only in combined search (superdesk#2033
Browse files Browse the repository at this point in the history
)

* Return search hits only in combined search

* fix tests

* fix all day tests for AU timezone

* fix e2e
  • Loading branch information
MarkLark86 authored Jul 24, 2024
1 parent 839798d commit f022b48
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 116 deletions.
4 changes: 2 additions & 2 deletions e2e/cypress/e2e/events/event_embedded_coverage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('Planning.Events: embedded coverage', () => {
.click();

// Test the new Event appears in the list view
list.expectItemCount(1);
list.expectItemCount(2);
list.expectItemText(0, 'slugline of the event');

// Test coverage icons in the related Planning item
Expand Down Expand Up @@ -361,7 +361,7 @@ describe('Planning.Events: embedded coverage', () => {
editor.postButton
.should('exist')
.should('be.enabled');
list.expectItemCount(1);
list.expectItemCount(2);
list.expectItemText(0, 'slugline of the event');

// Make sure the Text coverage was created as well
Expand Down
14 changes: 13 additions & 1 deletion server/features/combined_export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ Feature: Export combined Planning and Event items with default template
And we get text in "body_html"
"""
<h2>Planning</h2>
<p><b>Planning 1</b></p>
<p>desc</p>
<p></p>
<p>Editorial note: Ed. note 1</p>
<p>Planned coverage: Text, Photo
<p>---</p>
<p><b>Planning 2</b></p>
<p>desc 2</p>
<p></p>
Expand Down Expand Up @@ -173,6 +179,9 @@ Feature: Export combined Planning and Event items with default template
<p><b>Event:</b> test</p>
<p><b>Coverages:</b> Text, Photo</p>
<p>---</p>
<p><b>Planning:</b> Planning 1</p>
<p><b>Coverages:</b> Text, Photo</p>
<p>---</p>
<p><b>Planning:</b> Planning 2</p>
<p><b>Coverages:</b> Text, Photo</p>
<p>---</p>
Expand Down Expand Up @@ -208,6 +217,9 @@ Feature: Export combined Planning and Event items with default template
<p><b>Event:</b> test</p>
<p><b>Coverages:</b> Text, Photo</p>
<p>---</p>
<p><b>Planning:</b> Planning 1</p>
<p><b>Coverages:</b> Text, Photo</p>
<p>---</p>
<p><b>Planning:</b> Planning 2</p>
<p><b>Coverages:</b> Text, Photo</p>
<p>---</p>
Expand Down Expand Up @@ -248,6 +260,6 @@ Feature: Export combined Planning and Event items with default template
"""
{"_items": [{
"slugline": "Foo",
"body_html": "<p>test</p><p>Planning 2</p>"
"body_html": "<p>test</p><p>Planning 1</p><p>Planning 2</p>"
}]}
"""
36 changes: 24 additions & 12 deletions server/features/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,14 @@ Feature: Search Feature
]
"""
When we get "/events_planning_search?start_date=2016-01-02T00:00:00%2B0000"
Then we get list with 2 items
Then we get list with 4 items
"""
{
"_items": [
{"_id": "planning_123", "type": "planning"},
{"_id": "event_123", "type": "event"}
{"_id": "event_123", "type": "event"},
{"_id": "planning_456", "type": "planning"},
{"_id": "planning_789", "type": "planning"}
]
}
"""
Expand All @@ -172,7 +174,7 @@ Feature: Search Feature
{
"_items": [
{"_id": "planning_123", "type": "planning"},
{"_id": "event_123", "type": "event"}
{"_id": "planning_456", "type": "planning"}
]
}
"""
Expand All @@ -181,7 +183,7 @@ Feature: Search Feature
"""
{
"_items": [
{"_id": "event_123", "type": "event"}
{"_id": "planning_789", "type": "planning"}
]
}
"""
Expand Down Expand Up @@ -315,14 +317,18 @@ Feature: Search Feature
]
"""
When we get "/events_planning_search?start_date=2016-01-02T00:00:00%2B0000"
Then we get list with 5 items
Then we get list with 9 items
"""
{
"_items": [
{"_id": "event_123", "type": "event"},
{"_id": "planning_2", "type": "planning"},
{"_id": "planning_1", "type": "planning"},
{"_id": "event_456", "type": "event"},
{"_id": "planning_3", "type": "planning"},
{"_id": "planning_4", "type": "planning"},
{"_id": "event_786", "type": "event"},
{"_id": "planning_5", "type": "planning"},
{"_id": "planning_6", "type": "planning"}
]
}
Expand All @@ -338,35 +344,41 @@ Feature: Search Feature
}
"""
When we get "/events_planning_search?agendas=sports&calendars=sports&start_date=2016-01-02T00:00:00%2B0000"
Then we get list with 3 items
Then we get list with 5 items
"""
{
"_items": [
{"_id": "event_123", "type": "event"},
{"_id": "planning_2", "type": "planning"},
{"_id": "event_786", "type": "event"},
{"_id": "planning_5", "type": "planning"},
{"_id": "planning_1", "type": "planning"}
]
}
"""
When we get "/events_planning_search?agendas=sports&calendars=sports,finance&start_date=2016-01-02T00:00:00%2B0000"
Then we get list with 3 items
Then we get list with 5 items
"""
{
"_items": [
{"_id": "event_123", "type": "event"},
{"_id": "planning_2", "type": "planning"},
{"_id": "event_786", "type": "event"},
{"_id": "planning_5", "type": "planning"},
{"_id": "planning_1", "type": "planning"}
]
}
"""
When we get "/events_planning_search?agendas=sports,finance&calendars=sports,finance&start_date=2016-01-02T00:00:00%2B0000"
Then we get list with 4 items
Then we get list with 6 items
"""
{
"_items": [
{"_id": "event_123", "type": "event"},
{"_id": "event_456", "type": "event"},
{"_id": "planning_2", "type": "planning"},
{"_id": "planning_3", "type": "planning"},
{"_id": "event_786", "type": "event"},
{"_id": "planning_5", "type": "planning"},
{"_id": "planning_1", "type": "planning"}
]
}
Expand All @@ -376,7 +388,7 @@ Feature: Search Feature
"""
{
"_items": [
{"_id": "event_456", "type": "event"},
{"_id": "planning_4", "type": "planning"},
{"_id": "planning_6", "type": "planning"}
]
}
Expand All @@ -386,8 +398,8 @@ Feature: Search Feature
"""
{
"_items": [
{"_id": "event_123", "type": "event"},
{"_id": "event_786", "type": "event"},
{"_id": "planning_2", "type": "planning"},
{"_id": "planning_5", "type": "planning"},
{"_id": "planning_1", "type": "planning"}
]
}
Expand Down
7 changes: 5 additions & 2 deletions server/features/search_combined.feature
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,12 @@ Feature: Search Events and Planning
"""
Then we get OK response
When we get "/events_planning_search?only_future=false"
Then we get list with 3 items
Then we get list with 4 items
"""
{"_items": [
{"_id": "user_2_event_1"},
{"_id": "user_2_event_2"},
{"_id": "user_2_plan_1"},
{"_id": "user_2_plan_2"}
]}
"""
Expand All @@ -190,14 +191,16 @@ Feature: Search Events and Planning
"""
Then we get OK response
When we get "/events_planning_search?only_future=false"
Then we get list with 6 items
Then we get list with 8 items
"""
{"_items": [
{"_id": "user_1_event_1"},
{"_id": "user_1_event_2"},
{"_id": "user_2_event_1"},
{"_id": "user_2_event_2"},
{"_id": "user_1_plan_1"},
{"_id": "user_1_plan_2"},
{"_id": "user_2_plan_1"},
{"_id": "user_2_plan_2"}
]}
"""
25 changes: 17 additions & 8 deletions server/features/search_combined_locks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Feature: Search Events and Planning Locks
When we get "/events_planning_search?only_future=false&lock_state=locked"
Then we get list with 0 items
When we get "/events_planning_search?only_future=false&lock_state=unlocked"
Then we get list with 7 items
Then we get list with 10 items
"""
{"_items": [
{"slugline": "e-unlocked", "type": "event"},
Expand All @@ -106,7 +106,10 @@ Feature: Search Events and Planning Locks
{"slugline": "p-locked", "type": "planning"},
{"slugline": "ep-unlocked", "type": "event"},
{"slugline": "ep-e-locked", "type": "event"},
{"slugline": "ep-p-locked", "type": "event"}
{"slugline": "ep-p-locked", "type": "event"},
{"slugline": "ep-unlocked", "type": "planning"},
{"slugline": "ep-e-locked", "type": "planning"},
{"slugline": "ep-p-locked", "type": "planning"}
]}
"""
When we post to "/events/event_2/lock" with success
Expand All @@ -126,22 +129,25 @@ Feature: Search Events and Planning Locks
{"lock_action": "edit"}
"""
When we get "/events_planning_search?only_future=false&lock_state=locked"
Then we get list with 4 items
Then we get list with 6 items
"""
{"_items": [
{"slugline": "e-locked", "type": "event"},
{"slugline": "p-locked", "type": "planning"},
{"slugline": "ep-e-locked", "type": "event"},
{"slugline": "ep-p-locked", "type": "event"}
{"slugline": "ep-p-locked", "type": "event"},
{"slugline": "ep-e-locked", "type": "planning"},
{"slugline": "ep-p-locked", "type": "planning"}
]}
"""
When we get "/events_planning_search?only_future=false&lock_state=unlocked"
Then we get list with 3 items
Then we get list with 4 items
"""
{"_items": [
{"slugline": "e-unlocked", "type": "event"},
{"slugline": "p-unlocked", "type": "planning"},
{"slugline": "ep-unlocked", "type": "event"}
{"slugline": "ep-unlocked", "type": "event"},
{"slugline": "ep-unlocked", "type": "planning"}
]}
"""
When we post to "/events/event_1/lock" with success
Expand All @@ -157,7 +163,7 @@ Feature: Search Events and Planning Locks
{"lock_action": "edit"}
"""
When we get "/events_planning_search?only_future=false&lock_state=locked"
Then we get list with 7 items
Then we get list with 10 items
"""
{"_items": [
{"slugline": "e-unlocked", "type": "event"},
Expand All @@ -166,7 +172,10 @@ Feature: Search Events and Planning Locks
{"slugline": "p-locked", "type": "planning"},
{"slugline": "ep-unlocked", "type": "event"},
{"slugline": "ep-e-locked", "type": "event"},
{"slugline": "ep-p-locked", "type": "event"}
{"slugline": "ep-p-locked", "type": "event"},
{"slugline": "ep-unlocked", "type": "planning"},
{"slugline": "ep-e-locked", "type": "planning"},
{"slugline": "ep-p-locked", "type": "planning"}
]}
"""
When we get "/events_planning_search?only_future=false&lock_state=unlocked"
Expand Down
12 changes: 6 additions & 6 deletions server/features/search_sort.feature
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,31 @@ Feature: Event Search
When we get "events_planning_search?repo=combined&only_future=false"
Then we get the following order
"""
["event_2", "event_4", "event_1", "plan_1", "event_3", "plan_3"]
["event_2", "plan_2", "event_4", "plan_4", "event_1", "plan_1", "event_3", "plan_3"]
"""
# Sort by creation date, in ascending order (default order)
When we get "events_planning_search?repo=combined&only_future=false&sort_field=created"
Then we get the following order
"""
["event_1", "plan_1", "event_2", "event_3", "plan_3", "event_4"]
["event_1", "plan_1", "event_2", "plan_2", "event_3", "plan_3", "event_4", "plan_4"]
"""
# Sort by creation date, in descending order
When we get "events_planning_search?repo=combined&only_future=false&sort_field=created&sort_order=descending"
Then we get the following order
"""
["event_4", "plan_3", "event_3", "event_2", "plan_1", "event_1"]
["plan_4", "event_4", "plan_3", "event_3", "plan_2", "event_2", "plan_1", "event_1"]
"""
# Sort by updated date, in ascending order (default order)
When we get "events_planning_search?repo=combined&only_future=false&sort_field=updated"
Then we get the following order
"""
["event_4", "event_3", "plan_3", "event_2", "event_1", "plan_1"]
["event_4", "plan_4", "event_3", "plan_3", "event_2", "plan_2", "event_1", "plan_1"]
"""
# Sort by updated date, in descending order
When we get "events_planning_search?repo=combined&only_future=false&sort_field=updated&sort_order=descending"
Then we get the following order
"""
["plan_1", "event_1", "event_2", "plan_3", "event_3", "event_4"]
["plan_1", "event_1", "plan_2", "event_2", "plan_3", "event_3", "plan_4", "event_4"]
"""
# Update an item, then sort by updated date in descending order
When we patch "/events/event_3"
Expand All @@ -181,5 +181,5 @@ Feature: Event Search
When we get "events_planning_search?repo=combined&only_future=false&sort_field=updated&sort_order=descending"
Then we get the following order
"""
["event_3", "plan_1", "event_1", "event_2", "plan_3", "event_4"]
["event_3", "plan_1", "event_1", "plan_2", "event_2", "plan_3", "plan_4", "event_4"]
"""
Loading

0 comments on commit f022b48

Please sign in to comment.