Introduce prettier

This commit is contained in:
Takeshi Kimata
2024-05-19 21:04:45 +09:00
parent cbb5993276
commit 75eeebefda
89 changed files with 872 additions and 944 deletions

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const path = require('path');
const { Sequelize } = require("sequelize");
const { Sequelize } = require('sequelize');
const app = express();
// enable frontend access
const cors = require("cors");
const cors = require('cors');
const frontendOrigin = process.env.FRONTEND_ORIGIN || 'http://localhost:3000';
const corsOptions = {
origin: frontendOrigin,
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
};
app.use(cors(corsOptions));
@@ -16,103 +16,103 @@ app.use(cors(corsOptions));
app.use(express.json());
// Specify the directory to serve static files
app.use(express.static(path.join(__dirname, "public")));
app.use(express.static(path.join(__dirname, 'public')));
// init sequalize
const sequelize = new Sequelize({
dialect: "sqlite",
storage: "database.sqlite",
dialect: 'sqlite',
storage: 'database.sqlite',
});
// "/"
const indexRoute = require("./routes/index");
app.use("/", indexRoute);
const indexRoute = require('./routes/index');
app.use('/', indexRoute);
// "auth"
const signUpRoute = require("./routes/auth/signup")(sequelize);
const signInRoute = require("./routes/auth/signin")(sequelize);
app.use("/auth", signUpRoute);
app.use("/auth", signInRoute);
const signUpRoute = require('./routes/auth/signup')(sequelize);
const signInRoute = require('./routes/auth/signin')(sequelize);
app.use('/auth', signUpRoute);
app.use('/auth', signInRoute);
// "/projects"
const projectsIndexRoute = require("./routes/projects/index")(sequelize);
const projectsShowRoute = require("./routes/projects/show")(sequelize);
const projectsNewRoute = require("./routes/projects/new")(sequelize);
const projectsEditRoute = require("./routes/projects/edit")(sequelize);
const projectsDeleteRoute = require("./routes/projects/delete")(sequelize);
app.use("/projects", projectsIndexRoute);
app.use("/projects", projectsShowRoute);
app.use("/projects", projectsNewRoute);
app.use("/projects", projectsEditRoute);
app.use("/projects", projectsDeleteRoute);
const projectsIndexRoute = require('./routes/projects/index')(sequelize);
const projectsShowRoute = require('./routes/projects/show')(sequelize);
const projectsNewRoute = require('./routes/projects/new')(sequelize);
const projectsEditRoute = require('./routes/projects/edit')(sequelize);
const projectsDeleteRoute = require('./routes/projects/delete')(sequelize);
app.use('/projects', projectsIndexRoute);
app.use('/projects', projectsShowRoute);
app.use('/projects', projectsNewRoute);
app.use('/projects', projectsEditRoute);
app.use('/projects', projectsDeleteRoute);
// "/folders"
const foldersIndexRoute = require("./routes/folders/index")(sequelize);
const foldersNewRoute = require("./routes/folders/new")(sequelize);
const foldersEditRoute = require("./routes/folders/edit")(sequelize);
const foldersDeleteRoute = require("./routes/folders/delete")(sequelize);
app.use("/folders", foldersIndexRoute);
app.use("/folders", foldersNewRoute);
app.use("/folders", foldersEditRoute);
app.use("/folders", foldersDeleteRoute);
const foldersIndexRoute = require('./routes/folders/index')(sequelize);
const foldersNewRoute = require('./routes/folders/new')(sequelize);
const foldersEditRoute = require('./routes/folders/edit')(sequelize);
const foldersDeleteRoute = require('./routes/folders/delete')(sequelize);
app.use('/folders', foldersIndexRoute);
app.use('/folders', foldersNewRoute);
app.use('/folders', foldersEditRoute);
app.use('/folders', foldersDeleteRoute);
// "/cases"
const casesIndexRoute = require("./routes/cases/index")(sequelize);
const casesShowRoute = require("./routes/cases/show")(sequelize);
const casesNewRoute = require("./routes/cases/new")(sequelize);
const casesEditRoute = require("./routes/cases/edit")(sequelize);
const casesDeleteRoute = require("./routes/cases/delete")(sequelize);
const casesBulkDeleteRoute = require("./routes/cases/bulkDelete")(sequelize);
app.use("/cases", casesIndexRoute);
app.use("/cases", casesShowRoute);
app.use("/cases", casesNewRoute);
app.use("/cases", casesEditRoute);
app.use("/cases", casesDeleteRoute);
app.use("/cases", casesBulkDeleteRoute);
const casesIndexRoute = require('./routes/cases/index')(sequelize);
const casesShowRoute = require('./routes/cases/show')(sequelize);
const casesNewRoute = require('./routes/cases/new')(sequelize);
const casesEditRoute = require('./routes/cases/edit')(sequelize);
const casesDeleteRoute = require('./routes/cases/delete')(sequelize);
const casesBulkDeleteRoute = require('./routes/cases/bulkDelete')(sequelize);
app.use('/cases', casesIndexRoute);
app.use('/cases', casesShowRoute);
app.use('/cases', casesNewRoute);
app.use('/cases', casesEditRoute);
app.use('/cases', casesDeleteRoute);
app.use('/cases', casesBulkDeleteRoute);
// "/steps"
const stepsNewRoute = require("./routes/steps/new")(sequelize);
const stepsDeleteRoute = require("./routes/steps/delete")(sequelize);
app.use("/steps", stepsNewRoute);
app.use("/steps", stepsDeleteRoute);
const stepsNewRoute = require('./routes/steps/new')(sequelize);
const stepsDeleteRoute = require('./routes/steps/delete')(sequelize);
app.use('/steps', stepsNewRoute);
app.use('/steps', stepsDeleteRoute);
// "/attachments"
const attachmentsNewRoute = require("./routes/attachments/new")(sequelize);
const attachmentsDeleteRoute = require("./routes/attachments/delete")(sequelize);
const attachmentsDownloadRoute = require("./routes/attachments/download")(sequelize);
app.use("/attachments", attachmentsNewRoute);
app.use("/attachments", attachmentsDeleteRoute);
app.use("/attachments", attachmentsDownloadRoute);
const attachmentsNewRoute = require('./routes/attachments/new')(sequelize);
const attachmentsDeleteRoute = require('./routes/attachments/delete')(sequelize);
const attachmentsDownloadRoute = require('./routes/attachments/download')(sequelize);
app.use('/attachments', attachmentsNewRoute);
app.use('/attachments', attachmentsDeleteRoute);
app.use('/attachments', attachmentsDownloadRoute);
// "/runs"
const runsIndexRoute = require("./routes/runs/index")(sequelize);
const runsShowRoute = require("./routes/runs/show")(sequelize);
const runsNewRoute = require("./routes/runs/new")(sequelize);
const runsEditRoute = require("./routes/runs/edit")(sequelize);
const runDeleteRoute = require("./routes/runs/delete")(sequelize);
app.use("/runs", runsIndexRoute);
app.use("/runs", runsShowRoute);
app.use("/runs", runsNewRoute);
app.use("/runs", runsEditRoute);
app.use("/runs", runDeleteRoute);
const runsIndexRoute = require('./routes/runs/index')(sequelize);
const runsShowRoute = require('./routes/runs/show')(sequelize);
const runsNewRoute = require('./routes/runs/new')(sequelize);
const runsEditRoute = require('./routes/runs/edit')(sequelize);
const runDeleteRoute = require('./routes/runs/delete')(sequelize);
app.use('/runs', runsIndexRoute);
app.use('/runs', runsShowRoute);
app.use('/runs', runsNewRoute);
app.use('/runs', runsEditRoute);
app.use('/runs', runDeleteRoute);
// "/runcases"
const runCaseIndexRoute = require("./routes/runcases/index")(sequelize);
const runCaseNewRoute = require("./routes/runcases/new")(sequelize);
const runCaseEditRoute = require("./routes/runcases/edit")(sequelize);
const runCaseBuldNewRoute = require("./routes/runcases/bulkNew")(sequelize);
const runCaseDeleteRoute = require("./routes/runcases/delete")(sequelize);
const runCaseBulkDeleteRoute = require("./routes/runcases/bulkDelete")(sequelize);
app.use("/runcases", runCaseIndexRoute);
app.use("/runcases", runCaseNewRoute);
app.use("/runcases", runCaseEditRoute);
app.use("/runcases", runCaseBuldNewRoute);
app.use("/runcases", runCaseDeleteRoute);
app.use("/runcases", runCaseBulkDeleteRoute);
const runCaseIndexRoute = require('./routes/runcases/index')(sequelize);
const runCaseNewRoute = require('./routes/runcases/new')(sequelize);
const runCaseEditRoute = require('./routes/runcases/edit')(sequelize);
const runCaseBuldNewRoute = require('./routes/runcases/bulkNew')(sequelize);
const runCaseDeleteRoute = require('./routes/runcases/delete')(sequelize);
const runCaseBulkDeleteRoute = require('./routes/runcases/bulkDelete')(sequelize);
app.use('/runcases', runCaseIndexRoute);
app.use('/runcases', runCaseNewRoute);
app.use('/runcases', runCaseEditRoute);
app.use('/runcases', runCaseBuldNewRoute);
app.use('/runcases', runCaseDeleteRoute);
app.use('/runcases', runCaseBulkDeleteRoute);
// "/home"
const homeIndexRoute = require("./routes/home/index")(sequelize);
app.use("/home", homeIndexRoute);
const homeIndexRoute = require('./routes/home/index')(sequelize);
app.use('/home', homeIndexRoute);
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {

View File

@@ -31,4 +31,4 @@ module.exports = {
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('projects');
},
};
};

