Files
thamanyah/tests/features/catalogue_search.feature
FahdShalhoub c3465bedb1
Build, Push and Deploy Discovery / build-push-deploy (push) Successful in 1m57s
FEAT: Video Search In Discovery
2026-08-29 17:56:11 +03:00

79 lines
4.0 KiB
Gherkin

Feature: Searching the catalogue
Discovery holds a copy of every video cms has announced as ready. Reaching
one by id is no use to a reader who does not have an id finding something
to watch means searching for it by what it is called and what it is filed
under.
The search is lexical: it matches the words of a title, not its meaning. The
last word a reader types is treated as a prefix, because someone typing into
a search box is usually part-way through a word.
Background:
Given the CMS API is available
And the Discovery API is available
Scenario: Finding a catalogued video by a word in its title
Given the catalogue holds a video titled "Desert Falcons"
When I search the catalogue for that video's title
Then the search returns that video
# The last word is matched as a prefix, so the results keep up with someone
# still typing. Earlier words are matched whole — they have been finished.
Scenario: Finding a video from a part-typed word
Given the catalogue holds a video titled "Desert Falcons"
When I search the catalogue for "Desert Fal"
Then the search returns that video
# Categories narrow a search rather than widening it: a video filed elsewhere
# is not an answer to a reader who asked for one category in particular.
Scenario: A search narrowed to another category leaves the video out
Given the catalogue holds a video titled "Desert Falcons" filed under "documentary"
When I search the catalogue for that video's title in category "news"
Then the search does not return that video
Scenario: A search narrowed to the video's own category still finds it
Given the catalogue holds a video titled "Desert Falcons" filed under "documentary"
When I search the catalogue for that video's title in category "documentary"
Then the search returns that video
# Several categories mean "any of these", not "all of these": naming more of
# them offers the reader more, rather than demanding the video be filed under
# every one at once.
Scenario: Naming several categories matches a video filed under any of them
Given the catalogue holds a video titled "Desert Falcons" filed under "documentary"
When I search the catalogue for that video's title in categories "news, documentary"
Then the search returns that video
# Paging is by cursor rather than by offset: the catalogue is added to while
# people are reading it, and an offset silently repeats or skips a video when
# something is announced between one page and the next. A cursor names where
# the last page stopped, so the page after it is the same page whenever it is
# asked for.
Scenario: Paging through the results a page at a time
Given the catalogue holds 3 videos titled "Mountain Wolves"
When I search the catalogue for that title 2 at a time
Then the search returns 2 videos
And the search offers a cursor to the next page
When I follow the cursor
Then the search returns 1 video
And the search offers no further cursor
And the pages together hold every one of those videos exactly once
# A cursor is opaque, so a client that makes one up has made a mistake rather
# than found a fault. Saying 400 is what tells the two apart.
Scenario: Refusing a cursor no search issued
Given the catalogue holds a video titled "Desert Falcons"
When I search the catalogue for that video's title from the cursor "not-a-cursor"
Then the request is rejected with status 400
And the problem title is "Malformed Search Cursor"
# A page size is a request for work, and an uncapped one is a request for all
# of it — the catalogue is read constantly, and one client asking for every
# row at once should not be able to make everyone else wait. The cap applies
# silently rather than as a rejection: the reader still gets a page, and the
# cursor still reaches the rest.
Scenario: Capping a page size that asks for the whole catalogue
When I search the whole catalogue 5000 at a time
Then the search returns at most 100 videos
And the search offers a cursor to the next page