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
2 changes: 1 addition & 1 deletion src/features/review/dto/inputs/product-reviews.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ProductReviewsInput {
@IsOptional()
@IsString()
@IsNotEmpty()
cursor?: string;
cursor?: string | null;

@IsOptional()
@IsInt()
Expand Down
2 changes: 1 addition & 1 deletion src/features/review/dto/inputs/store-reviews.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class StoreReviewsInput {
@IsOptional()
@IsString()
@IsNotEmpty()
cursor?: string;
cursor?: string | null;

@IsOptional()
@IsInt()
Expand Down
14 changes: 13 additions & 1 deletion src/features/review/services/review-listing.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('ReviewListingService (real DB)', () => {
args: {
photoOnly?: boolean;
sort?: 'LATEST' | 'LIKES';
cursor?: string;
cursor?: string | null;
limit?: number;
} = {},
accountId?: bigint,
Expand Down Expand Up @@ -270,6 +270,18 @@ describe('ReviewListingService (real DB)', () => {
);
});

it.each(['LATEST', 'LIKES'] as const)(
'cursor null은 첫 페이지로 처리한다 (%s)',
async (sort) => {
const target = await makeTarget();
const review = await makeReview(target);

const result = await list(kind, target, { sort, cursor: null });

expect(result.items.map((r) => r.id)).toEqual([review.id.toString()]);
},
);

it('cursor "0"은 페이지를 리셋하지 않고 빈 결과를 반환한다', async () => {
const target = await makeTarget();
await makeReview(target);
Expand Down
5 changes: 3 additions & 2 deletions src/features/review/services/review-listing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
interface ListingArgs {
photoOnly?: boolean;
sort?: ReviewSort;
cursor?: string;
cursor?: string | null;
limit?: number;
}

Expand Down Expand Up @@ -115,7 +115,8 @@ export class ReviewListingService {
photoOnly,
sort,
limit,
cursorRaw: input.cursor,
// 명시적 cursor: null도 첫 페이지 요청이다
cursorRaw: input.cursor ?? undefined,
}),
this.repo.countReviews({ scope, photoOnly: false }),
this.repo.countReviews({ scope, photoOnly: true }),
Expand Down
Loading