feat: comment to test run's case (#390)

This commit is contained in:
kimatata
2026-02-23 12:26:07 +09:00
committed by GitHub
parent 1f4ac0ae7b
commit a9674c81ab
27 changed files with 1045 additions and 40 deletions

View File

@@ -109,7 +109,19 @@ export default function (sequelize) {
},
{
model: RunCase,
attributes: ['id', 'runId', 'status'],
attributes: [
'id',
'runId',
'status',
[
sequelize.literal(
'(SELECT COUNT(*) FROM `comments` WHERE `comments`.`commentableType` = ' +
sequelize.escape('RunCase') +
' AND `comments`.`commentableId` = `RunCases`.`id`)'
),
'commentCount',
],
],
// Must be 'true' when filtering by status, otherwise all cases are returned.
required: runCaseRequired,
where: {

View File

@@ -7,6 +7,7 @@ import defineTag from '../../models/tags.js';
import defineAttachment from '../../models/attachments.js';
import authMiddleware from '../../middleware/auth.js';
import visibilityMiddleware from '../../middleware/verifyVisible.js';
import defineRunCase from '../../models/runCases.js';
export default function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
@@ -19,6 +20,10 @@ export default function (sequelize) {
Attachment.belongsToMany(Case, { through: 'caseAttachments' });
Case.belongsToMany(Tags, { through: 'caseTags', foreignKey: 'caseId', otherKey: 'tagId' });
Tags.belongsToMany(Case, { through: 'caseTags', foreignKey: 'tagId', otherKey: 'caseId' });
const RunCase = defineRunCase(sequelize, DataTypes);
RunCase.belongsTo(Case, { foreignKey: 'caseId' });
Case.hasMany(RunCase, { foreignKey: 'caseId' });
const { verifySignedIn } = authMiddleware(sequelize);
const { verifyProjectVisibleFromCaseId } = visibilityMiddleware(sequelize);
@@ -44,6 +49,9 @@ export default function (sequelize) {
attributes: ['id', 'name'],
through: { attributes: [] },
},
{
model: RunCase,
},
],
});
return res.json(testcase);