https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35052 --- Comment #22 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 205614 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205614&action=edit Bug 35052: Add end-to-end test for the query-time OpacHiddenItems filter Adds a test exercising the real QueryBuilder->build_query_compat -> Search->search_compat pipeline together, mocking only the ES-network boundary (_items_index_ready, _apply_item_level_filters, _get_item_counts_by_biblio, search) - not _apply_opac_hidden_items_filter or build_query_compat themselves, both of which run for real. Closes the gap explicitly flagged on Bug 43151 (2026-08-04): "no end-to-end test through build_query_compat exercising this pipeline ... the actual join between 'what a real search sends' and 'what gets extracted' is only verified manually." Test plan: 1) ktd --name "${KTD_INSTANCE:-kohadev}" --shell --run 'prove t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t' 2) All tests pass, including the new 'end-to-end: build_query_compat -> search_compat honours OpacHiddenItemsHidesRecord' subtest For final human verification with a live Elasticsearch, before this bug is signed off: 3) Boot KTD with Elasticsearch: ktd --search-engine es8 up (or your usual ${KTD_INSTANCE} invocation if already running with ES) 4) Catalogue a record titled ZZZ35052TEST with two items: item 1: withdrawn = 1; item 2: withdrawn = 0 5) Set system preferences: OpacHiddenItems to withdrawn: - 1 OpacHiddenItemsHidesRecord to "Hide", OpacHiddenItemsExceptions empty 6) Rebuild the indices: misc/search_tools/rebuild_elasticsearch.pl -a -r -v 7) Search ZZZ35052TEST in the OPAC - record appears (item 2 is visible, so the record must not be hidden) 8) Edit item 2's withdrawn to 1 as well (now both items hidden). Wait ~15s for the aggregation cache to expire, or flush it directly: ktd --name "${KTD_INSTANCE}" --shell --run 'perl -e "Koha::Caches->get_instance->flush_all"' 9) Search ZZZ35052TEST again - record is now absent from results, AND the reported total-hits count does not include it either. This is the actual bug being fixed: previously the total included the fully-hidden record and a results page could render with fewer results than requested because the record was skipped only after being counted 10) Set OpacHiddenItemsExceptions to a patron category with a test patron account in it, log in to the OPAC as that patron, repeat step 9 - the record reappears for that patron only -- You are receiving this mail because: You are watching all bug changes.