refactor(api): pair public tag filters with groups
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { NotFoundException } from '@nestjs/common';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { PublicService } from './public.service';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
@@ -247,7 +247,9 @@ describe('PublicService', () => {
|
||||
pageSize: 50,
|
||||
countryId: countryId.toString(),
|
||||
keyword: `Pub `,
|
||||
tagIds: filterTagIds.slice(0, 2).map(String),
|
||||
tagIds: filterTagIds
|
||||
.slice(0, 2)
|
||||
.map((tagId) => `${filterGroupIds[0]}:${tagId}`),
|
||||
});
|
||||
expect(sameGroup.items.map((item) => item.goodName)).toEqual(
|
||||
expect.arrayContaining([`Pub High ${stamp}`, `Pub Mid ${stamp}`]),
|
||||
@@ -258,12 +260,25 @@ describe('PublicService', () => {
|
||||
pageSize: 50,
|
||||
countryId: countryId.toString(),
|
||||
keyword: `Pub `,
|
||||
tagIds: filterTagIds.map(String),
|
||||
tagIds: filterTagIds.map(
|
||||
(tagId, index) =>
|
||||
`${index < 2 ? filterGroupIds[0] : filterGroupIds[1]}:${tagId}`,
|
||||
),
|
||||
});
|
||||
expect(acrossGroups.items.map((item) => item.goodName)).toContain(`Pub High ${stamp}`);
|
||||
expect(acrossGroups.items.map((item) => item.goodName)).not.toContain(`Pub Mid ${stamp}`);
|
||||
});
|
||||
|
||||
it('rejects a tag paired with the wrong tag group', async () => {
|
||||
await expect(
|
||||
service.getGoods({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
tagIds: [`${filterGroupIds[1]}:${filterTagIds[0]}`],
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
});
|
||||
|
||||
it('returns the SDS product id as the public product id', async () => {
|
||||
const result = await service.getGoods({
|
||||
page: 1,
|
||||
|
||||
Reference in New Issue
Block a user