refactor: refactor foundation

This commit is contained in:
2026-08-14 09:43:19 +03:00
parent 2e32d226d3
commit da585b157a
54 changed files with 4822 additions and 535 deletions
+39
View File
@@ -0,0 +1,39 @@
import { HttpResponse, http } from "msw";
const authentication = {
accessToken: "test-token",
user: { id: "user-1", email: "user@example.com" },
};
export const handlers = [
http.post("*/api/v1/auth/register", () => HttpResponse.json(authentication)),
http.post("*/api/v1/auth/login", () => HttpResponse.json(authentication)),
http.post("*/api/v1/auth/refresh", () =>
HttpResponse.json({ code: "UNAUTHORIZED" }, { status: 401 }),
),
http.post(
"*/api/v1/auth/logout",
() => new HttpResponse(null, { status: 204 }),
),
http.get("*/api/v1/auth/me", () => HttpResponse.json(authentication.user)),
http.get("*/api/v1/tbank-connection", () =>
HttpResponse.json({ connected: false, connectedAt: null }),
),
http.put("*/api/v1/tbank-connection", () =>
HttpResponse.json({ connected: true, connectedAt: "2026-08-14T00:00:00Z" }),
),
http.delete(
"*/api/v1/tbank-connection",
() => new HttpResponse(null, { status: 204 }),
),
http.get("*/api/v1/brokerage-accounts", () => HttpResponse.json([])),
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
HttpResponse.json({
lastSuccessfulAt: "2026-08-14T00:00:00Z",
isStale: false,
totalsByCurrency: [],
positions: [],
cashBalances: [],
}),
),
];
+4
View File
@@ -0,0 +1,4 @@
import { setupServer } from "msw/node";
import { handlers } from "./handlers";
export const server = setupServer(...handlers);
+6
View File
@@ -1,5 +1,11 @@
import "@testing-library/jest-dom/vitest";
import { afterAll, afterEach, beforeAll } from "vitest";
import "../shared/i18n";
import { server } from "./server";
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
Object.defineProperty(window, "matchMedia", {
writable: true,