Implemented test run update
This commit is contained in:
@@ -81,10 +81,12 @@ app.use("/attachments", attachmentsDownloadRoute);
|
||||
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 PORT = process.env.PORT || 3001;
|
||||
|
||||
28
backend/routes/runs/edit.js
Normal file
28
backend/routes/runs/edit.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const { DataTypes } = require("sequelize");
|
||||
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
delete updateRun.Steps;
|
||||
await testrun.update(updateRun);
|
||||
res.json(testrun);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal Server Error");
|
||||
}
|
||||
});
|
||||
|
||||
return router;
|
||||
};
|
||||
@@ -87,7 +87,7 @@ async function updateRun(updateTestRun: RunType) {
|
||||
body: JSON.stringify(updateTestRun),
|
||||
};
|
||||
|
||||
const url = `${apiServer}/cases/${updateTestRun.id}`;
|
||||
const url = `${apiServer}/runs/${updateTestRun.id}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, fetchOptions);
|
||||
|
||||
Reference in New Issue
Block a user