Skip to content

useFilteredTestCases should expose a filtered flag for consistent empty-state messaging #558

Description

@MuhammadTalha57

🤔 What's the problem you've observed?

useFilteredTestCases (added in #545) returns only ReadonlyArray<ExpandedTestCase>, but its sibling useFilteredDocuments returns { results, filtered } where filtered indicates whether any search/tag/status criteria are currently active.

Consumers that use useFilteredTestCases such as the Timeline component being built in #524 cannot distinguish between two different empty states:

"No scenarios were executed" (nothing ran)
"No scenarios match your query and/or filters" (something ran but was filtered out)

This forces consumers to either call useSearch directly (breaking the abstraction that #545 was specifically designed to provide) or show an inaccurate message to the user.

✨ Do you have a proposal for making it better?

Change useFilteredTestCases to return a consistent shape matching useFilteredDocuments:

return { results, filtered }

The hook already imports useSearch, so deriving filtered requires no new dependencies. The filtered flag can be computed the same way useFilteredDocuments computes it from whether hideStatuses, tagExpression, or a text search query is active.

This keeps the abstraction intact, makes both hooks consistent with each other and unblocks Timeline from showing accurate empty-state messaging without leaking search internals into the component.

📚 Any additional context?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions