This commit is contained in:
seb
2026-10-26 01:01:08 +01:00
parent 358e3009b2
commit 563945394b
4 changed files with 117 additions and 0 deletions

View File

@@ -225,6 +225,42 @@ describe('store.category', () => {
/Not authorized|Parent not found/,
);
});
it('touches updated_at on moved category, subcategories, and associated articles', async () => {
const topTarget = await create('Move Target');
const movedCat = await create('Moved Cat');
const subCat = await create('Sub Cat', movedCat.id);
const artMoved = await createArticle(store, tenant, { parentId: movedCat.id, name: 'Article in Moved' });
const artSub = await createArticle(store, tenant, { parentId: subCat.id, name: 'Article in Sub' });
const oldDate = '2020-01-01T00:00:00.000Z';
await ctx.provider.query(
`UPDATE category SET updated_at = '${oldDate}' WHERE id IN (${movedCat.id}, ${subCat.id})`
);
await ctx.provider.query(
`UPDATE article SET updated_at = '${oldDate}' WHERE id IN (${artMoved.id}, ${artSub.id})`
);
await store.category.move({
googleAuthId: tenant.googleAuthId,
id: movedCat.id,
parentId: topTarget.id,
});
const cats = await ctx.provider.query(
`SELECT id, updated_at FROM category WHERE id IN (${movedCat.id}, ${subCat.id})`
);
for (const row of cats.rows) {
assert.ok(new Date(row.updated_at) > new Date(oldDate), `Category ${row.id} updated_at was touched`);
}
const arts = await ctx.provider.query(
`SELECT id, updated_at FROM article WHERE id IN (${artMoved.id}, ${artSub.id})`
);
for (const row of arts.rows) {
assert.ok(new Date(row.updated_at) > new Date(oldDate), `Article ${row.id} updated_at was touched`);
}
});
});
describe('order', () => {