Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
95bd2b5
refactor(frontend): improve McpServerTab with separation of concerns …
Oct 23, 2025
566853c
fix(frontend): fix sidebar cookie state and use-mobile event listener…
Oct 23, 2025
86d5621
refactor(frontend): extract McpServerTab sections into focused compon…
Oct 24, 2025
2bb84e4
refactor(frontend): merge McpCodeDisplay into McpJsonContent for bett…
Oct 24, 2025
890b642
refactor(frontend): organize types and interfaces at the top of McpJs…
Oct 24, 2025
9d983b4
refactor(frontend): organize types at the top of mcpServerUtils
Oct 24, 2025
64bfa8f
test(frontend): add critical user flow tests for McpServerTab refacto…
Oct 24, 2025
30d4879
refactor(frontend): remove all 'any' types from tests and components
Oct 24, 2025
9d4095e
refactor(test): clarify useMcpServer test scope
Oct 24, 2025
0669698
fix(frontend): fix WSL platform detection in buildMcpServerJson
Oct 24, 2025
6d63543
refactor(test): remove unnecessary comments and extra test files
Oct 24, 2025
19db5e3
test(frontend): add comprehensive unit tests for MCP section components
Oct 24, 2025
621baf6
fix(test): make message-sorting performance test more robust for CI
Oct 24, 2025
1aa5612
test(frontend): add tests for generateApiKey in authStore
Oct 24, 2025
bbc0181
test(frontend): improve authStore generateApiKey test coverage
Oct 24, 2025
eba279a
docs(test): add comment explaining useMcpServer integration test cove…
Oct 24, 2025
2ee5d2a
test(frontend): add explicit tests for api_key condition branches
Oct 24, 2025
f918f8e
refactor: move API key generation from authStore to useMcpServer hook
Oct 24, 2025
e92b817
fix: reset package-lock.json to match main branch
Oct 24, 2025
4780193
test(frontend): add tests for use-mobile and sidebar bug fixes
Oct 24, 2025
4e722bf
refactor(frontend): cleanup unused imports and improve code quality
Oct 24, 2025
655c8d4
test(frontend): add direct unit tests for useMcpServer hook
Oct 24, 2025
128b45f
refactor(test): remove all 'any' and 'unknown' types from tests
Oct 24, 2025
835281b
fix(test): add explicit testids for copy/check icons for E2E compatib…
Oct 24, 2025
345af75
test(frontend): add tests for copy/check icon states
Oct 24, 2025
fbb55d5
test(frontend): improve icon tests to verify both name and testId
Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(frontend): add explicit tests for api_key condition branches
- Test when api_key is missing from response
- Test when api_key is null
- Test when api_key is undefined
- Ensure both branches of 'if (res?.api_key)' are covered
- Maintains 100% line coverage on authStore.ts
  • Loading branch information
Olfa Maslah authored and Olfa Maslah committed Oct 30, 2025
commit 2ee5d2a99065bb7151338852feab74c0f2341c3b
36 changes: 35 additions & 1 deletion src/frontend/src/stores/__tests__/authStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,50 @@ describe("useAuthStore", () => {
consoleErrorSpy.mockRestore();
});

it("should handle missing api_key in response", async () => {
it("should NOT set apiKey when response has no api_key property", async () => {
const { result } = renderHook(() => useAuthStore());
const initialApiKey = result.current.apiKey;

// Response without api_key property
mockCreateApiKey.mockResolvedValue({});

await act(async () => {
await result.current.generateApiKey?.();
});

// apiKey should remain unchanged (condition if (res?.api_key) is false)
expect(result.current.apiKey).toBe(initialApiKey);
expect(result.current.isGeneratingApiKey).toBe(false);
});

it("should NOT set apiKey when api_key is null", async () => {
const { result } = renderHook(() => useAuthStore());
const initialApiKey = result.current.apiKey;

// Response with null api_key
mockCreateApiKey.mockResolvedValue({ api_key: null });

await act(async () => {
await result.current.generateApiKey?.();
});

// apiKey should remain unchanged (condition if (res?.api_key) is false)
expect(result.current.apiKey).toBe(initialApiKey);
expect(result.current.isGeneratingApiKey).toBe(false);
});

it("should NOT set apiKey when api_key is undefined", async () => {
const { result } = renderHook(() => useAuthStore());
const initialApiKey = result.current.apiKey;

// Response with undefined api_key
mockCreateApiKey.mockResolvedValue({ api_key: undefined });

await act(async () => {
await result.current.generateApiKey?.();
});

// apiKey should remain unchanged (condition if (res?.api_key) is false)
expect(result.current.apiKey).toBe(initialApiKey);
expect(result.current.isGeneratingApiKey).toBe(false);
});
Expand Down