Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ docker-compose up -d
| Buyer | `rJvbMhFjmfAd5DZAVhXe7kuPBKmhBMkaCH` |
| Seller | `ra7MVxG3MUCqym6opZBQXj9bSx5P7s5B4Y` |

> Testnet Faucet: https://xrpl.org/xrp-testnet-faucet.html

---

Expand Down
15 changes: 1 addition & 14 deletions src/modules/partners/partners.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,11 @@ describe("PartnersController", () => {
it("모든 파라미터를 서비스에 전달", async () => {
mockPartnersService.search.mockResolvedValue({ data: [] });

await controller.search(
null,
"acme",
5,
"Automotive",
"Korea",
"OEM",
"1-10",
"buyer-id",
);
await controller.search(null, "acme", 5, "buyer-id");

expect(mockPartnersService.search).toHaveBeenCalledWith({
q: "acme",
limit: 5,
industry: "Automotive",
country: "Korea",
partnership: "OEM",
size: "1-10",
buyerId: "buyer-id",
});
});
Expand Down
20 changes: 0 additions & 20 deletions src/modules/partners/partners.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ export class PartnersController {
type: Number,
description: "결과 수 (기본 10)",
})
@ApiQuery({ name: "industry", required: false, description: "산업 필터" })
@ApiQuery({ name: "country", required: false, description: "국가 필터" })
@ApiQuery({
name: "partnership",
required: false,
description: "파트너십 태그 필터",
})
@ApiQuery({
name: "size",
required: false,
description: "기업 규모 (예: 1-10, 11-50, 51-200)",
})
@ApiQuery({
name: "buyerId",
required: false,
Expand All @@ -60,19 +48,11 @@ export class PartnersController {
@OptionalCurrentUser() user: SessionUser | null,
@Query("q") q: string,
@Query("limit", new DefaultValuePipe(10), ParseIntPipe) limit?: number,
@Query("industry") industry?: string,
@Query("country") country?: string,
@Query("partnership") partnership?: string,
@Query("size") size?: string,
@Query("buyerId") buyerId?: string,
) {
return this.partnersService.search({
q,
limit,
industry,
country,
partnership,
size,
buyerId,
userId: user?.userId,
});
Expand Down
41 changes: 15 additions & 26 deletions src/modules/partners/partners.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,37 +97,17 @@ describe("PartnersService", () => {

// ── browse 모드 ───────────────────────────────────────────────────────────────

describe("browse 모드 (필터만, 쿼리 없음)", () => {
it("industry 매핑 필터 적용 후 score=1.0", async () => {
// AI 분석 모킹
jest.spyOn(service as any, "generateHyDEAndKeywords").mockResolvedValue({
profile: "",
keywords: "",
});

describe("browse 모드 (쿼리 없음, 전체 조회)", () => {
it("쿼리 없을 때 전체 조회 후 score=1.0", async () => {
sellerModel.find.mockReturnValue(
buildQueryMock([{ _id: "c1", name: "Acme" }]),
);

const result = await service.search({
q: "",
industry: "IT / AI / SaaS",
});
const result = await service.search({ q: "" });

expect(sellerModel.find).toHaveBeenCalled();
expect(result.data[0].score).toBe(1.0);
});

it("country 필터 적용", async () => {
sellerModel.find.mockReturnValue(buildQueryMock([]));

await service.search({ q: "", country: "Korea" });

expect(sellerModel.find).toHaveBeenCalledWith(
expect.objectContaining({ "location.country": "Korea" }),
expect.any(Object),
);
});
});

// ── 벡터 검색 ─────────────────────────────────────────────────────────────────
Expand All @@ -137,6 +117,8 @@ describe("PartnersService", () => {
embeddingsService.embed.mockResolvedValue(new Array(64).fill(0.1));
sellerModel.aggregate.mockResolvedValue([
{ _id: "c1", name: "Acme", score: 0.9 },
{ _id: "c2", name: "Beta", score: 0.8 },
{ _id: "c3", name: "Gamma", score: 0.7 },
]);

const result = await service.search({ q: "화장품 제조사" });
Expand All @@ -156,6 +138,8 @@ describe("PartnersService", () => {
industry: "Beauty / Consumer Goods / Food",
score: 12,
},
{ _id: "c2", name: "Alpha Corp", score: 8 },
{ _id: "c3", name: "Beta Corp", score: 4 },
]),
);

Expand All @@ -172,12 +156,16 @@ describe("PartnersService", () => {
embeddingsService.embed.mockResolvedValue(new Array(64).fill(0.1));
sellerModel.aggregate.mockResolvedValue([]); // 벡터 결과 없음
sellerModel.find.mockReturnValue(
buildQueryMock([{ _id: "c2", name: "Beta", score: 3 }]),
buildQueryMock([
{ _id: "c2", name: "Beta", score: 3 },
{ _id: "c3", name: "Alpha", score: 2 },
{ _id: "c4", name: "Gamma", score: 1 },
]),
);

const result = await service.search({ q: "식품" });

expect(result.data).toHaveLength(1);
expect(result.data).toHaveLength(3);
expect(result.data[0].name).toBe("Beta");
});
});
Expand All @@ -189,6 +177,8 @@ describe("PartnersService", () => {
buyerModel.find.mockReturnValue(
buildQueryMock([
{ _id: "b1", name_kr: "라온바이어", country: "US", score: 10 },
{ _id: "b2", name_kr: "서울바이어", country: "KR", score: 8 },
{ _id: "b3", name_kr: "부산바이어", country: "KR", score: 6 },
]),
);

Expand Down Expand Up @@ -286,7 +276,6 @@ describe("PartnersService", () => {

await service.search({
q: "",
industry: "IT / AI / SaaS",
userId: USER_ID,
});

Expand Down
Loading
Loading