const { Course } = require('../../api/models/courses/courses.mdl'); const Unit = require('../../api/models/courses/units.mdl'); const Lesson = require('../../api/models/courses/lessons.mdl'); const { TaskList, Task } = require('../../api/models/task/task.mdl'); const Advertisement = require('../../api/models/advertisements/advertisements.mdl'); const TierPlan = require('../../api/models/tiers/tier_plans.mdl'); const { Op } = require('sequelize'); const QA_PREFIX = '[QA-TEST'; const TARGETS = [ { model: Task, column: 'name' }, { model: TaskList, column: 'name' }, { model: Advertisement, column: 'headline' }, { model: Unit, column: 'title' }, { model: Lesson, column: 'title' }, { model: Course, column: 'title' }, { model: TierPlan, column: 'label' }, ]; /** Hard-deletes every QA-TEST-prefixed fixture row across all modules this suite touches. */ async function cleanupQaTestFixtures() { const removed = {}; for (const { model, column } of TARGETS) { const count = await model.destroy({ where: { [column]: { [Op.like]: `${QA_PREFIX}%` } }, force: true, // hard delete, not just paranoid soft-delete — mirrors the manual "archive then permanently delete" cleanup flow }); if (count) removed[model.name] = count; } return removed; } module.exports = { cleanupQaTestFixtures, QA_PREFIX };