Skip to content

test(settings): add coverage for save reset and export flows #560#665

Merged
utksh1 merged 7 commits into
utksh1:mainfrom
NaitikVerma6776:test/settings-save-reset-export
Jun 9, 2026
Merged

test(settings): add coverage for save reset and export flows #560#665
utksh1 merged 7 commits into
utksh1:mainfrom
NaitikVerma6776:test/settings-save-reset-export

Conversation

@NaitikVerma6776

Copy link
Copy Markdown
Contributor

Description

Added page-level test coverage for Settings.tsx.

Changes include:

  • Testing save configuration flow and localStorage persistence.
  • Testing reset confirmation modal behavior.
  • Testing export functionality using a test-friendly stub without triggering real downloads.

Related Issues

Closes #560

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran Vitest test suite locally:

npm test

Verified:

  • Settings save flow persists configuration to localStorage.
  • Reset confirmation modal appears correctly.
  • Export flow triggers the expected download behavior through a stub.
  • Existing theme persistence tests continue to pass.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.

@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label area:frontend Frontend React/UI work labels Jun 8, 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.

This needs cleanup before merge. The test file now includes a UTF-8 BOM at the start of the import line, adds an it.skip export-flow test, and the added coverage is mostly duplicated by existing Settings tests instead of exercising the requested save/reset/export behavior end-to-end. Please remove the BOM, avoid committed skipped tests, and either make the export-flow test active or keep the PR to focused non-duplicated coverage.

@NaitikVerma6776

NaitikVerma6776 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Hey @utksh1 , made the requested changes:

Issues fixed:

  • Removed the UTF-8 BOM from the import line
  • Removed the it.skip export-flow test entirely
  • Fixed broken syntax in SettingsTheme.test.tsx (code was floating outside it blocks with a nested it inside another it)

What's added:

  • Created SettingsExport.test.tsx with 4 focused active tests covering the export flow end-to-end using a test-friendly stub (spies on document.createElement('a') and mocks .click() so no real download fires)

  • Verifies anchor is created with a valid JSON data URI

  • Verifies filename is secuscan_config_.json

  • Verifies exported JSON contains the current config values

  • Verifies anchor is removed from DOM after click- No duplication: save and reset behavior are already covered by SettingsSaveReset.test.tsx, theme persistence by SettingsTheme.test.tsx, so the new file only adds what was missing.

  • All 11 tests pass locally via npm test.

Please review the changes and feel free to give feedback

@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. Still needs cleanup: SettingsTheme.test.tsx contains a BOM at the import line, skipped export coverage was split but the files still have no final newline, and the tests need to match existing formatting/hygiene. Please remove encoding/no-newline churn and rerun frontend checks.

@NaitikVerma6776

Copy link
Copy Markdown
Contributor Author

heyy @utksh1 ,if u want to squash all the commits into one . U can convey me.

@NaitikVerma6776

Copy link
Copy Markdown
Contributor Author

Fixed all issues raised in the review:

Removed UTF-8 BOM from SettingsTheme.test.tsx and SettingsExport.test.tsx (both files now start cleanly with import)
Added final newline to both files
Removed explicit vitest imports (vi, describe, it, expect, beforeEach) to match existing file hygiene
No skipped tests — all 4 export flow tests are active
Export coverage is focused and non-duplicated — save/reset are already covered by SettingsSaveReset.test.tsx, theme by SettingsTheme.test.tsx, so SettingsExport.test.tsx only covers what was missing

All 11 tests pass locally via npm test.

@utksh1 utksh1 added the gssoc:approved Admin validation: approved for GSSoC scoring label Jun 9, 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 latest update removes the BOM/no-final-newline/test-style issues and keeps the diff to focused Settings save/reset/export coverage. CI is green on the reviewed head; approved pending a fresh branch update.

@utksh1 utksh1 merged commit f920c2f into utksh1:main Jun 9, 2026
12 checks passed
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 gssoc:approved Admin validation: approved for GSSoC scoring level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] Add Settings page coverage for save, reset, and export flows

2 participants