Skip to content

[TEST] Add Scans page bulk-delete failure coverage #2027

Description

Summary

Currently, the Scans page test suite lacks explicit regression coverage for handling bulk deletion failures. We need to introduce a robust unit test to ensure that when the bulk-delete API request fails, the application behaves gracefully: the UI maintains its state (the selected task rows are not prematurely removed) and the user is notified with proper in-app error feedback.

Target Files

  • Frontend Component: frontend/src/pages/Scans.tsx (specifically around line 241 where the bulk deletion logic is handled)
  • Test Suite: frontend/testing/unit/pages/Scans.test.tsx

Detailed Acceptance Criteria & Implementation Steps

To resolve this issue, a new test block must be added to Scans.test.tsx that executes the following sequence:

1. Mock API Rejection

  • Mock the bulkDeleteTasks function (or the equivalent API handler imported in Scans.tsx) to return a rejected promise:
    Promise.reject(new Error("Network Error or Internal Server Error"))
  1. Simulate User Interaction
    Render the page component within the test environment.
    Select multiple scan task rows to initiate a bulk action.
    Trigger the Delete button/action to fire the mock bulk delete request.

  2. Assert State & UI Preservation
    Rows Persist: Verify that the selected task rows remain visible in the DOM/table. They must not be optimistically deleted or cleared from the list prior to a successful API response.
    Selection State: Verify if the checkmarks or selection states of those rows remain intact during or after the failed operation.

  3. Assert Error Feedback
    Verify that the appropriate error notification, toast message, or alert banner is rendered in the UI, containing user-friendly failure feedback.

Technical Context
The goal is to prevent regression where an optimistic UI update might clear out tasks before verifying the backend deletion succeeded, leaving the user with an out-of-sync interface if the network call fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions