fix(seo): keep former slugs reserved to their entity, date sitemap products from Hiboutik
This commit is contained in:
@@ -54,24 +54,33 @@ describe('AppController (e2e)', () => {
|
||||
});
|
||||
|
||||
it('GET /sitemap lists the public pages', async () => {
|
||||
prisma.brand.findMany.mockResolvedValue([{ slug: 'bts', updatedAt: new Date('2026-11-01T10:00:00Z') }]);
|
||||
prisma.category.findMany.mockResolvedValue([{ slug: 'albums', updatedAt: new Date('2026-10-01T10:00:00Z') }]);
|
||||
prisma.product.findMany.mockResolvedValue([{ slug: 'bts-proof', updatedAt: new Date('2026-11-05T08:00:00Z') }]);
|
||||
prisma.brand.findMany.mockResolvedValue([{ slug: 'bts' }]);
|
||||
prisma.category.findMany.mockResolvedValue([{ slug: 'albums' }]);
|
||||
prisma.product.findMany.mockResolvedValue([
|
||||
{ slug: 'bts-proof', hiboutikUpdatedAt: new Date('2026-11-05T08:00:00Z') },
|
||||
{ slug: 'bts-wings', hiboutikUpdatedAt: null },
|
||||
]);
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.get('/sitemap')
|
||||
.expect(200)
|
||||
.expect('Cache-Control', 'public, max-age=600')
|
||||
.expect({
|
||||
brands: [{ slug: 'bts', updatedAt: '2026-11-01T10:00:00.000Z' }],
|
||||
categories: [{ slug: 'albums', updatedAt: '2026-10-01T10:00:00.000Z' }],
|
||||
products: [{ slug: 'bts-proof', updatedAt: '2026-11-05T08:00:00.000Z' }],
|
||||
brands: [{ slug: 'bts' }],
|
||||
categories: [{ slug: 'albums' }],
|
||||
products: [
|
||||
{ slug: 'bts-proof', updatedAt: '2026-11-05T08:00:00.000Z' },
|
||||
{ slug: 'bts-wings', updatedAt: null },
|
||||
],
|
||||
});
|
||||
// only public rows with a slug are read
|
||||
// only public rows with a slug are read; products are dated by Hiboutik, not by the last sync
|
||||
expect(prisma.brand.findMany).toHaveBeenCalledWith(expect.objectContaining({ where: { slug: { not: null }, enabled: true } }));
|
||||
expect(prisma.category.findMany).toHaveBeenCalledWith(expect.objectContaining({ where: { slug: { not: null }, webEnabled: true } }));
|
||||
expect(prisma.product.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ where: { slug: { not: null }, enabled: true, archived: false } }),
|
||||
expect.objectContaining({
|
||||
where: { slug: { not: null }, enabled: true, archived: false },
|
||||
select: { slug: true, hiboutikUpdatedAt: true },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user