Skip to content

fixed: Replaced Scans alert() failures with toast feedback#626

Open
pranavv2707 wants to merge 5 commits into
utksh1:mainfrom
pranavv2707:main
Open

fixed: Replaced Scans alert() failures with toast feedback#626
pranavv2707 wants to merge 5 commits into
utksh1:mainfrom
pranavv2707:main

Conversation

@pranavv2707

@pranavv2707 pranavv2707 commented Jun 6, 2026

Copy link
Copy Markdown

Description

Replaced alert() dialogs in the Scans page destructive-action failure paths with accessible toast notifications using the existing ToastContext. Also adds test coverage for all three failure paths:

  • Delete single task — clicking "Delete_Record" on one scan and confirming
  • Bulk delete — selecting multiple scans and clicking "Prune_Selected_Records"
  • Clear all — clicking "Purge_All_Records" which wipes everything

Related Issues

Closes issue number #469

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

Unit tests — 5 new tests in Scans.failures.test.tsx:

  • deleteTask failure shows error toast and keeps task in list
  • bulkDeleteTasks failure shows error toast and keeps tasks in list
  • clearAllTasks failure shows error toast

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

Issues Fixed

  1. The Scans page was using browser alert() dialogs for delete and clear-history failure paths, which block the page, cannot be styled, and are inaccessible to screen readers.
    • Replaced all alert() calls in handleTaskDelete, handleClearAll, and handleBulkDelete failure paths with addToast() from the existing ToastContext.
    • Error toasts use role="alert" so screen readers announce them automatically.
    • Console logging kept for diagnostics.

Tests Added

  • frontend/testing/unit/pages/Scans.failures.test.tsx — 5 new tests covering:
    • deleteTask failure shows error toast and keeps task in list
    • bulkDeleteTasks failure shows error toast and keeps tasks in list
    • clearAllTasks failure shows error toast

How to Test

  1. Run cd frontend && npm run test — all 5 new tests should pass.
  2. Run npm run build — build should complete with no errors.
  3. Optionally, run the frontend locally, open the Scans page, and trigger a delete while the backend is stopped — an error toast should appear instead of a browser alert popup.

Comments:

The npm audit failure is a pre-existing vulnerability on upstream main, not introduced by this PR.
This change only modifies frontend/src/pages/Scans.tsx and frontend/testing/unit/pages/Scans.failures.test.tsx.
I have sought assistance from LLMs and gituhub copilot to understand the codebase and guide implementation, as disclosed per the contributing guidelines.

I apologise for the large number of commits.

Screenshots for checks

Screenshot 2026-06-06 at 11 06 34

Description: The screenshot shows the passing of all 5 tests.

Screenshot 2026-06-06 at 11 07 46

Description: The screenshot shows the successful building after the running of the tests, generating no warnings.

@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label area:frontend Frontend React/UI work labels Jun 7, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toast replacement is a useful direction, but this head is behind and required checks are failing. Please rebase on latest main/current CI baseline and fix frontend-checks/backend-lint before requesting review again.

@pranavv2707 pranavv2707 force-pushed the main branch 2 times, most recently from a6a39cc to fb56811 Compare June 7, 2026 17:12

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the latest push. This still has broad Scans/Workflows/phase test churn, no-final-newline changes, and production formatting churn around the toast change. Please narrow the PR to replacing alert failures with toast feedback, remove unrelated test rewrites, and rerun frontend checks.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecking after the latest commit: this is still blocked.

The frontend-checks job is failing on the current head. Please fix CI and keep the patch focused on replacing Scans alert failures with toast handling; unrelated Scans/Workflows churn should stay out of this PR.

@pranavv2707

Copy link
Copy Markdown
Author

Rechecking after the latest commit: this is still blocked.

The frontend-checks job is failing on the current head. Please fix CI and keep the patch focused on replacing Scans alert failures with toast handling; unrelated Scans/Workflows churn should stay out of this PR.

Hi @utksh1
The initial frontend-checks failure is because of the npm audit issue and it is present in upstream too.

The ToastContext mock additions to Scans.test.tsx, ScansPhases.test.tsx, and Scans.polling.test.tsx are necessary because adding useToast() to Scans.tsx causes those tests to fail and those are minimal 5-line additions with no other changes to those files.

Please do let know if i may remove all of them and commit just the scans alert page or any other alternative approach.

@utksh1 utksh1 closed this Jun 24, 2026
@utksh1 utksh1 added the gssoc:invalid Admin validation: invalid for GSSoC scoring label Jun 24, 2026
@utksh1 utksh1 reopened this Jun 25, 2026
@utksh1 utksh1 removed the gssoc:invalid Admin validation: invalid for GSSoC scoring label Jun 25, 2026
@utksh1 utksh1 closed this Jun 25, 2026
@utksh1 utksh1 reopened this Jun 25, 2026
@utksh1 utksh1 added gssoc:invalid Admin validation: invalid for GSSoC scoring and removed gssoc:invalid Admin validation: invalid for GSSoC scoring labels Jun 29, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing blocking browser alerts with accessible toasts is a great UX/accessibility win. The failure test coverage looks comprehensive as well. Merging!

@utksh1 utksh1 added gssoc:approved Admin validation: approved for GSSoC scoring quality:clean Contributor score x1.2; mentor +5 pts labels Jul 3, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just about to merge this, but another PR that was merged today caused a merge conflict! Could you please pull from main and rebase so I can merge this in?

@utksh1 utksh1 removed the gssoc:approved Admin validation: approved for GSSoC scoring label Jul 3, 2026
@pranavv2707

Copy link
Copy Markdown
Author

Hello @utksh1 ,
I have resolved the merge conflicts after pulling from main and the tests run successfully
Thankss

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

Labels

area:frontend Frontend React/UI work level:beginner 20 pts difficulty label for small beginner-friendly PRs quality:clean Contributor score x1.2; mentor +5 pts type:bug Bug fix work category bonus label type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants