Skip to content

Commit

Permalink
Merge pull request #1390 from akto-api-security/hotfix/fix_np_endpoin…
Browse files Browse the repository at this point in the history
…ts_page

Fixing null pointer on run test modal
  • Loading branch information
avneesh-akto authored Aug 22, 2024
2 parents 277cc52 + 8d1484b commit 86a9c0e
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
const initialState = {
categories: [],
tests: {},
selectedCategory: "",
selectedCategory: "BOLA",
recurringDaily: false,
continuousTesting: false,
overriddenTestAppUrl: "",
Expand Down Expand Up @@ -81,12 +81,13 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
const businessLogicSubcategories = allSubCategoriesResponse.subCategories
const categories = allSubCategoriesResponse.categories
const { selectedCategory, mapCategoryToSubcategory } = populateMapCategoryToSubcategory(businessLogicSubcategories)

// Store all tests
const processMapCategoryToSubcategory = {}
Object.keys(mapCategoryToSubcategory).map(category => {
processMapCategoryToSubcategory[category] = [...mapCategoryToSubcategory[category]["all"]]
})
if(Object.keys(businessLogicSubcategories).length > 0){
Object.keys(mapCategoryToSubcategory).map(category => {
processMapCategoryToSubcategory[category] = [...mapCategoryToSubcategory[category]["all"]]
})
}

// Set if a test is selected or not
Object.keys(processMapCategoryToSubcategory).map(category => {
Expand All @@ -110,7 +111,7 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
...prev,
categories: categories,
tests: processMapCategoryToSubcategory,
selectedCategory: Object.keys(processMapCategoryToSubcategory)[0],
selectedCategory: Object.keys(processMapCategoryToSubcategory).length > 0 ? Object.keys(processMapCategoryToSubcategory)[0] : "",
testName: testName,
authMechanismPresent: authMechanismPresent
}))
Expand Down Expand Up @@ -147,7 +148,6 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
ret[x.superCategory.name].all.push(obj)
ret[x.superCategory.name].selected.push(obj)
})

//store this
return {
selectedCategory: Object.keys(ret)[0],
Expand All @@ -157,7 +157,7 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu

const activator = (
<div ref={runTestRef}>
<Button onClick={toggleRunTest} primary disabled={disabled} ><div data-testid="run_test_button">Run test</div></Button>
<Button onClick={toggleRunTest} primary disabled={disabled || testRun.selectedCategory.length === 0} ><div data-testid="run_test_button">Run test</div></Button>
</div>
);

Expand Down Expand Up @@ -222,7 +222,7 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
}))
}

testRows = testRun.tests[testRun.selectedCategory].filter(x=> x.label.toLowerCase().includes(searchValue.toLowerCase())).map(test => {
testRows = testRun.selectedCategory.length > 0 ? testRun.tests[testRun.selectedCategory].filter(x=> x.label.toLowerCase().includes(searchValue.toLowerCase())).map(test => {
const isCustom = test?.author !== "AKTO"
const label = (
<span style={{display: 'flex', gap: '4px', alignItems: 'flex-start'}}>
Expand All @@ -238,7 +238,7 @@ function RunTest({ endpoints, filtered, apiCollectionId, disabled, runTestFromOu
onChange={() => handleTestsSelected(test)}
/>
)])
})
}) : []
}

const hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
Expand Down

0 comments on commit 86a9c0e

Please sign in to comment.