refactor: 템플릿에서 기본적으로 제공하고 있는 워크 플로우에 디자인과 라우팅 흡수
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
createTechLogStudioApplication,
|
||||
} from "../../../src/features/tech-log/application/studio-application.ts";
|
||||
import type { ManagementGateway } from "../../../src/features/tech-log/application/ports/management-gateway.ts";
|
||||
import type { StudioAssetGateway } from "../../../src/features/tech-log/application/ports/studio-asset-gateway.ts";
|
||||
import type { StudioGateway } from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
|
||||
|
||||
describe("TechLog Studio application boundary", () => {
|
||||
it("exposes application capabilities without exposing outbound gateway objects", async () => {
|
||||
const dashboard = { marker: "dashboard" };
|
||||
const saved = { marker: "saved" };
|
||||
const assetPage = { marker: "asset-page" };
|
||||
const topics = [{ marker: "topic" }];
|
||||
|
||||
const studio = {
|
||||
getDashboard: vi.fn(async () => dashboard),
|
||||
saveDocument: vi.fn(async () => saved),
|
||||
} as unknown as StudioGateway;
|
||||
const assets = {
|
||||
listAssets: vi.fn(async () => assetPage),
|
||||
} as unknown as StudioAssetGateway;
|
||||
const management = {
|
||||
listTopics: vi.fn(async () => topics),
|
||||
} as unknown as ManagementGateway;
|
||||
|
||||
const application = createTechLogStudioApplication({
|
||||
studio,
|
||||
assets,
|
||||
management,
|
||||
});
|
||||
|
||||
expect("documents" in application).toBe(false);
|
||||
expect("assets" in application).toBe(false);
|
||||
expect("management" in application).toBe(false);
|
||||
|
||||
await expect(application.workspaceQueries.getDashboard()).resolves.toBe(dashboard);
|
||||
await expect(
|
||||
application.documentCommands.saveDocument(
|
||||
"document-1",
|
||||
{} as Parameters<StudioGateway["saveDocument"]>[1],
|
||||
{ idempotencyKey: "save-1" },
|
||||
),
|
||||
).resolves.toBe(saved);
|
||||
await expect(application.assetQueries.listAssets({})).resolves.toBe(assetPage);
|
||||
await expect(application.managementQueries.listTopics()).resolves.toBe(topics);
|
||||
|
||||
expect(studio.getDashboard).toHaveBeenCalledTimes(1);
|
||||
expect(studio.saveDocument).toHaveBeenCalledWith(
|
||||
"document-1",
|
||||
{},
|
||||
{ idempotencyKey: "save-1" },
|
||||
);
|
||||
expect(assets.listAssets).toHaveBeenCalledWith({}, undefined);
|
||||
expect(management.listTopics).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user