This commit is contained in:
2026-04-21 19:17:31 +08:00
parent d234d27cc0
commit 89129ef1f4
83 changed files with 13329 additions and 176 deletions

View File

@@ -175,6 +175,26 @@ describe('apiClient', () => {
expect(window.dispatchEvent).not.toHaveBeenCalled();
});
it('keeps the current access token when a public request explicitly skips auth', async () => {
setStoredAccessToken('still-valid-token');
vi.mocked(window.dispatchEvent).mockClear();
fetchMock.mockResolvedValueOnce(createResponseMock({ status: 401 }));
const response = await fetchWithApiAuth(
'/api/runtime/custom-world-gallery',
{ method: 'GET' },
{
skipAuth: true,
skipRefresh: true,
},
);
expect(response.status).toBe(401);
expect(fetchMock).toHaveBeenCalledTimes(1);
expect(getStoredAccessToken()).toBe('still-valid-token');
expect(window.dispatchEvent).not.toHaveBeenCalled();
});
it('retries transient get requests before unwrapping the response envelope', async () => {
fetchMock
.mockRejectedValueOnce(new TypeError('network unavailable'))