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
17 changes: 16 additions & 1 deletion src/features/order/repositories/order.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ export interface OngoingOrderRow {
}[];
}

/** 리뷰 작성 가능 주문 아이템 row. UserReviewService 매핑 입력. */
export interface ReviewableOrderItemRow {
id: bigint;
product_id: bigint;
product_name_snapshot: string;
order: { picked_up_at: Date | null } | null;
product: { images: { image_url: string }[] } | null;
store: {
store_name: string;
address_city: string | null;
address_neighborhood: string | null;
region: { name: string } | null;
} | null;
}

@Injectable()
export class OrderRepository {
constructor(private readonly prisma: PrismaService) {}
Expand Down Expand Up @@ -183,7 +198,7 @@ export class OrderRepository {
accountId: bigint;
offset: number;
limit: number;
}) {
}): Promise<{ items: ReviewableOrderItemRow[]; totalCount: number }> {
const where = {
deleted_at: null,
order: {
Expand Down
10 changes: 10 additions & 0 deletions src/features/user/services/user-review.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,26 @@ describe('UserReviewService (real DB)', () => {
where: { id: setup.storeId },
data: { address_city: '인천', address_neighborhood: '청라동' },
});
const pickedUpAt = new Date('2026-08-15T05:00:00.000Z');
const orderItem = await prisma.orderItem.findUniqueOrThrow({
where: { id: setup.orderItemId },
});
await prisma.order.update({
where: { id: orderItem.order_id },
data: { picked_up_at: pickedUpAt },
});

const [item] = (await service.myReviewableOrderItems(setup.accountId))
.items;

expect(item).toMatchObject({
orderItemId: setup.orderItemId.toString(),
productId: setup.productId.toString(),
productName: '상품R 스냅샷',
productImageUrl: 'https://img/review-target.png',
storeName: '매장R',
regionLabel: '인천 청라동',
pickedUpAt,
});
});

Expand Down
Loading