Skip to content

Add API request behavior tests#642

Open
HitanshiThakar wants to merge 2 commits into
utksh1:mainfrom
HitanshiThakar:test/api-timeout-behavior
Open

Add API request behavior tests#642
HitanshiThakar wants to merge 2 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
Copy link
Copy Markdown
Owner

@utksh1 utksh1 left a comment

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.

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: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