diff --git a/e2e/utils/html.go b/e2e/utils/html.go
index 82f40568b35..092e329e913 100644
--- a/e2e/utils/html.go
+++ b/e2e/utils/html.go
@@ -12,7 +12,11 @@ import (
"golang.org/x/net/html"
)
-var availablePlatforms = initPlatforms()
+var (
+ availablePlatforms = initPlatforms()
+ severityIds = []string{"info", "low", "medium", "high", "total"}
+ headerIds = []string{"scan-paths", "scan-platforms"}
+)
func initPlatforms() map[string]string {
platforms := make(map[string]string)
@@ -38,26 +42,24 @@ func HTMLValidation(t *testing.T, file string) {
require.NoError(t, errAct, "Opening Actual HTML File should not yield an error")
// Compare Header Data (Paths, Platforms)
- headerIds := []string{"scan-paths", "scan-platforms"}
- for arg := range headerIds {
- expectedValue := getElementByID(expectedHTML, headerIds[arg])
- actualValue := getElementByID(actualHTML, headerIds[arg])
-
+ sliceOfExpected := make([]string, 0, len(headerIds))
+ sliceOfActual := make([]string, 0, len(headerIds))
+ for _, header := range headerIds {
+ expectedValue := getElementByID(expectedHTML, header)
+ actualValue := getElementByID(actualHTML, header)
+ sliceOfActual = append(sliceOfActual, actualValue.LastChild.Data)
// Adapt path if running locally (dev)
if GetKICSDockerImageName() == "" {
expectedValue.LastChild.Data = KicsDevPathAdapter(expectedValue.LastChild.Data)
}
-
- require.NotNil(t, actualValue.LastChild,
- "[%s] Invalid value in Element ID <%s>", file, headerIds[arg])
-
- require.Equal(t, expectedValue.LastChild.Data, actualValue.LastChild.Data,
- "[%s] HTML Element <%s>:\n- Expected value: %s\n- Actual value: %s\n",
- file, headerIds[arg], expectedValue.LastChild.Data, actualValue.LastChild.Data)
+ sliceOfExpected = append(sliceOfExpected, expectedValue.LastChild.Data)
+ require.NotNil(t, actualValue.LastChild, "[%s] Invalid value in Element ID <%s>", file, header)
}
-
+ require.ElementsMatch(t, sliceOfExpected, sliceOfActual,
+ "[%s] HTML Element :\n- Expected value: %s\n- Actual value: %s\n",
+ file, sliceOfExpected, sliceOfActual)
// Compare Severity Values (High, Medium, Total...)
- severityIds := []string{"info", "low", "medium", "high", "total"}
+
for arg := range severityIds {
nodeIdentificator := "severity-count-" + severityIds[arg]
expectedSeverityValue := getElementByID(expectedHTML, nodeIdentificator)
diff --git a/e2e/utils/json.go b/e2e/utils/json.go
index 1f9acbc0eb4..3d712e6dbce 100644
--- a/e2e/utils/json.go
+++ b/e2e/utils/json.go
@@ -16,6 +16,8 @@ import (
"github.com/xeipuuv/gojsonschema"
)
+var filekey = "file"
+
type logMsg struct {
Level string `json:"level"`
ErrorMgs string `json:"error"`
@@ -143,7 +145,6 @@ func CheckLine(t *testing.T, expec, want string, line int) {
}
func setFields(t *testing.T, expect, actual []string, expectFileName, actualFileName, location string) {
- filekey := "file"
switch location {
case "payload":
var actualI model.Documents
@@ -226,6 +227,11 @@ func setFields(t *testing.T, expect, actual []string, expectFileName, actualFile
})
}
+ require.ElementsMatch(t, expectI.ScannedPaths, actualI.ScannedPaths,
+ "Expected Result content: 'fixtures/%s' doesn't match the Actual Result Scanned Paths content: 'output/%s'.",
+ expectFileName, actualFileName)
+ expectI.ScannedPaths = []string{}
+ actualI.ScannedPaths = []string{}
require.Equal(t, expectI, actualI,
"Expected Result content: 'fixtures/%s' doesn't match the Actual Result content: 'output/%s'.",
expectFileName, actualFileName)