Skip to content

Add API request behavior tests#642

Merged
utksh1 merged 4 commits into
utksh1:mainfrom
HitanshiThakar:test/api-timeout-behavior
Jun 9, 2026
Merged

Add API request behavior tests#642
utksh1 merged 4 commits into
utksh1:mainfrom
HitanshiThakar:test/api-timeout-behavior

Conversation

@HitanshiThakar

Copy link
Copy Markdown
Contributor

Description

Added focused unit tests for frontend API request behavior covering the exported API functions from frontend/src/api.ts.

Created api.request-behavior.test.ts to cover:

successful API responses
non-OK HTTP responses
timeout and abort behavior
timeout cleanup during rejected requests

Also added fake timer usage and proper mock/timer restoration to avoid test leakage.

Related Issues

Closes #471

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?

Ran npx vitest run testing/unit/api.request-behavior.test.ts
7 tests passed

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.

@HitanshiThakar

Copy link
Copy Markdown
Contributor Author

The added API request behavior tests are passing locally.
The remaining CI failures appear unrelated to this PR and are coming from existing frontend/backend tests after syncing with the latest main.

@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs 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 API behavior tests need a rebase/fix before review can continue. Current required checks are failing, including frontend-checks, and backend jobs are skipped. Please rebase on the current CI baseline and make the tests pass cleanly.

@HitanshiThakar

Copy link
Copy Markdown
Contributor Author

Done, All the checks have passed.

@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.

Re-reviewed the latest push. The API request behavior tests are focused and checks were green before the branch became behind.

@utksh1 utksh1 merged commit 084a11c 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:intermediate 35 pts difficulty label for moderate contributor PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] Add API client tests for request timeout and abort behavior

2 participants