100 lines
3.6 KiB
TypeScript
100 lines
3.6 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { createTechLogFeatureInstalledInput } from "../../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
|
|
import type { ManagementGateway } from "../../../src/features/tech-log/application/ports/management-gateway.ts";
|
|
import type {
|
|
ProjectIndexPage,
|
|
TopicEdit,
|
|
} from "../../../src/features/tech-log/contracts/management/contract.ts";
|
|
import { TaxonomyManager } from "../../../src/features/tech-log/presentation/studio/components/taxonomy-manager.tsx";
|
|
import { StudioProvider } from "../../helpers/studio-test-provider.tsx";
|
|
import { DEFAULT_STUDIO_MOCK_NOW } from "../../../src/features/tech-log/adapters/mock/mock-studio-gateway.ts";
|
|
import { createManagementGatewayStub } from "../../helpers/management-gateway-stub.ts";
|
|
import { MOCK_STUDIO_INSTALL_CONTEXT } from "../../helpers/studio-install-context.ts";
|
|
import { TestQueryProviders } from "../../helpers/query-providers.tsx";
|
|
|
|
import { studioGatewayFromApplication } from "../../helpers/studio-application-gateway-adapter.ts";
|
|
describe("TechLog taxonomy projection", () => {
|
|
it("renders project-topic structure from the project index without per-project detail requests", async () => {
|
|
const topicId = "11111111-1111-4111-8111-111111111111";
|
|
const projectId = "22222222-2222-4222-8222-222222222222";
|
|
const listTopics = vi
|
|
.fn<ManagementGateway["listTopics"]>()
|
|
.mockResolvedValue([
|
|
{
|
|
id: topicId,
|
|
name: "인증 경계",
|
|
slug: "auth-boundary",
|
|
status: "ACTIVE",
|
|
} as TopicEdit,
|
|
]);
|
|
const listProjects = vi
|
|
.fn<ManagementGateway["listProjects"]>()
|
|
.mockResolvedValue({
|
|
items: [
|
|
{
|
|
id: projectId,
|
|
name: "Keycloak Patterns",
|
|
slug: "keycloak-patterns",
|
|
topicIds: [topicId],
|
|
phase: "BUILDING",
|
|
workflowStatus: "DRAFT",
|
|
targetVisibility: "PRIVATE",
|
|
updatedAt: "2026-09-21T00:00:00Z",
|
|
version: 3,
|
|
publication: {
|
|
state: "NEVER_PUBLISHED",
|
|
hasUnpublishedChanges: true,
|
|
},
|
|
},
|
|
],
|
|
page: {
|
|
number: 0,
|
|
size: 50,
|
|
totalElements: 1,
|
|
totalPages: 1,
|
|
hasPrevious: false,
|
|
hasNext: false,
|
|
},
|
|
} as ProjectIndexPage);
|
|
const getProject = vi
|
|
.fn<ManagementGateway["getProject"]>()
|
|
.mockRejectedValue(new Error("taxonomy must not load project details"));
|
|
const managementGateway = createManagementGatewayStub({
|
|
listTopics,
|
|
listProjects,
|
|
getProject,
|
|
});
|
|
const studioGateway =
|
|
studioGatewayFromApplication(createTechLogFeatureInstalledInput(
|
|
MOCK_STUDIO_INSTALL_CONTEXT,
|
|
).input.createStudioApplication());
|
|
|
|
render(
|
|
<TestQueryProviders>
|
|
<MemoryRouter>
|
|
<StudioProvider
|
|
now={() => new Date(DEFAULT_STUDIO_MOCK_NOW)}
|
|
createGateway={() => studioGateway}
|
|
createManagementGateway={() => managementGateway}
|
|
>
|
|
<TaxonomyManager />
|
|
</StudioProvider>
|
|
</MemoryRouter>
|
|
</TestQueryProviders>,
|
|
);
|
|
|
|
expect(await screen.findByText("Keycloak Patterns")).toBeVisible();
|
|
expect(screen.getByText("인증 경계")).toBeVisible();
|
|
await waitFor(() => {
|
|
expect(listTopics).toHaveBeenCalledTimes(1);
|
|
expect(listProjects).toHaveBeenCalledTimes(1);
|
|
});
|
|
expect(getProject).not.toHaveBeenCalled();
|
|
});
|
|
});
|