View File

@@ -42,7 +42,7 @@ module.exports = {
});
},
async down (queryInterface, Sequelize) {
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('folders');
}
},
};

View File

@@ -2,7 +2,7 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface, Sequelize) {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('runs', {
id: {
type: Sequelize.INTEGER,
@@ -37,16 +37,16 @@ module.exports = {
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
type: Sequelize.DATE,
},
});
},
async down (queryInterface, Sequelize) {
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('runs');
}
},
};

View File

@@ -2,7 +2,7 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface, Sequelize) {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('cases', {
id: {
type: Sequelize.INTEGER,
@@ -57,16 +57,16 @@ module.exports = {
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
type: Sequelize.DATE,
},
});
},
async down (queryInterface, Sequelize) {
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('cases');
}
},
};

View File

@@ -31,4 +31,4 @@ module.exports = {
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('steps');
},
};
};

View File

@@ -1,9 +1,9 @@
"use strict";
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("caseSteps", {
await queryInterface.createTable('caseSteps', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
@@ -12,20 +12,20 @@ module.exports = {
caseId: {
type: Sequelize.INTEGER,
references: {
model: "cases",
key: "id",
model: 'cases',
key: 'id',
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
stepId: {
type: Sequelize.INTEGER,
references: {
model: "steps",
key: "id",
model: 'steps',
key: 'id',
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
stepNo: {
type: Sequelize.INTEGER,
@@ -41,12 +41,12 @@ module.exports = {
},
});
await queryInterface.addIndex("caseSteps", ["caseId", "stepId"], {
await queryInterface.addIndex('caseSteps', ['caseId', 'stepId'], {
unique: true,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("caseSteps");
await queryInterface.dropTable('caseSteps');
},
};

View File

@@ -2,7 +2,7 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface, Sequelize) {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('attachments', {
id: {
type: Sequelize.INTEGER,
@@ -23,16 +23,16 @@ module.exports = {
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
type: Sequelize.DATE,
},
});
},
async down (queryInterface, Sequelize) {
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('attachments');
}
},
};

View File

@@ -1,9 +1,9 @@
"use strict";
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("caseAttachments", {
await queryInterface.createTable('caseAttachments', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
@@ -12,20 +12,20 @@ module.exports = {
caseId: {
type: Sequelize.INTEGER,
references: {
model: "cases",
key: "id",
model: 'cases',
key: 'id',
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
attachmentId: {
type: Sequelize.INTEGER,
references: {
model: "attachments",
key: "id",
model: 'attachments',
key: 'id',
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
createdAt: {
type: Sequelize.DATE,
@@ -37,12 +37,12 @@ module.exports = {
},
});
await queryInterface.addIndex("caseAttachments", ["caseId", "attachmentId"], {
await queryInterface.addIndex('caseAttachments', ['caseId', 'attachmentId'], {
unique: true,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("caseAttachments");
await queryInterface.dropTable('caseAttachments');
},
};

View File

@@ -1,9 +1,9 @@
"use strict";
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("runCases", {
await queryInterface.createTable('runCases', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
@@ -12,20 +12,20 @@ module.exports = {
runId: {
type: Sequelize.INTEGER,
references: {
model: "runs",
key: "id",
model: 'runs',
key: 'id',
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: "cases",
key: "id",
model: 'cases',
key: 'id',
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
status: {
type: Sequelize.INTEGER,
@@ -41,12 +41,12 @@ module.exports = {
},
});
await queryInterface.addIndex("runCases", ["runId", "caseId"], {
await queryInterface.addIndex('runCases', ['runId', 'caseId'], {
unique: true,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("runCases");
await queryInterface.dropTable('runCases');
},
};

View File

@@ -1,9 +1,9 @@
"use strict";
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("users", {
await queryInterface.createTable('users', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
@@ -12,7 +12,7 @@ module.exports = {
email: {
type: Sequelize.STRING,
allowNull: false,
unique: true
unique: true,
},
password: {
type: Sequelize.STRING,
@@ -41,6 +41,6 @@ module.exports = {
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("users");
await queryInterface.dropTable('users');
},
};

View File

@@ -1,5 +1,5 @@
function defineAttachment(sequelize, DataTypes) {
const Attachment = sequelize.define("Attachment", {
const Attachment = sequelize.define('Attachment', {
title: {
type: DataTypes.STRING,
allowNull: false,
@@ -16,7 +16,7 @@ function defineAttachment(sequelize, DataTypes) {
Attachment.associate = (models) => {
Attachment.belongsToMany(models.Case, {
through: "caseAttachments"
through: 'caseAttachments',
});
};

View File

@@ -1,5 +1,5 @@
function defineCaseAttachment(sequelize, DataTypes) {
const CaseAttachment = sequelize.define("CaseAttachment", {
const CaseAttachment = sequelize.define('CaseAttachment', {
caseId: {
type: DataTypes.INTEGER,
allowNull: false,
@@ -12,12 +12,12 @@ function defineCaseAttachment(sequelize, DataTypes) {
CaseAttachment.associate = (models) => {
CaseAttachment.belongsTo(models.Case, {
foreignKey: "caseId",
onDelete: "CASCADE",
foreignKey: 'caseId',
onDelete: 'CASCADE',
});
CaseAttachment.belongsTo(models.Attachment, {
foreignKey: "attachmentId",
onDelete: "CASCADE",
foreignKey: 'attachmentId',
onDelete: 'CASCADE',
});
};

View File

@@ -1,5 +1,5 @@
function defineCaseStep(sequelize, DataTypes) {
const CaseStep = sequelize.define("CaseStep", {
const CaseStep = sequelize.define('CaseStep', {
caseId: {
type: DataTypes.INTEGER,
allowNull: false,
@@ -16,12 +16,12 @@ function defineCaseStep(sequelize, DataTypes) {
CaseStep.associate = (models) => {
CaseStep.belongsTo(models.Case, {
foreignKey: "caseId",
onDelete: "CASCADE",
foreignKey: 'caseId',
onDelete: 'CASCADE',
});
CaseStep.belongsTo(models.Step, {
foreignKey: "stepId",
onDelete: "CASCADE",
foreignKey: 'stepId',
onDelete: 'CASCADE',
});
};

View File

@@ -1,5 +1,5 @@
function defineCase(sequelize, DataTypes) {
const Case = sequelize.define("Case", {
const Case = sequelize.define('Case', {
title: {
type: DataTypes.STRING,
allowNull: false,
@@ -40,20 +40,20 @@ function defineCase(sequelize, DataTypes) {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: "folder",
key: "id",
model: 'folder',
key: 'id',
},
onDelete: "CASCADE",
onDelete: 'CASCADE',
},
});
Case.associate = (models) => {
Case.belongsTo(models.Folder, {
foreignKey: "folderId",
onDelete: "CASCADE",
foreignKey: 'folderId',
onDelete: 'CASCADE',
});
Case.belongsToMany(models.Step, {
through: "caseSteps"
through: 'caseSteps',
});
};

View File

@@ -1,5 +1,5 @@
function defineFolder(sequelize, DataTypes) {
const Folder = sequelize.define("Folder", {
const Folder = sequelize.define('Folder', {
name: {
type: DataTypes.STRING,
allowNull: false,
@@ -17,10 +17,10 @@ function defineFolder(sequelize, DataTypes) {
allowNull: false,
references: {
model: 'project',
key: 'id'
key: 'id',
},
onDelete: 'CASCADE'
}
onDelete: 'CASCADE',
},
});
Folder.associate = (models) => {

View File

@@ -1,40 +1,27 @@
"use strict";
'use strict';
const fs = require("fs");
const path = require("path");
const Sequelize = require("sequelize");
const process = require("process");
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const process = require('process');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || "development";
const config = require(__dirname + "/../config/config.json")[env];
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};
let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(
config.database,
config.username,
config.password,
config
);
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs.readdirSync(__dirname)
.filter((file) => {
return (
file.indexOf(".") !== 0 &&
file !== basename &&
file.slice(-3) === ".js" &&
file.indexOf(".test.js") === -1
);
return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js' && file.indexOf('.test.js') === -1;
})
.forEach((file) => {
const model = require(path.join(__dirname, file))(
sequelize,
Sequelize.DataTypes
);
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});

View File

@@ -1,5 +1,5 @@
function defineProject(sequelize, DataTypes) {
const Project = sequelize.define("Project", {
const Project = sequelize.define('Project', {
name: {
type: DataTypes.STRING,
allowNull: false,
@@ -11,7 +11,7 @@ function defineProject(sequelize, DataTypes) {
});
Project.associate = (models) => {
Project.hasMany(models.Folder, { foreignKey: "projectId" });
Project.hasMany(models.Folder, { foreignKey: 'projectId' });
};
return Project;

View File

@@ -1,5 +1,5 @@
function defineRunCase(sequelize, DataTypes) {
const RunCase = sequelize.define("RunCase", {
const RunCase = sequelize.define('RunCase', {
runId: {
type: DataTypes.INTEGER,
allowNull: false,
@@ -16,12 +16,12 @@ function defineRunCase(sequelize, DataTypes) {
RunCase.associate = (models) => {
RunCase.belongsTo(models.Run, {
foreignKey: "runId",
onDelete: "CASCADE",
foreignKey: 'runId',
onDelete: 'CASCADE',
});
RunCase.belongsTo(models.Case, {
foreignKey: "caseId",
onDelete: "CASCADE",
foreignKey: 'caseId',
onDelete: 'CASCADE',
});
};

View File

@@ -21,10 +21,10 @@ function defineRun(sequelize, DataTypes) {
allowNull: false,
references: {
model: 'project',
key: 'id'
key: 'id',
},
onDelete: 'CASCADE'
}
onDelete: 'CASCADE',
},
});
Run.associate = (models) => {
@@ -34,4 +34,4 @@ function defineRun(sequelize, DataTypes) {
return Run;
}
module.exports = defineRun;
module.exports = defineRun;

View File

@@ -1,5 +1,5 @@
function defineStep(sequelize, DataTypes) {
const Step = sequelize.define("Step", {
const Step = sequelize.define('Step', {
step: {
type: DataTypes.STRING,
allowNull: false,
@@ -12,7 +12,7 @@ function defineStep(sequelize, DataTypes) {
Step.associate = (models) => {
Step.belongsToMany(models.Case, {
through: "caseSteps"
through: 'caseSteps',
});
};

View File

@@ -1,5 +1,5 @@
function defineUser(sequelize, DataTypes) {
const User = sequelize.define("User", {
const User = sequelize.define('User', {
email: {
type: DataTypes.STRING,
allowNull: false,

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const path = require("path");
const fs = require("fs");
const defineAttachment = require("../../models/attachments");
const { DataTypes } = require("sequelize");
const path = require('path');
const fs = require('fs');
const defineAttachment = require('../../models/attachments');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Attachment = defineAttachment(sequelize, DataTypes);
router.delete("/:attachmentId", async (req, res) => {
router.delete('/:attachmentId', async (req, res) => {
const attachmentId = req.params.attachmentId;
const t = await sequelize.transaction();
@@ -16,19 +16,19 @@ module.exports = function (sequelize) {
const attachment = await Attachment.findByPk(attachmentId);
if (!attachment) {
await t.rollback();
return res.status(404).send("Attachment not found");
return res.status(404).send('Attachment not found');
}
// delete file from folder
const uploadDir = path.join(__dirname, "../../public/uploads");
const uploadDir = path.join(__dirname, '../../public/uploads');
const url = attachment.path;
const fileName = url.substring(url.lastIndexOf("/") + 1);
const fileName = url.substring(url.lastIndexOf('/') + 1);
const filePath = path.join(uploadDir, fileName);
fs.unlink(filePath, (err) => {
if (err) {
console.error('Error deleting file:', err);
t.rollback();
return res.status(404).send("Attachment not found");
return res.status(404).send('Attachment not found');
}
});
@@ -38,7 +38,7 @@ module.exports = function (sequelize) {
} catch (error) {
console.error(error);
await t.rollback();
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,32 +1,32 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const path = require("path");
const fs = require("fs");
const defineAttachment = require("../../models/attachments");
const { DataTypes } = require("sequelize");
const path = require('path');
const fs = require('fs');
const defineAttachment = require('../../models/attachments');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Attachment = defineAttachment(sequelize, DataTypes);
router.get("/download/:attachmentId", async (req, res) => {
router.get('/download/:attachmentId', async (req, res) => {
const attachmentId = req.params.attachmentId;
try {
const attachment = await Attachment.findByPk(attachmentId);
if (!attachment) {
return res.status(404).send("Attachment not found");
return res.status(404).send('Attachment not found');
}
const filename = attachment.path.split("/").pop();
const filename = attachment.path.split('/').pop();
const filePath = path.join(__dirname, `../../public/uploads/${filename}`);
if (!fs.existsSync(filePath)) {
return res.status(404).json({ error: "File not found" });
return res.status(404).json({ error: 'File not found' });
}
res.download(filePath);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,18 +1,18 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const path = require("path");
const fs = require("fs");
const multer = require("multer");
const defineAttachment = require("../../models/attachments");
const defineCaseAttachment = require("../../models/caseAttachments");
const { DataTypes } = require("sequelize");
const path = require('path');
const fs = require('fs');
const multer = require('multer');
const defineAttachment = require('../../models/attachments');
const defineCaseAttachment = require('../../models/caseAttachments');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Attachment = defineAttachment(sequelize, DataTypes);
const CaseAttachment = defineCaseAttachment(sequelize, DataTypes);
// Create uploads folder if it does not exist
const uploadDir = path.join(__dirname, "../../public/uploads");
const uploadDir = path.join(__dirname, '../../public/uploads');
if (!fs.existsSync(uploadDir)) {
fs.mkdirSync(uploadDir, { recursive: true });
}
@@ -46,16 +46,16 @@ module.exports = function (sequelize) {
const upload = multer({ storage });
router.post("/", upload.array("files", 10), async (req, res) => {
router.post('/', upload.array('files', 10), async (req, res) => {
const t = await sequelize.transaction();
try {
const caseId = req.query.parentCaseId;
const files = req.files;
if (files.length === 0) {
return res.status(400).json({ error: "No files uploaded" });
return res.status(400).json({ error: 'No files uploaded' });
}
const host = req.get("host");
const host = req.get('host');
const protocol = req.protocol;
const attachmentsData = files.map((file) => ({
title: file.originalname,
@@ -75,7 +75,7 @@ module.exports = function (sequelize) {
res.json(newAttachments);
} catch (error) {
await t.rollback();
res.status(500).json({ error: "Internal server error" });
res.status(500).json({ error: 'Internal server error' });
}
});

View File

@@ -1,2 +1,2 @@
const roles = [{ uid: "admin" }, { uid: "moderator" }, { uid: "user" }];
const roles = [{ uid: 'admin' }, { uid: 'moderator' }, { uid: 'user' }];
module.exports = roles;

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineUser = require("../../models/users");
const { DataTypes } = require("sequelize");
const defineUser = require('../../models/users');
const { DataTypes } = require('sequelize');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
module.exports = function (sequelize) {
const User = defineUser(sequelize, DataTypes);
router.post("/signin", async (req, res) => {
router.post('/signin', async (req, res) => {
try {
const { email, password } = req.body;
const user = await User.findOne({
@@ -17,20 +17,20 @@ module.exports = function (sequelize) {
},
});
if (!user) {
return res.status(401).json({ error: "Authentication failed" });
return res.status(401).json({ error: 'Authentication failed' });
}
const passwordMatch = await bcrypt.compare(password, user.password);
if (!passwordMatch) {
return res.status(401).json({ error: "Authentication failed" });
return res.status(401).json({ error: 'Authentication failed' });
}
const accessToken = jwt.sign({ userId: user.id }, "your-secret-key", {
expiresIn: "1h",
const accessToken = jwt.sign({ userId: user.id }, 'your-secret-key', {
expiresIn: '1h',
});
res.status(200).json({ access_token: accessToken, user });
} catch (error) {
console.error(error);
res.status(500).send("Sign up failed");
res.status(500).send('Sign up failed');
}
});

View File

@@ -1,15 +1,15 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineUser = require("../../models/users");
const { DataTypes } = require("sequelize");
const roles = require("./roles");
const bcrypt = require("bcrypt");
const jwt = require("jsonwebtoken");
const defineUser = require('../../models/users');
const { DataTypes } = require('sequelize');
const roles = require('./roles');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
module.exports = function (sequelize) {
const User = defineUser(sequelize, DataTypes);
router.post("/signup", async (req, res) => {
router.post('/signup', async (req, res) => {
try {
const { email, password, username, avatarPath } = req.body;
const hashedPassword = await bcrypt.hash(password, 10);
@@ -17,8 +17,8 @@ module.exports = function (sequelize) {
const userCount = await User.count();
const initialRole =
userCount > 0
? roles.findIndex((entry) => entry.uid === "user")
: roles.findIndex((entry) => entry.uid === "admin");
? roles.findIndex((entry) => entry.uid === 'user')
: roles.findIndex((entry) => entry.uid === 'admin');
const user = await User.create({
email,
@@ -28,15 +28,15 @@ module.exports = function (sequelize) {
avatarPath: avatarPath,
});
const accessToken = jwt.sign({ userId: user.id }, "your-secret-key", {
expiresIn: "1h",
const accessToken = jwt.sign({ userId: user.id }, 'your-secret-key', {
expiresIn: '1h',
});
user.password = undefined;
res.status(200).json({ access_token: accessToken, user });
} catch (error) {
console.error(error);
res.status(500).send("Sign up failed");
res.status(500).send('Sign up failed');
}
});

View File

@@ -1,15 +1,15 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineCase = require("../../models/cases");
const { DataTypes } = require("sequelize");
const defineCase = require('../../models/cases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
router.post("/bulkdelete", async (req, res) => {
router.post('/bulkdelete', async (req, res) => {
const { caseIds } = req.body;
if (!caseIds || !Array.isArray(caseIds)) {
return res.status(400).send("Invalid caseIds array");
return res.status(400).send('Invalid caseIds array');
}
try {
@@ -17,7 +17,7 @@ module.exports = function (sequelize) {
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,23 +1,23 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineCase = require("../../models/cases");
const { DataTypes } = require("sequelize");
const defineCase = require('../../models/cases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
router.delete("/:caseId", async (req, res) => {
router.delete('/:caseId', async (req, res) => {
const caseId = req.params.caseId;
try {
const testcase = await Case.findByPk(caseId);
if (!testcase) {
return res.status(404).send("Case not found");
return res.status(404).send('Case not found');
}
await testcase.destroy();
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,20 +1,20 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineCase = require("../../models/cases");
const defineStep = require("../../models/steps");
const { DataTypes } = require("sequelize");
const defineCase = require('../../models/cases');
const defineStep = require('../../models/steps');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
const Step = defineStep(sequelize, DataTypes);
router.put("/:caseId", async (req, res) => {
router.put('/:caseId', async (req, res) => {
const caseId = req.params.caseId;
const updateCase = req.body;
try {
const testcase = await Case.findByPk(caseId);
if (!testcase) {
return res.status(404).send("Case not found");
return res.status(404).send('Case not found');
}
// if Case has Steps, update Steps as well
@@ -36,7 +36,7 @@ module.exports = function (sequelize) {
res.json(testcase);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,16 +1,16 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineCase = require("../../models/cases");
const { DataTypes } = require("sequelize");
const defineCase = require('../../models/cases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
router.get("/", async (req, res) => {
router.get('/', async (req, res) => {
const { folderId } = req.query;
if (!folderId) {
return res.status(400).json({ error: "folderId is required" });
return res.status(400).json({ error: 'folderId is required' });
}
try {
@@ -22,7 +22,7 @@ module.exports = function (sequelize) {
res.json(cases);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,17 +1,9 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineCase = require("../../models/cases");
const { DataTypes } = require("sequelize");
const defineCase = require('../../models/cases');
const { DataTypes } = require('sequelize');
const requiredFields = [
"title",
"state",
"priority",
"type",
"automationStatus",
"template",
"folderId",
];
const requiredFields = ['title', 'state', 'priority', 'type', 'automationStatus', 'template', 'folderId'];
function isEmpty(value) {
if (value === null || value === undefined) {
@@ -24,7 +16,7 @@ function isEmpty(value) {
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
try {
if (
requiredFields.some((field) => {
@@ -32,8 +24,7 @@ module.exports = function (sequelize) {
})
) {
return res.status(400).json({
error:
"Title, state, priority, type, automationStatus, template, and folderId are required",
error: 'Title, state, priority, type, automationStatus, template, and folderId are required',
});
}
@@ -65,7 +56,7 @@ module.exports = function (sequelize) {
res.json(newCase);
} catch (error) {
res.status(500).json({ error: "Internal server error" });
res.status(500).json({ error: 'Internal server error' });
}
});

View File

@@ -1,24 +1,24 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineCase = require("../../models/cases");
const defineStep = require("../../models/steps");
const defineAttachment = require("../../models/attachments");
const { DataTypes } = require("sequelize");
const defineCase = require('../../models/cases');
const defineStep = require('../../models/steps');
const defineAttachment = require('../../models/attachments');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
const Step = defineStep(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(Step, { through: 'caseSteps' });
Step.belongsToMany(Case, { through: 'caseSteps' });
Case.belongsToMany(Attachment, { through: 'caseAttachments' });
Attachment.belongsToMany(Case, { through: 'caseAttachments' });
router.get("/:caseId", async (req, res) => {
router.get('/:caseId', async (req, res) => {
const caseId = req.params.caseId;
if (!caseId) {
return res.status(400).json({ error: "caseId is required" });
return res.status(400).json({ error: 'caseId is required' });
}
try {
@@ -26,7 +26,7 @@ module.exports = function (sequelize) {
include: [
{
model: Step,
through: { attributes: ["stepNo"] },
through: { attributes: ['stepNo'] },
},
{
model: Attachment,
@@ -36,7 +36,7 @@ module.exports = function (sequelize) {
return res.json(testcase);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,23 +1,23 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineFolder = require("../../models/folders");
const { DataTypes } = require("sequelize");
const defineFolder = require('../../models/folders');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Folder = defineFolder(sequelize, DataTypes);
router.delete("/:folderId", async (req, res) => {
router.delete('/:folderId', async (req, res) => {
const folderId = req.params.folderId;
try {
const folder = await Folder.findByPk(folderId);
if (!folder) {
return res.status(404).send("Folder not found");
return res.status(404).send('Folder not found');
}
await folder.destroy();
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,18 +1,18 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineFolder = require("../../models/folders");
const { DataTypes } = require("sequelize");
const defineFolder = require('../../models/folders');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Folder = defineFolder(sequelize, DataTypes);
router.put("/:folderId", async (req, res) => {
router.put('/:folderId', async (req, res) => {
const folderId = req.params.folderId;
const { name, detail, projectId, parentFolderId } = req.body;
try {
const folder = await Folder.findByPk(folderId);
if (!folder) {
return res.status(404).send("Folder not found");
return res.status(404).send('Folder not found');
}
await folder.update({
name,
@@ -23,7 +23,7 @@ module.exports = function (sequelize) {
res.json(folder);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineFolder = require('../../models/folders');
const { DataTypes } = require('sequelize');
module.exports = function(sequelize) {
const Folder = defineFolder(sequelize, DataTypes)
module.exports = function (sequelize) {
const Folder = defineFolder(sequelize, DataTypes);
router.get("/", async (req, res) => {
router.get('/', async (req, res) => {
const { projectId } = req.query;
if (!projectId) {
@@ -16,15 +16,15 @@ module.exports = function(sequelize) {
try {
const folders = await Folder.findAll({
where: {
projectId: projectId
}
projectId: projectId,
},
});
res.json(folders);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});
return router;
};
};

View File

@@ -1,18 +1,16 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineFolder = require("../../models/folders");
const { DataTypes } = require("sequelize");
const defineFolder = require('../../models/folders');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Folder = defineFolder(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
try {
const { name, detail, projectId, parentFolderId } = req.body;
if (!name || !projectId) {
return res
.status(400)
.json({ error: "Name and projectId are required" });
return res.status(400).json({ error: 'Name and projectId are required' });
}
const newFolder = await Folder.create({
@@ -24,7 +22,7 @@ module.exports = function (sequelize) {
res.json(newFolder);
} catch (error) {
res.status(500).json({ error: "Internal server error" });
res.status(500).json({ error: 'Internal server error' });
}
});

View File

@@ -1,11 +1,11 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineProject = require("../../models/projects");
const defineFolder = require("../../models/folders");
const defineCase = require("../../models/cases");
const defineRun = require("../../models/runs");
const defineRunCase = require("../../models/runCases");
const { DataTypes } = require("sequelize");
const defineProject = require('../../models/projects');
const defineFolder = require('../../models/folders');
const defineCase = require('../../models/cases');
const defineRun = require('../../models/runs');
const defineRunCase = require('../../models/runCases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Project = defineProject(sequelize, DataTypes);
@@ -13,16 +13,16 @@ module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
const Run = defineRun(sequelize, DataTypes);
const RunCase = defineRunCase(sequelize, DataTypes);
Project.hasMany(Folder, { foreignKey: "projectId" });
Folder.hasMany(Case, { foreignKey: "folderId" });
Project.hasMany(Run, { foreignKey: "projectId" });
Run.hasMany(RunCase, { foreignKey: "runId" });
Project.hasMany(Folder, { foreignKey: 'projectId' });
Folder.hasMany(Case, { foreignKey: 'folderId' });
Project.hasMany(Run, { foreignKey: 'projectId' });
Run.hasMany(RunCase, { foreignKey: 'runId' });
router.get("/:projectId", async (req, res) => {
router.get('/:projectId', async (req, res) => {
const projectId = req.params.projectId;
if (!projectId) {
return res.status(400).json({ error: "projectId is required" });
return res.status(400).json({ error: 'projectId is required' });
}
try {
@@ -36,12 +36,12 @@ module.exports = function (sequelize) {
],
});
if (!project) {
return res.status(404).send("Project not found");
return res.status(404).send('Project not found');
}
res.json(project);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,23 +1,23 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineProject = require("../../models/projects");
const { DataTypes } = require("sequelize");
const defineProject = require('../../models/projects');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Project = defineProject(sequelize, DataTypes);
router.delete("/:projectId", async (req, res) => {
router.delete('/:projectId', async (req, res) => {
const projectId = req.params.projectId;
try {
const project = await Project.findByPk(projectId);
if (!project) {
return res.status(404).send("Project not found");
return res.status(404).send('Project not found');
}
await project.destroy();
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,18 +1,18 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineProject = require("../../models/projects");
const { DataTypes } = require("sequelize");
const defineProject = require('../../models/projects');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Project = defineProject(sequelize, DataTypes);
router.put("/:projectId", async (req, res) => {
router.put('/:projectId', async (req, res) => {
const projectId = req.params.projectId;
const { name, detail } = req.body;
try {
const project = await Project.findByPk(projectId);
if (!project) {
return res.status(404).send("Project not found");
return res.status(404).send('Project not found');
}
await project.update({
name,
@@ -21,7 +21,7 @@ module.exports = function (sequelize) {
res.json(project);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,20 +1,20 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineProject = require('../../models/projects');
const { DataTypes } = require('sequelize');
module.exports = function(sequelize) {
const Project = defineProject(sequelize, DataTypes)
module.exports = function (sequelize) {
const Project = defineProject(sequelize, DataTypes);
router.get("/", async (req, res) => {
router.get('/', async (req, res) => {
try {
const projects = await Project.findAll();
res.json(projects);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});
return router;
};
};

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineProject = require("../../models/projects");
const { DataTypes } = require("sequelize");
const defineProject = require('../../models/projects');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Project = defineProject(sequelize, DataTypes)
const Project = defineProject(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
try {
const { name, detail } = req.body;
const newProject = await Project.create({
@@ -16,7 +16,7 @@ module.exports = function (sequelize) {
res.json(newProject);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,19 +1,19 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineProject = require("../../models/projects");
const defineFolder = require("../../models/folders");
const { DataTypes } = require("sequelize");
const defineProject = require('../../models/projects');
const defineFolder = require('../../models/folders');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Project = defineProject(sequelize, DataTypes);
const Folder = defineFolder(sequelize, DataTypes);
Project.hasMany(Folder, { foreignKey: "projectId" });
Project.hasMany(Folder, { foreignKey: 'projectId' });
router.get("/:projectId", async (req, res) => {
router.get('/:projectId', async (req, res) => {
const projectId = req.params.projectId;
if (!projectId) {
return res.status(400).json({ error: "projectId is required" });
return res.status(400).json({ error: 'projectId is required' });
}
try {
@@ -25,12 +25,12 @@ module.exports = function (sequelize) {
],
});
if (!project) {
return res.status(404).send("Project not found");
return res.status(404).send('Project not found');
}
res.json(project);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRunCase = require("../../models/runCases");
const { DataTypes, Op } = require("sequelize");
const defineRunCase = require('../../models/runCases');
const { DataTypes, Op } = require('sequelize');
module.exports = function (sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes);
router.post("/bulkdelete", async (req, res) => {
router.post('/bulkdelete', async (req, res) => {
const recordsToDelete = req.body;
try {
@@ -20,7 +20,7 @@ module.exports = function (sequelize) {
});
if (existingRunCases.length === 0) {
return res.status(200).send("No records found to delete");
return res.status(200).send('No records found to delete');
}
await RunCase.destroy({
@@ -32,10 +32,10 @@ module.exports = function (sequelize) {
},
});
res.status(200).send("Records deleted successfully");
res.status(200).send('Records deleted successfully');
} catch (error) {
console.error("Error deleting run cases:", error);
res.status(500).send("Internal Server Error");
console.error('Error deleting run cases:', error);
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRunCase = require("../../models/runCases");
const { DataTypes, Op } = require("sequelize");
const defineRunCase = require('../../models/runCases');
const { DataTypes, Op } = require('sequelize');
module.exports = function (sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes);
router.post("/bulknew", async (req, res) => {
router.post('/bulknew', async (req, res) => {
const recordsToCreate = req.body;
try {
@@ -22,9 +22,7 @@ module.exports = function (sequelize) {
// Filter out records that already exist
const recordsToCreateFiltered = recordsToCreate.filter((record) => {
return !existingRunCases.some(
(existingRecord) =>
existingRecord.runId == record.runId &&
existingRecord.caseId == record.caseId
(existingRecord) => existingRecord.runId == record.runId && existingRecord.caseId == record.caseId
);
});
@@ -39,7 +37,7 @@ module.exports = function (sequelize) {
res.json(newRunCases);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRunCase = require("../../models/runCases");
const { DataTypes } = require("sequelize");
const defineRunCase = require('../../models/runCases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes);
router.delete("/", async (req, res) => {
router.delete('/', async (req, res) => {
const runId = req.query.runId;
const caseId = req.query.caseId;
@@ -20,14 +20,14 @@ module.exports = function (sequelize) {
});
if (!deletingRunCase) {
return res.status(404).send("RunCase not found");
return res.status(404).send('RunCase not found');
}
await deletingRunCase.destroy();
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRunCase = require("../../models/runCases");
const { DataTypes } = require("sequelize");
const defineRunCase = require('../../models/runCases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes);
router.put("/", async (req, res) => {
router.put('/', async (req, res) => {
const runId = req.query.runId;
const caseId = req.query.caseId;
const status = req.query.status;
@@ -20,7 +20,7 @@ module.exports = function (sequelize) {
});
if (!runCase) {
return res.status(404).send("Runcase not found");
return res.status(404).send('Runcase not found');
}
await runCase.update({
@@ -31,7 +31,7 @@ module.exports = function (sequelize) {
res.json(runCase);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRunCase = require("../../models/runCases");
const defineRunCase = require('../../models/runCases');
const { DataTypes } = require('sequelize');
module.exports = function(sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes)
module.exports = function (sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes);
router.get("/", async (req, res) => {
router.get('/', async (req, res) => {
const { runId } = req.query;
if (!runId) {
@@ -16,15 +16,15 @@ module.exports = function(sequelize) {
try {
const runCases = await RunCase.findAll({
where: {
runId: runId
}
runId: runId,
},
});
res.json(runCases);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});
return router;
};
};

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRunCase = require("../../models/runCases");
const { DataTypes } = require("sequelize");
const defineRunCase = require('../../models/runCases');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const RunCase = defineRunCase(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
const runId = req.query.runId;
const caseId = req.query.caseId;
@@ -15,26 +15,24 @@ module.exports = function (sequelize) {
const existingRunCase = await RunCase.findOne({
where: {
runId: runId,
caseId: caseId
}
caseId: caseId,
},
});
if (existingRunCase) {
return res.status(400).send("Record already exists");
return res.status(400).send('Record already exists');
}
const newRunCase = await RunCase.create(
{
runId: runId,
caseId: caseId,
status: 0,
},
);
const newRunCase = await RunCase.create({
runId: runId,
caseId: caseId,
status: 0,
});
res.json(newRunCase);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,23 +1,23 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRun = require("../../models/runs");
const { DataTypes } = require("sequelize");
const defineRun = require('../../models/runs');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Run = defineRun(sequelize, DataTypes);
router.delete("/:runId", async (req, res) => {
router.delete('/:runId', async (req, res) => {
const runId = req.params.runId;
try {
const testrun = await Run.findByPk(runId);
if (!testrun) {
return res.status(404).send("Run not found");
return res.status(404).send('Run not found');
}
await testrun.destroy();
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,18 +1,18 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRun = require("../../models/runs");
const { DataTypes } = require("sequelize");
const defineRun = require('../../models/runs');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Run = defineRun(sequelize, DataTypes);
router.put("/:runId", async (req, res) => {
router.put('/:runId', async (req, res) => {
const runId = req.params.runId;
const updateRun = req.body;
try {
const testrun = await Run.findByPk(runId);
if (!testrun) {
return res.status(404).send("Run not found");
return res.status(404).send('Run not found');
}
delete updateRun.Steps;
@@ -20,7 +20,7 @@ module.exports = function (sequelize) {
res.json(testrun);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,12 +1,12 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRun = require("../../models/runs");
const defineRun = require('../../models/runs');
const { DataTypes } = require('sequelize');
module.exports = function(sequelize) {
const Run = defineRun(sequelize, DataTypes)
module.exports = function (sequelize) {
const Run = defineRun(sequelize, DataTypes);
router.get("/", async (req, res) => {
router.get('/', async (req, res) => {
const { projectId } = req.query;
if (!projectId) {
@@ -16,15 +16,15 @@ module.exports = function(sequelize) {
try {
const runs = await Run.findAll({
where: {
projectId: projectId
}
projectId: projectId,
},
});
res.json(runs);
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});
return router;
};
};

View File

@@ -1,18 +1,16 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRun = require("../../models/runs");
const { DataTypes } = require("sequelize");
const defineRun = require('../../models/runs');
const { DataTypes } = require('sequelize');
module.exports = function (sequelize) {
const Run = defineRun(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
try {
const { name, configurations, description, state, projectId } = req.body;
if (!name || !projectId) {
return res
.status(400)
.json({ error: "Name and projectId are required" });
return res.status(400).json({ error: 'Name and projectId are required' });
}
const newRun = await Run.create({
@@ -25,7 +23,7 @@ module.exports = function (sequelize) {
res.json(newRun);
} catch (error) {
res.status(500).json({ error: "Internal server error" });
res.status(500).json({ error: 'Internal server error' });
}
});

View File

@@ -1,39 +1,39 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineRun = require("../../models/runs");
const defineRunCase = require("../../models/runCases");
const { DataTypes, literal } = require("sequelize");
const defineRun = require('../../models/runs');
const defineRunCase = require('../../models/runCases');
const { DataTypes, literal } = require('sequelize');
module.exports = function (sequelize) {
const Run = defineRun(sequelize, DataTypes);
const RunCase = defineRunCase(sequelize, DataTypes);
router.get("/:runId", async (req, res) => {
router.get('/:runId', async (req, res) => {
const runId = req.params.runId;
if (!runId) {
return res.status(400).json({ error: "runId is required" });
return res.status(400).json({ error: 'runId is required' });
}
try {
const run = await Run.findByPk(runId);
if (!run) {
return res.status(404).send("Run not found");
return res.status(404).send('Run not found');
}
// Counts test case status belonging to the run
const statusCounts = await RunCase.findAll({
attributes: ["status", [literal("COUNT(*)"), "count"]],
attributes: ['status', [literal('COUNT(*)'), 'count']],
where: {
runId: run.id,
},
group: ["status"],
group: ['status'],
});
res.json({ run, statusCounts });
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineStep = require("../../models/steps");
const defineCaseStep = require("../../models/caseSteps");
const { DataTypes, Op } = require("sequelize");
const defineStep = require('../../models/steps');
const defineCaseStep = require('../../models/caseSteps');
const { DataTypes, Op } = require('sequelize');
module.exports = function (sequelize) {
const Step = defineStep(sequelize, DataTypes);
const CaseStep = defineCaseStep(sequelize, DataTypes);
router.delete("/:stepId", async (req, res) => {
router.delete('/:stepId', async (req, res) => {
const stepId = req.params.stepId;
// TODO The caseId should not be specified from the front end, but should be traced from stepId by association.
const caseId = req.query.parentCaseId;
@@ -19,7 +19,7 @@ module.exports = function (sequelize) {
const step = await Step.findByPk(stepId);
if (!step) {
await t.rollback();
return res.status(404).send("Step not found");
return res.status(404).send('Step not found');
}
// Get caseStep to be deleted.
@@ -32,7 +32,7 @@ module.exports = function (sequelize) {
// Decrease stepNo for all caseSteps with greater than the caseStep to be deleted.
await CaseStep.update(
{ stepNo: sequelize.literal("stepNo - 1") },
{ stepNo: sequelize.literal('stepNo - 1') },
{
where: {
CaseId: caseId,
@@ -51,7 +51,7 @@ module.exports = function (sequelize) {
} catch (error) {
console.error(error);
await t.rollback();
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineStep = require("../../models/steps");
const defineCaseStep = require("../../models/caseSteps");
const { DataTypes, Op } = require("sequelize");
const defineStep = require('../../models/steps');
const defineCaseStep = require('../../models/caseSteps');
const { DataTypes, Op } = require('sequelize');
module.exports = function (sequelize) {
const Step = defineStep(sequelize, DataTypes);
const CaseStep = defineCaseStep(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
const newStepNo = req.query.newStepNo;
const caseId = req.query.parentCaseId;
@@ -16,13 +16,13 @@ module.exports = function (sequelize) {
try {
// Update existing stepNo for steps with stepNo greater than or equal to newStepNo
const maxStepNo = await CaseStep.max("stepNo", {
const maxStepNo = await CaseStep.max('stepNo', {
where: { caseId: caseId },
transaction: t,
});
if (maxStepNo >= newStepNo) {
await CaseStep.update(
{ stepNo: sequelize.literal("stepNo + 1") },
{ stepNo: sequelize.literal('stepNo + 1') },
{
where: {
caseId: caseId,
@@ -35,8 +35,8 @@ module.exports = function (sequelize) {
const newStep = await Step.create(
{
step: "",
result: "",
step: '',
result: '',
},
{ transaction: t }
);
@@ -55,7 +55,7 @@ module.exports = function (sequelize) {
} catch (error) {
console.error(error);
await t.rollback();
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,58 +1,58 @@
"use strict";
const path = require("path");
const fs = require("fs");
'use strict';
const path = require('path');
const fs = require('fs');
module.exports = {
up: async (queryInterface, Sequelize) => {
// Add projects table records
await queryInterface.bulkInsert("Projects", [
await queryInterface.bulkInsert('Projects', [
{
name: "TestPlat Test",
name: 'TestPlat Test',
detail: "Test Plat's Manual test",
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "Iron Muscle App(筋トレアプリ)",
detail: "リリース前総合評価",
name: 'Iron Muscle App(筋トレアプリ)',
detail: 'リリース前総合評価',
createdAt: new Date(),
updatedAt: new Date(),
},
]);
// Add folders table records
await queryInterface.bulkInsert("folders", [
await queryInterface.bulkInsert('folders', [
{
name: "Account",
detail: "",
name: 'Account',
detail: '',
projectId: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "Contact",
detail: "",
name: 'Contact',
detail: '',
projectId: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "アカウント",
detail: "",
name: 'アカウント',
detail: '',
projectId: 2,
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "トレーニング記録",
detail: "",
name: 'トレーニング記録',
detail: '',
projectId: 2,
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "タイムライン",
detail: "",
name: 'タイムライン',
detail: '',
projectId: 2,
createdAt: new Date(),
updatedAt: new Date(),
@@ -60,30 +60,30 @@ module.exports = {
]);
// Add runs table records
await queryInterface.bulkInsert("runs", [
await queryInterface.bulkInsert('runs', [
{
name: "First Test Run",
name: 'First Test Run',
projectId: 1,
configurations: 1,
description: "5/14 - 5/31",
description: '5/14 - 5/31',
state: 4,
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "総合評価第一回",
name: '総合評価第一回',
projectId: 2,
configurations: 1,
description: "5/14 - 5/31",
description: '5/14 - 5/31',
state: 4,
createdAt: new Date(),
updatedAt: new Date(),
},
{
name: "総合評価第二回",
name: '総合評価第二回',
projectId: 2,
configurations: 1,
description: "6/1 - 6/12",
description: '6/1 - 6/12',
state: 1,
createdAt: new Date(),
updatedAt: new Date(),
@@ -91,171 +91,171 @@ module.exports = {
]);
// Add cases table records
await queryInterface.bulkInsert("cases", [
await queryInterface.bulkInsert('cases', [
{
title: "Signup",
title: 'Signup',
state: 1,
priority: 1,
type: 4,
automationStatus: 1,
description: "User can signup from signup form.",
description: 'User can signup from signup form.',
template: 1,
preConditions: "Not signed in",
expectedResults: "",
preConditions: 'Not signed in',
expectedResults: '',
folderId: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "Signin",
title: 'Signin',
state: 1,
priority: 1,
type: 4,
automationStatus: 1,
description: "User can signin from signin form.",
description: 'User can signin from signin form.',
template: 1,
preConditions: "Not signed in",
expectedResults: "",
preConditions: 'Not signed in',
expectedResults: '',
folderId: 1,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "Contact",
title: 'Contact',
state: 1,
priority: 1,
type: 4,
automationStatus: 1,
description: "User can send inquiry from 'contact us' form.",
template: 0,
preConditions: "",
expectedResults: "",
preConditions: '',
expectedResults: '',
folderId: 2,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "メールアドレスでのアカウント登録",
title: 'メールアドレスでのアカウント登録',
state: 1,
priority: 2,
type: 4,
automationStatus: 1,
description: "メールアドレス、パスワードをフォームに入力してサインアップボタンを押す",
description: 'メールアドレス、パスワードをフォームに入力してサインアップボタンを押す',
template: 0,
preConditions: "未サインイン状態であること。アカウントがないこと。",
expectedResults: "サインアップができ、自動でアカウントページに遷移する",
preConditions: '未サインイン状態であること。アカウントがないこと。',
expectedResults: 'サインアップができ、自動でアカウントページに遷移する',
folderId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "メールアドレスでのサインイン",
title: 'メールアドレスでのサインイン',
state: 1,
priority: 2,
type: 4,
automationStatus: 1,
description: "メールアドレス、パスワードをフォームに入力してサインインボタンを押す",
description: 'メールアドレス、パスワードをフォームに入力してサインインボタンを押す',
template: 0,
preConditions: "未サインイン状態であること",
expectedResults: "サインインができ、自動でアカウントページに遷移する",
preConditions: '未サインイン状態であること',
expectedResults: 'サインインができ、自動でアカウントページに遷移する',
folderId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "ソーシャルアカウントサインイン",
title: 'ソーシャルアカウントサインイン',
state: 1,
priority: 1,
type: 4,
automationStatus: 1,
description: "Googleアカウントで筋トレアプリにサインインできること",
description: 'Googleアカウントで筋トレアプリにサインインできること',
template: 0,
preConditions: "未サインイン状態であること",
expectedResults: "サインインでき、自動でアカウントページに遷移する",
preConditions: '未サインイン状態であること',
expectedResults: 'サインインでき、自動でアカウントページに遷移する',
folderId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "アカウント情報編集",
title: 'アカウント情報編集',
state: 1,
priority: 3,
type: 4,
automationStatus: 1,
description: "ユーザー名、アバター画像を変更できること",
description: 'ユーザー名、アバター画像を変更できること',
template: 0,
preConditions: "アバター画像(.png, .svg, .jpg)を用意する",
expectedResults: "アバター画像を登録できること",
preConditions: 'アバター画像(.png, .svg, .jpg)を用意する',
expectedResults: 'アバター画像を登録できること',
folderId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "アカウント閲覧",
title: 'アカウント閲覧',
state: 1,
priority: 0,
type: 1,
automationStatus: 1,
description: "ほかの人のアカウント情報は見れないこと",
description: 'ほかの人のアカウント情報は見れないこと',
template: 1,
preConditions: "特になし",
expectedResults: "",
preConditions: '特になし',
expectedResults: '',
folderId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "筋トレ記録(部位選択)",
title: '筋トレ記録(部位選択)',
state: 1,
priority: 2,
type: 1,
automationStatus: 1,
description: "部位選択",
description: '部位選択',
template: 1,
preConditions: "特になし",
expectedResults: "筋トレ部位を選択できること",
preConditions: '特になし',
expectedResults: '筋トレ部位を選択できること',
folderId: 4,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "筋トレ記録(回数選択)",
title: '筋トレ記録(回数選択)',
state: 1,
priority: 2,
type: 1,
automationStatus: 1,
description: "回数選択",
description: '回数選択',
template: 1,
preConditions: "特になし",
expectedResults: "筋トレ回数を選択できること",
preConditions: '特になし',
expectedResults: '筋トレ回数を選択できること',
folderId: 4,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "筋トレ記録 ダイアログのクローズ",
title: '筋トレ記録 ダイアログのクローズ',
state: 1,
priority: 3,
type: 3,
automationStatus: 1,
description: "選択ダイアログの機能性確認",
description: '選択ダイアログの機能性確認',
template: 1,
preConditions: "ダイアログを開く",
expectedResults: "ダイアログの「×」ボタンを押して閉じれること",
preConditions: 'ダイアログを開く',
expectedResults: 'ダイアログの「×」ボタンを押して閉じれること',
folderId: 4,
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "筋トレ記録 選択ダイアログ",
title: '筋トレ記録 選択ダイアログ',
state: 1,
priority: 3,
type: 3,
automationStatus: 1,
description: "選択ダイアログのレスポンシブ確認",
description: '選択ダイアログのレスポンシブ確認',
template: 1,
preConditions: "スマホでウェブサイトにアクセスする",
expectedResults: "ダイアログの表示がおかしくないこと",
preConditions: 'スマホでウェブサイトにアクセスする',
expectedResults: 'ダイアログの表示がおかしくないこと',
folderId: 4,
createdAt: new Date(),
updatedAt: new Date(),
@@ -263,47 +263,47 @@ module.exports = {
]);
// Add steps table records
await queryInterface.bulkInsert("steps", [
await queryInterface.bulkInsert('steps', [
{
step: "Check accout status",
result: "Never have account",
step: 'Check accout status',
result: 'Never have account',
createdAt: new Date(),
updatedAt: new Date(),
},
{
step: "Enter signup form and then, click 'signup' button.",
result: "Automatically redirect to the account page",
result: 'Automatically redirect to the account page',
createdAt: new Date(),
updatedAt: new Date(),
},
{
step: "Check signin status",
result: "Not signed in",
step: 'Check signin status',
result: 'Not signed in',
createdAt: new Date(),
updatedAt: new Date(),
},
{
step: "Enter signin form and then, click 'signin button.'",
result: "Automatically redirect to the account page",
result: 'Automatically redirect to the account page',
createdAt: new Date(),
updatedAt: new Date(),
},
{
step: "ブラウザのシークレットモードに入る",
result: "開発者モードのLocal Storageを開き、sessionがないことを確認する。",
step: 'ブラウザのシークレットモードに入る',
result: '開発者モードのLocal Storageを開き、sessionがないことを確認する。',
createdAt: new Date(),
updatedAt: new Date(),
},
{
step: "'account/userinfo?userid=xxx'に遷移する",
result: "エラーページにリダイレクトされ、403エラーなこと。",
result: 'エラーページにリダイレクトされ、403エラーなこと。',
createdAt: new Date(),
updatedAt: new Date(),
},
]);
// Add case-step join table
await queryInterface.bulkInsert("caseSteps", [
await queryInterface.bulkInsert('caseSteps', [
{
caseId: 1,
stepId: 1,
@@ -338,7 +338,8 @@ module.exports = {
stepNo: 1,
createdAt: new Date(),
updatedAt: new Date(),
}, {
},
{
caseId: 8,
stepId: 6,
stepNo: 2,
@@ -347,28 +348,28 @@ module.exports = {
},
]);
await queryInterface.bulkInsert("attachments", [
await queryInterface.bulkInsert('attachments', [
{
title: "Selenium logo",
detail: "",
path: "http://localhost:3001/uploads/861px-Selenium_Logo.png",
title: 'Selenium logo',
detail: '',
path: 'http://localhost:3001/uploads/861px-Selenium_Logo.png',
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: "vitest logo",
detail: "",
path: "http://localhost:3001/uploads/logo-shadow.svg",
title: 'vitest logo',
detail: '',
path: 'http://localhost:3001/uploads/logo-shadow.svg',
createdAt: new Date(),
updatedAt: new Date(),
},
]);
// copy sample files to uploads folder
const sampleFolderPath = "public/sample";
const uploadsFolderPath = "public/uploads";
const SeleniumLogoFileName = "861px-Selenium_Logo.png";
const vitestLogoFileName = "logo-shadow.svg";
const sampleFolderPath = 'public/sample';
const uploadsFolderPath = 'public/uploads';
const SeleniumLogoFileName = '861px-Selenium_Logo.png';
const vitestLogoFileName = 'logo-shadow.svg';
if (!fs.existsSync(uploadsFolderPath)) {
fs.mkdirSync(uploadsFolderPath, { recursive: true });
}
@@ -381,17 +382,13 @@ module.exports = {
}
}
);
fs.copyFile(
`${sampleFolderPath}/${vitestLogoFileName}`,
`${uploadsFolderPath}/${vitestLogoFileName}`,
(err) => {
if (err) {
console.log(err);
}
fs.copyFile(`${sampleFolderPath}/${vitestLogoFileName}`, `${uploadsFolderPath}/${vitestLogoFileName}`, (err) => {
if (err) {
console.log(err);
}
);
});
await queryInterface.bulkInsert("caseAttachments", [
await queryInterface.bulkInsert('caseAttachments', [
{
caseId: 1,
attachmentId: 1,
@@ -406,7 +403,7 @@ module.exports = {
},
]);
await queryInterface.bulkInsert("runCases", [
await queryInterface.bulkInsert('runCases', [
{
runId: 1,
caseId: 1,