Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not show scenarios from other stories, add "create first scenario" in story editor, refactored some css, removed some console logs #796

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,911 changes: 1,450 additions & 1,461 deletions backend/src/database/DbServices.js

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions backend/src/helpers/projectManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ function checkAndAddSuffix(name, conflictingNameList) {

// Add the new name (with or without suffix) to the list
conflictingNameList.push(newName);
console.log(conflictingNameList);
return newName;
}

Expand Down Expand Up @@ -473,10 +472,8 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
});
const repoJsonData = zip.readAsText("repo.json");
const repoData = JSON.parse(repoJsonData);
console.log(repoData);
const mappingJsonData = zip.readAsText("keyStoryIds.json");
const mappingData = JSON.parse(mappingJsonData);
console.log(mappingData);
const repoBlocksJsonData = zip.readAsText("repoBlocks.json");
const repoBlocksData = JSON.parse(repoBlocksJsonData);
let groupMapping = [];
Expand All @@ -500,7 +497,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
existingName: title,
associatedID: _id.toHexString(),
}));
console.log(existingNames);

const newData = existingNames.map(({ existingName }) => existingName);
existingNameList = existingNameList.concat(newData);
for (const storyFile of storyFiles) {
Expand All @@ -526,7 +523,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
existingName: name,
associatedID: _id.toHexString(),
}));
console.log(existingNames);

const newData = existingNames.map(({ existingName }) => existingName);
existingNameList = existingNameList.concat(newData);
for (const singularBlock of repoBlocksData) {
Expand All @@ -550,7 +547,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
existingName: name,
associatedID: _id.toHexString(),
}));
console.log(existingNames);

const newData = existingNames.map(({ existingName }) => existingName);
existingNameList = existingNameList.concat(newData);
for (const groupFile of groupFiles) {
Expand Down Expand Up @@ -673,7 +670,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
client,
file
);
console.log(groupMapping);

