Skip to content
Merged
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
72 changes: 72 additions & 0 deletions tests/smoke/test_ucc_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from os import path
from pathlib import Path
from typing import Any
import subprocess
import shutil

from splunk_add_on_ucc_framework.entity.interval_entity import CRON_REGEX
from tests.smoke import helpers
Expand Down Expand Up @@ -740,6 +742,76 @@ def test_ucc_dashboard_js_copying(config, expected_file_count):
)


def test_check_ucc_ui_files(tmp_path):
if path.exists(path.join(os.getcwd(), "dist")):
shutil.rmtree(path.join(os.getcwd(), "dist"))
subprocess.run(["poetry", "build"], capture_output=True, text=True)
dist_folder = path.join(tmp_path, "dist")

# Set the path to dist directory in current working directory
dist_dir = Path(path.join(os.getcwd(), "dist"))

# Get .whl file in that directory
whl_file = next(dist_dir.glob("*.whl"))
whl_file_path = path.join(dist_folder, whl_file)
subprocess.run(
["pip", "install", whl_file_path, "--target", dist_folder],
capture_output=True,
text=True,
)

# Run the command to store all UI files
result = subprocess.run(
[
"ls",
"-a",
f"{dist_folder}/splunk_add_on_ucc_framework/package/appserver/static/js/build",
],
capture_output=True,
text=True,
)
file_list = result.stdout.strip().split("\n")

# Remove '.' and '..'
cleaned_files = file_list[2:]

def remove_hash(filename):
if filename.endswith(".js"):
return re.sub(r"\.[a-zA-Z0-9_-]+(?=\.js$)", "", filename)
return filename

# Create new list with hash removed
normalized_files = [remove_hash(f) for f in cleaned_files]

expected_js_files_list = [
"ArrowBroadUnderbarDown.js",
"assets",
"ConfigurationPage.js",
"Dashboard.consts.js",
"Dashboard.Custom.js",
"Dashboard.DashboardPage.js",
"Dashboard.DataIngestion.js",
"Dashboard.EnterpriseViewOnlyPreset.js",
"Dashboard.Error.js",
"Dashboard.Overview.js",
"Dashboard.Resource.js",
"Dashboard.utils.js",
"entry_page.js",
"ErrorBoundary.js",
"html2canvas.esm.js",
"index.es.js",
"InputPage.js",
"licenses.txt",
"Menu.js",
"purify.es.js",
"redirect_page.js",
"Search.js",
"Search.js",
"usePlatform.js",
]
assert sorted(normalized_files) == sorted(expected_js_files_list)


def test_ucc_generate_with_all_alert_types(tmp_path, caplog):
package_folder = path.join(
path.dirname(path.realpath(__file__)),
Expand Down
Loading