Skip to content

fix(playwright): make SearchExport tests robust for AUT environments with >200k assets#27316

Open
harsh-vador wants to merge 1 commit intomainfrom
fix-search-export-spec
Open

fix(playwright): make SearchExport tests robust for AUT environments with >200k assets#27316
harsh-vador wants to merge 1 commit intomainfrom
fix-search-export-spec

Conversation

@harsh-vador
Copy link
Copy Markdown
Contributor

Describe your changes:

Problem

In AUT environments where the Explore page returns >200,000 total assets, the Export button is disabled by design when "All matching assets" scope is selected. This caused multiple SearchExport.spec.ts tests to fail because:

  1. openExportScopeModal helper asserted toBeEnabled() on the Export button unconditionally
  2. Tests that click Export with the default "All matching assets" scope had no mock controlling the total count returned when the modal opens

Root Cause

The Export modal fetches the total asset count via a fresh searchQuery call when the modal opens (not on page load). In AUT, this returns >200,000, triggering the limit guard and disabling the Export button.

Fix

  • Removed toBeEnabled() from openExportScopeModal helper — the enabled state is environment-dependent and belongs in individual tests, not the shared helper
  • Added mockSearchQueryCount helper — intercepts **/api/v1/search/query?* to return a small count (default: 10), ensuring the modal sees a count below the 200k limit
  • Applied mockSearchQueryCount to 4 tests that click Export with the default "All matching assets" scope:
    • All matching assets export calls API with dataAsset index
    • Export button is disabled while export is in progress
    • Export API error is shown inside the modal
    • Export downloads CSV and closes modal

Tests using "Visible results" scope are unaffected — switching to that radio always enables the Export button regardless of total count.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@harsh-vador harsh-vador self-assigned this Apr 13, 2026
@harsh-vador harsh-vador added the safe to test Add this label to run secure Github workflows on PRs label Apr 13, 2026
@harsh-vador harsh-vador requested a review from a team as a code owner April 13, 2026 10:09
@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 13, 2026

Code Review ✅ Approved

Hardened SearchExport tests to handle AUT environments with over 200k assets, improving robustness across scale scenarios. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@github-actions
Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.91% (59751/93479) 43.65% (31232/71547) 46.75% (9395/20093)

@sonarqubecloud
Copy link
Copy Markdown

@github-actions

This comment was marked as outdated.

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

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants