Skip to content

test(auth): address review comments on JwtValidator unit tests#12

Merged
Psyborgs-git merged 3 commits intoadd-jwt-validator-tests-12249440911468361910from
copilot/sub-pr-10
Feb 26, 2026
Merged

test(auth): address review comments on JwtValidator unit tests#12
Psyborgs-git merged 3 commits intoadd-jwt-validator-tests-12249440911468361910from
copilot/sub-pr-10

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

Cleans up packages/auth/src/jwt.test.ts based on PR review feedback.

Changes

  • Remove unused import: Drop type Mock from the vitest import line
  • Add file header: Add /** Tests for @orch/auth/jwt — JwtValidator unit tests */ per project convention
  • Eliminate redundant validate() calls: Refactor "missing issuer" and "provider not found" tests to call validate() once, capture the error, and assert all properties on it — instead of calling it 2–3 times with separate expect(...).rejects chains
  • Fix indentation: Align the rethrow OrchestratorError test body to 4-space indent, consistent with the rest of the file

Before (redundant calls):

await expect(validator.validate(validToken)).rejects.toThrow(OrchestratorError);
await expect(validator.validate(validToken)).rejects.toThrow('JWT missing required "iss" claim');
try {
    await validator.validate(validToken); // called a 3rd time just to assert .code
} catch (err: any) {
    expect(err.code).toBe(ErrorCode.TOKEN_INVALID);
}

After (single call):

let error: any;
try {
    await validator.validate(validToken);
} catch (err: any) {
    error = err;
}
expect(error).toBeInstanceOf(OrchestratorError);
expect(error.message).toContain('JWT missing required "iss" claim');
expect(error.code).toBe(ErrorCode.TOKEN_INVALID);

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Psyborgs-git <49641518+Psyborgs-git@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for JwtValidator in auth package test(auth): address review comments on JwtValidator unit tests Feb 26, 2026
@Psyborgs-git Psyborgs-git marked this pull request as ready for review February 26, 2026 04:30
@Psyborgs-git Psyborgs-git merged commit 20f4fab into add-jwt-validator-tests-12249440911468361910 Feb 26, 2026
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.

2 participants