feat(tags): add tags to test cases (#299)
This commit is contained in:
@@ -3,6 +3,7 @@ const router = express.Router();
|
||||
import { DataTypes } from 'sequelize';
|
||||
import defineCase from '../../models/cases.js';
|
||||
import defineStep from '../../models/steps.js';
|
||||
import defineTag from '../../models/tags.js';
|
||||
import defineAttachment from '../../models/attachments.js';
|
||||
import authMiddleware from '../../middleware/auth.js';
|
||||
import visibilityMiddleware from '../../middleware/verifyVisible.js';
|
||||
@@ -10,11 +11,14 @@ import visibilityMiddleware from '../../middleware/verifyVisible.js';
|
||||
export default function (sequelize) {
|
||||
const Case = defineCase(sequelize, DataTypes);
|
||||
const Step = defineStep(sequelize, DataTypes);
|
||||
const Tags = defineTag(sequelize, DataTypes);
|
||||
const Attachment = defineAttachment(sequelize, DataTypes);
|
||||
Case.belongsToMany(Step, { through: 'caseSteps' });
|
||||
Step.belongsToMany(Case, { through: 'caseSteps' });
|
||||
Case.belongsToMany(Attachment, { through: 'caseAttachments' });
|
||||
Attachment.belongsToMany(Case, { through: 'caseAttachments' });
|
||||
Case.belongsToMany(Tags, { through: 'caseTags', foreignKey: 'caseId', otherKey: 'tagId' });
|
||||
Tags.belongsToMany(Case, { through: 'caseTags', foreignKey: 'tagId', otherKey: 'caseId' });
|
||||
const { verifySignedIn } = authMiddleware(sequelize);
|
||||
const { verifyProjectVisibleFromCaseId } = visibilityMiddleware(sequelize);
|
||||
|
||||
@@ -35,6 +39,11 @@ export default function (sequelize) {
|
||||
{
|
||||
model: Attachment,
|
||||
},
|
||||
{
|
||||
model: Tags,
|
||||
attributes: ['id', 'name'],
|
||||
through: { attributes: [] },
|
||||
},
|
||||
],
|
||||
});
|
||||
return res.json(testcase);
|
||||
|
||||
Reference in New Issue
Block a user