Skip to content

Commit

Permalink
Merge pull request #1844 from akto-api-security/fix/fix_testing_conti…
Browse files Browse the repository at this point in the history
…nous_test_table

Fixed call for after clicking table for summaries
  • Loading branch information
notshivansh authored Dec 20, 2024
2 parents 21b2a47 + e47fc3b commit 61bc259
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GithubSimpleTable from "../../../components/tables/GithubSimpleTable";
import {
Text,
Button,
Expand Down Expand Up @@ -133,6 +132,7 @@ function SingleTestRunPage() {

const [testingRunResultSummariesObj, setTestingRunResultSummariesObj] = useState({})
const [allResultsLength, setAllResultsLength] = useState(undefined)
const [currentSummary, setCurrentSummary] = useState('')

const tableTabMap = {
vulnerable: "VULNERABLE",
Expand Down Expand Up @@ -185,7 +185,7 @@ function SingleTestRunPage() {
})
}

async function setSummary(summary){
async function setSummary(summary, initialCall=false){
setTempLoading((prev) => {
prev.running = false;
return prev;
Expand All @@ -198,59 +198,53 @@ function SingleTestRunPage() {

return {...prev};
});

await fetchTestingRunResultsData(summary.hexId);
}
async function fetchTestingRunResultsData(summaryHexId){
setLoading(false);
setTempLoading((prev) => {
prev.vulnerable = true;
prev.no_vulnerability_found = true;
prev.skipped = true;
prev.need_configurations = true
prev.ignored_issues = true
return {...prev};
});
setCurrentSummary(summary);
if(!initialCall){
setUpdateTable(Date.now().toString())
}
}

useEffect(() => {
setUpdateTable(Date.now().toString())
}, [testingRunResultSummariesObj])

const fetchTestingRunResultSummaries = async () => {
await api.fetchTestingRunResultSummaries(hexId).then(async ({ testingRun, testingRunResultSummaries, workflowTest, testingRunType }) => {
let tempTestingRunResultSummaries = [];
await api.fetchTestingRunResultSummaries(hexId).then(({ testingRun, testingRunResultSummaries, workflowTest, testingRunType }) => {
tempTestingRunResultSummaries = testingRunResultSummaries
setTestingRunResultSummariesObj({
testingRun, testingRunResultSummaries, workflowTest, testingRunType
testingRun, workflowTest, testingRunType
})
})
const timeNow = func.timeNow()
const defaultIgnoreTime = LocalStore.getState().defaultIgnoreSummaryTime
tempTestingRunResultSummaries.sort((a,b) => {
const isAWithinTimeAndRunning = (timeNow - defaultIgnoreTime <= a.startTimestamp) && a.state === 'RUNNING';
const isBWithinTimeAndRunning = (timeNow - defaultIgnoreTime <= b.startTimestamp) && b.state === 'RUNNING';

if (isAWithinTimeAndRunning && isBWithinTimeAndRunning) {
return b.startTimestamp - a.startTimestamp;
}
if (isAWithinTimeAndRunning) return -1;
if (isBWithinTimeAndRunning) return 1;
return b.startTimestamp - a.startTimestamp;
})
setSummary(tempTestingRunResultSummaries[0], true)
}

const fetchTableData = async (sortKey, sortOrder, skip, limit, filters, filterOperators, queryValue) => {
let testRunResultsRes = []
let testRunCountMap = []
const { testingRun, testingRunResultSummaries, workflowTest, testingRunType } = testingRunResultSummariesObj
if(testingRun == undefined || testingRunResultSummaries.length === 0){
const { testingRun, workflowTest, testingRunType } = testingRunResultSummariesObj
if(testingRun === undefined){
return {value: [], total: 0}
}

if(testingRun.testIdConfig === 1){
setWorkflowTest(workflowTest);
}
let cicd = testingRunType === "CI_CD";
const timeNow = func.timeNow()
const defaultIgnoreTime = LocalStore.getState().defaultIgnoreSummaryTime
testingRunResultSummaries.sort((a,b) => {
const isAWithinTimeAndRunning = (timeNow - defaultIgnoreTime <= a.startTimestamp) && a.state === 'RUNNING';
const isBWithinTimeAndRunning = (timeNow - defaultIgnoreTime <= b.startTimestamp) && b.state === 'RUNNING';

if (isAWithinTimeAndRunning && isBWithinTimeAndRunning) {
return b.startTimestamp - a.startTimestamp;
}
if (isAWithinTimeAndRunning) return -1;
if (isBWithinTimeAndRunning) return 1;
return b.startTimestamp - a.startTimestamp;
})
const localSelectedTestRun = transform.prepareTestRun(testingRun, testingRunResultSummaries[0], cicd, false);
const localSelectedTestRun = transform.prepareTestRun(testingRun, currentSummary , cicd, false);
setTestingRunConfigSettings(testingRun.testingRunConfig?.configsAdvancedSettings || [])
setTestingRunConfigId(testingRun.testingRunConfig?.id || -1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ const transform = {
if (testingRunResultSummary == null) {
testingRunResultSummary = {};
}
if (testingRunResultSummary.countIssues != null) {
testingRunResultSummary.countIssues = transform.prepareCountIssues(testingRunResultSummary.countIssues);
}

let state = cicd ? testingRunResultSummary.state : data.state ;
if (cicd !== true && checkTestFailure(testingRunResultSummary.state, state)) {
Expand Down

0 comments on commit 61bc259

Please sign in to comment.