---
title: "Reject stale results from an earlier query"
description: "Test a controlled out-of-order search response so the final visible results always belong to the latest query entered by the user."
canonical_url: "https://vostride.com/agent-library/search-filtering/latest-query-wins.md"
md_url: "https://vostride.com/agent-library/search-filtering/latest-query-wins.md"
content_kind: "recipe"
topic: "search-filtering"
---

# Reject stale results from an earlier query

Test a controlled out-of-order search response so the final visible results always belong to the latest query entered by the user.

## Risk

Debounced search can let a slower response overwrite a later query. This scenario needs a test-environment response schedule; arbitrary sleeps do not establish that responses actually arrived out of order.

## Fixtures

- A test-only search service fixture delays the query amber until after the query blue has completed.
- Amber notebook and Blue planner have distinct stable catalog keys and no overlapping searchable aliases.
- An external harness records release order of the two prepared responses without exposing customer traffic.

## Steps

1. Open the fixture search page and verify both products are present in the unfiltered inventory.
2. Enter amber, then replace the entire input with blue while the first fixture response is pending.
3. Wait for the blue result and verify Blue planner is visible while Amber notebook is absent.
4. Release the delayed amber response through the prepared harness and verify the input still reads blue.
5. Verify the result stays Blue planner after the older response is confirmed complete, then open its detail and check its key.

## Expected results

- The harness proves that amber completed after blue; without that evidence the race was not exercised.
- The final rendered result key is the blue fixture key despite the older response arriving last.
- The displayed query, result count, and opened detail all agree on the final query.

## False-pass traps

- A passing run without the required response order proves ordinary search only.
- Matching the input text without checking result identity misses stale response rendering.

## Cleanup

- Remove the response delay fixture and delete both temporary catalog entries.

## Use with agent-qa

Adapt this test design to your application's acceptance criteria and configured target using the [recipe execution guide](/agent-library/software-factory/turn-a-recipe-into-an-agent-qa-test.md). External fixture setup and non-UI checks require your own supported hooks or test tooling. Validate the authored test, execute it, and inspect the completed evidence; this recipe is not a recorded test result.

## References

- [agent-qa test](/docs/agent-qa/configuration/test.md)
- [agent-qa first test](/docs/agent-qa/guides/first-test.md)
- [agent-qa web testing](/docs/agent-qa/guides/web-testing.md)

- [Search and filtering QA recipes](/agent-library/search-filtering.md)
- [Software factory QA library](/agent-library.md)