await mongo.importBlocks(
true,
newRepo.toHexString(),
Expand Down
5 changes: 2 additions & 3 deletions backend/src/helpers/reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async function createReport(res, reportName: string) {//TODO remove res here pus
try {
fs.writeFileSync(resolvedPath, report.jsonReport);
} catch (error) {
console.log('Error:', error);
console.error('Error:', error);
}

reporter.generate(setOptions(reportName));
Expand Down Expand Up @@ -344,7 +344,7 @@ function scenarioResult(scenarioReport: any, scenario: any) {
function deleteReport(jsonReport: string) {
const report = path.normalize(`${reportPath}${jsonReport}`);
fs.unlink(report, (err) => {
if (err) console.log(err);
if (err) console.error(err);
else console.log(`${report} deleted.`);
});
}
Expand All @@ -355,7 +355,6 @@ async function fetchFiles(stories, repoId){
.flatMap(scen => scen.stepDefinitions.when)
.filter(step => step.type === "Upload File")
.map(step => step.values[0]);
console.log(neededFiles)
if (neededFiles) return mongo.getFiles(neededFiles, repoId)
}

Expand Down
15 changes: 7 additions & 8 deletions backend/src/serverHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ function jsUcfirst(string) {
// Building feature file step-content
function getSteps(steps, stepType) {
let data = '';
console.log(steps)
for (const step of steps) {
// eslint-disable-next-line no-continue
if (step.deactivated) continue;
data += `${jsUcfirst(stepType)} `;
if ((step.values[0]) != null && (step.values[0]) !== 'User') {
data += `${step.pre} '${step.values[0]}' ${Boolean(step.mid) ? step.mid : ''}${Boolean(step.values[1]) ? `'${step.values[1]}'` : ''}`;
if (Boolean(step.post)) data += ` ${step.post}${Boolean(step.values[2]) ? `'${step.values[2]}'` : ''}`;
data += `${step.pre} '${step.values[0]}' ${step.mid ? step.mid : ''}${step.values[1] ? `'${step.values[1]}'` : ''}`;
if (step.post) data += ` ${step.post}${step.values[2] ? `'${step.values[2]}'` : ''}`;
} else if ((step.values[0]) === 'User') data += `${step.pre} '${step.values[0]}'`;
else {
data += `${step.pre} ${step.mid}${getValues(step.values)}`;
if (Boolean(step.post)) data += ` ${step.post}`;
if (step.post) data += ` ${step.post}`;
}
data += '\n';
}
Expand All @@ -78,7 +77,7 @@ function getExamples(steps) {
for (let k = 0; k < steps[i].values.length; k++) data += `${steps[i].values[k]} | `;
}
// if no lines other than value line, return empty
if (data.split('\n').length > 2) data = 'Examples:' + data;
if (data.split('\n').length > 2) data = `Examples:${data}`;
else return ''; // explicit return as first line (title/name/key) is always written
return `${data}\n`;
}
Expand Down Expand Up @@ -106,7 +105,7 @@ function getScenarioContent(scenarios, storyID) {
// Building feature file story-name-content (feature file title)
function getFeatureContent(story) {
let body = '';
if (Boolean(story.body)) {
if (story.body) {
body = story.body.replaceAll('#', '').replaceAll('(/)', '');
}
let data = `Feature: ${story.title}\n\n${body}\n\n`;
Expand Down Expand Up @@ -417,7 +416,7 @@ async function replaceRefBlocks(scenarios) {
if (!elem._blockReferenceId) return [elem];
return mongo.getBlock(elem._blockReferenceId).then((block) => {
// Get an array of the values of the given, when, then properties
const steps = [...block.stepDefinitions.given, ...block.stepDefinitions.when, ...block.stepDefinitions.then]
const steps = [...block.stepDefinitions.given, ...block.stepDefinitions.when, ...block.stepDefinitions.then];
// Flatten array
return steps.flat(1);
});
Expand Down Expand Up @@ -664,4 +663,4 @@ module.exports = {
exportSingleFeatureFile,
exportProjectFeatureFiles,
applySpecialCommands
};
};
4 changes: 2 additions & 2 deletions backend/src/serverRouter/backgroundRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ router
extended: true
}))
.use((_, __, next) => {
console.log('Time of github request:', Date.now());
console.log('Time of background router request:', Date.now());
next();
})
.use((req, res, next) => {
Expand Down Expand Up @@ -57,4 +57,4 @@ router.delete('/:storyID', async (req, res) => {
}
});

module.exports = router;
module.exports = router;
2 changes: 1 addition & 1 deletion backend/src/serverRouter/blockRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ router
extended: true
}))
.use((_, __, next) => {
console.log('Time of github request:', Date.now());
console.log('Time of block router request:', Date.now());
next();
})
.use((req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/serverRouter/githubRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ router
extended: true
}))
.use((_, __, next) => {
console.log('Time of github request:', Date.now());
console.log('Time of github router request:', Date.now());
next();
})
.use((req, res, next) => {
Expand Down
23 changes: 15 additions & 8 deletions backend/src/serverRouter/jiraRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ router.post('/user/create/', (req, res) => {
console.error('No Jira User sent. (Got undefinded)');
res.status(401).json('No Jira User sent. (Got undefinded)');
} else {
const { jiraAccountName, jiraPassword, jiraHost: jiraServer, jiraAuthMethod } = req.body;
const {
jiraAccountName, jiraPassword, jiraHost: jiraServer, jiraAuthMethod
} = req.body;
let authString = `Bearer ${jiraPassword}`;
if (jiraAuthMethod === 'basic') {
const auth = Buffer.from(`${jiraAccountName}:${jiraPassword}`).toString('base64');
authString = `Basic ${auth}`;
}
console.log('auth ', authString);
const options = {
method: 'GET',
qs: {
Expand All @@ -51,15 +52,19 @@ router.post('/user/create/', (req, res) => {

// jiraHost must only consist of letters, numbers, '.' and ':' to represent URLs, IPs or ports
if (/^[.:a-zA-Z0-9]+$/.test(jiraServer)) {
console.log(jiraServer);
const jiraURL = `http://${jiraServer}/rest/auth/1/session`;
fetch(jiraURL, options)
.then((response) => response.json())
.then(() => {
userHelper.updateJiraCredential(req.user._id, jiraAccountName, jiraPassword, jiraServer, jiraAuthMethod)
.then((result) => {
res.status(200).json(result);
});
userHelper.updateJiraCredential(
req.user._id,
jiraAccountName,
jiraPassword,
jiraServer,
jiraAuthMethod
).then((result) => {
res.status(200).json(result);
});
})
.catch((error) => {
console.error(error);
Expand All @@ -82,7 +87,9 @@ router.delete('/user/disconnect/', (req, res) => {

router.post('/login', (req, res) => {
if (typeof req.body.jiraAccountName !== 'undefined') {
const { jiraAccountName, jiraPassword, jiraServer, AuthMethod } = req.body;
const {
jiraAccountName, jiraPassword, jiraServer, AuthMethod
} = req.body;
let authString = `Bearer ${jiraPassword}`;
if (AuthMethod === 'basic') {
const auth = Buffer.from(`${jiraAccountName}:${jiraPassword}`).toString('base64');
Expand Down
2 changes: 1 addition & 1 deletion backend/src/serverRouter/reportRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ router
extended: true
}))
.use((_, __, next) => {
console.log('Time of github request:', Date.now());
console.log('Time of report router request:', Date.now());
next();
})
.use((req, res, next) => {
Expand Down
5 changes: 2 additions & 3 deletions backend/src/serverRouter/runReportRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ router

// run single Feature
router.post('/Feature/:issueID', (req, res) => {
reporter.runReport(req, res, [], 'feature', req.body).catch((reason) => { console.log('failed in runreport', reason); res.send(reason).status(500) });
reporter.runReport(req, res, [], 'feature', req.body).catch((reason) => { console.log('failed in runreport', reason); res.send(reason).status(500); });
});

// run single Scenario of a Feature
Expand Down Expand Up @@ -65,11 +65,10 @@ router.post('/TempGroup', async (req, res) => {
params.repository = req.body.repository;
params.repoId = req.body.id;
req.body = tempGroup;
console.log(tempGroup)
reporter.runReport(req, res, mystories, 'group', tempGroup).then(() => {
console.log('Report for temporary group created');
})
.catch((reason) => res.send(reason).status(500));
.catch((reason) => res.send(reason).status(500));
});

// generate older Report
Expand Down
18 changes: 9 additions & 9 deletions backend/src/serverRouter/sanityTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const bodyParser = require('body-parser');
const passport = require('passport');
const bcrypt = require('bcrypt');
const initializePassport = require('../passport-config');
const mongo = require('../database/DbServices')
const mongo = require('../database/DbServices');
const reporter = require('../../dist/helpers/reporting');

const router = express.Router();
Expand Down Expand Up @@ -39,16 +39,16 @@ router
});

router.post('/test/:repoID/:groupID', passport.authenticate('normal-local', { session: false }), async (req, res) => {
try {
req.body.email = req.body.email.toLowerCase();
await test(req, res);
} catch (error) {
res.status(401).json(error);
}
try {
req.body.email = req.body.email.toLowerCase();
await test(req, res);
} catch (error) {
res.status(401).json(error);
}
});

async function test(req, res) {
const group = await mongo.getOneStoryGroup(req.params.repoID, req.params.groupID);
const group = await mongo.getOneStoryGroup(req.params.repoID, req.params.groupID);
const mystories = [];
for (const ms of group.member_stories) {
const id = typeof (ms) === 'object' ? ms._id : ms; // inconsistent in database
Expand All @@ -60,4 +60,4 @@ async function test(req, res) {
reporter.runSanityReport(req, res, mystories, 'group', req.body).catch((reason) => res.send(reason).status(500));
}

module.exports = router;
module.exports = router;
Loading
Loading