Skip to content

test(api): add unit tests for admin network-policies route (#1405) - #1634

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
sergioprica:test/network-policies-route-1405
Oct 2, 2026
Merged

RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
sergioprica:test/network-policies-route-1405

Conversation

@sergioprica

@sergioprica sergioprica commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

closes #1405
Closes #1405

Summary

Adds unit tests in src/app/api/admin/network-policies/__tests__/route.test.ts covering the GET, POST, and DELETE handlers exported by src/app/api/admin/network-policies/route.ts.

Scenarios Covered

  • GET: returns 200 with { success: true, data: [...] }.
  • POST:
    • valid IP / CIDR / COUNTRY policy returns 201 with trimmed value, generated np_* ID, and createdAt timestamp.
    • truncates description to 200 characters when longer.
    • returns 400 (Invalid scope, Value is required, Invalid action, Invalid request body) on invalid or malformed inputs.
  • DELETE:
    • deletes an existing policy by id (200 { success: true }).
    • returns 400 when id query param is missing.
    • returns 404 when id is not found.

Verification

  • Verified all 9 test cases pass under vitest run src/app/api/admin/network-policies/__tests__/route.test.ts.

This contribution was prepared by an autonomous agent operating on the
Averray platform.

Agent identity: 0xF051A3FA695Eb21ab13Db2dEfe60Cd47f0BE343b
Claim session: pr-rinafcode-teachlink-web-1405:0xF051A3FA695Eb21ab13Db2dEfe60Cd47f0BE343b
Job spec: https://api.averray.com/jobs/definition?jobId=pr-rinafcode-teachlink-web-1405
Submission: 0x{hash}

Maintainer review of the substance is requested before merge.
The Averray platform funds this contribution; the agent receives no
direct compensation from this repository. Decline at will.

@RUKAYAT-CODER

RUKAYAT-CODER commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Well done on the progress so far
Kindly fix workflow to pass and resolve conflict.
Run npm run lint to view and fix lint errors

@sergioprica
sergioprica force-pushed the test/network-policies-route-1405 branch from ceba57a to 9721ec1 Compare September 29, 2026 03:45
@sergioprica

Copy link
Copy Markdown
Contributor Author

Thank you @RUKAYAT-CODER! I have rebased the branch onto the latest main to resolve the merge conflict, aligned the test suite with the typed Request helper so both pnpm run lint and pnpm run type-check pass cleanly, and updated the issue link keyword for the PR quality gate.

@sergioprica
sergioprica force-pushed the test/network-policies-route-1405 branch from 9721ec1 to ba8a334 Compare September 30, 2026 19:33
@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 0eb2547 into rinafcode:main Oct 2, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for the API route src/app/api/admin/network-policies/route.ts

2 participants