Skip to content

Commit

Permalink
Add testset documentation and HTML reports
Browse files Browse the repository at this point in the history
  • Loading branch information
ylkhayat committed Feb 12, 2024
1 parent 24ba953 commit b240d8f
Show file tree
Hide file tree
Showing 45 changed files with 229 additions and 17,554 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
*.log
!testsets/**/*.log
!docs/testsets/**/*.html
node_modules
dist
1 change: 1 addition & 0 deletions README.md → docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 🚀 Smart Socket Service

Welcome to the Smart Socket Service, your one-stop shop for controlling and monitoring smart sockets. This service is like a remote control for your smart sockets, but with superpowers! 💪
This documentation also has a [github page](https://ylkhayat.github.io/smart-socket-service/), maybe check it out for better visualization when it comes to testsets.

## Usage Scenario

Expand Down
File renamed without changes.
57 changes: 57 additions & 0 deletions docs/testsets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
body,
html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,
sans-serif, Apple Color Emoji, Segoe UI Emoji;
}
#sidebar {
width: 250px;
height: 100%;
overflow-y: auto;
float: left;
background-color: #f4f4f4;
padding: 10px;
border-radius: 5px; /* Add rounded borders */
}
#sidebar a {
display: block;
color: #333;
text-decoration: none;
padding: 5px;
cursor: pointer;
transition: background-color 0.1s;

}
#sidebar a:hover {
background-color: #ddd;
}

#sidebar a.selected {
background-color: #ddd;
}

#sidebar details {
> a,
details {
margin-left: 20px;
}
}

#sidebar summary {
cursor: pointer;
padding: 5px; /* Add padding */
font-weight: 500;
}
#sidebar summary:hover {
background-color: #ddd;
}
#content {
margin-left: 250px;
height: 100%;
overflow-y: auto;
padding: 10px;
border-radius: 5px; /* Add rounded borders */
}
18 changes: 18 additions & 0 deletions docs/testsets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BPMNs - Testsets</title>
<link rel="stylesheet" href="css/style.css" />
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</head>
<body>
<div id="sidebar">
<h3>Testsets</h3>
</div>
<div id="content"></div>

<script src="js/script.js"></script>
</body>
</html>
48 changes: 48 additions & 0 deletions docs/testsets/js/generate-tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const fs = require("fs");
const path = require("path");

const directoryPath = path.join(__dirname, ".."); // Change 'content' to your target directory
const outputPath = path.join(__dirname, "..", "tree.json");

function isDirectory(filePath) {
return fs.statSync(filePath).isDirectory();
}

const ignore = [
"node_modules",
"index.html",
"README.md",
"tree.json",
"js",
"css",
"img",
"fonts",
"favicon.ico",
"CNAME",
".git",
".gitignore",
"LICENSE",
"js",
"css",
".DS_Store",
"energy-monitor.log",
"server-monitor.log",
];
function generateTree(dirPath, relativePath = "") {
return fs.readdirSync(dirPath).reduce((acc, item) => {
if (ignore.includes(item)) return acc;
const fullPath = path.join(dirPath, item);
const itemRelativePath = path.join(relativePath, item);
if (isDirectory(fullPath)) {
acc[item] = generateTree(fullPath, itemRelativePath);
} else {
acc[item] = itemRelativePath;
}
return acc;
}, {});
}

const tree = generateTree(directoryPath);
fs.writeFileSync(outputPath, JSON.stringify(tree, null, 2), "utf8");

console.log(`Tree structure generated at ${outputPath}`);
63 changes: 63 additions & 0 deletions docs/testsets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
document.addEventListener("DOMContentLoaded", function () {
fetch("tree.json")
.then((response) => response.json())
.then((files) => {
const folder = document.createElement("div");
createElements(files, folder);
document.getElementById("sidebar").appendChild(folder);
});
});

window.addEventListener("hashchange", function () {
const anchors = document.querySelectorAll("#sidebar a");
anchors.forEach((anchor) => {
if (anchor.getAttribute("href") === window.location.hash) {
anchor.classList.add("selected");
} else {
anchor.classList.remove("selected");
}
});
});

function createElements(files, parent) {
Object.entries(files).forEach(([key, value]) => {
if (typeof value === "object") {
const folder = document.createElement("details");
const summary = document.createElement("summary");
summary.textContent = key;
folder.appendChild(summary);
parent.appendChild(folder);
createElements(value, folder); // Recursive call for nested objects
} else {
const link = document.createElement("a");
link.href = `#${value}`;
link.textContent = key;
link.onclick = function () {
loadContent(value);
return false;
};
parent.appendChild(link);
}
});
}

function loadContent(filePath) {
const content = document.getElementById("content");
fetch(filePath)
.then((response) => response.text())
.then((text) => {
if (filePath.endsWith(".md")) {
content.innerHTML = marked.parse(text);
} else if (filePath.endsWith(".xml")) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(text, "text/xml");
const pre = document.createElement("pre");
pre.textContent = new XMLSerializer().serializeToString(xmlDoc);
content.innerHTML = "";
content.appendChild(pre);
} else {
content.innerHTML = text;
}
window.location.hash = filePath;
});
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions docs/testsets/tree.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"mixer-control-scenario-b.xml": "mixer-control-scenario-b.xml",
"parallel-start-wait-stop": {
"parallel-start-wait-stop.xml": "parallel-start-wait-stop/parallel-start-wait-stop.xml",
"run-1": {
"energy-monitor.html": "parallel-start-wait-stop/run-1/energy-monitor.html",
"server-monitor.html": "parallel-start-wait-stop/run-1/server-monitor.html"
},
"run-2": {
"energy-monitor.html": "parallel-start-wait-stop/run-2/energy-monitor.html",
"server-monitor.html": "parallel-start-wait-stop/run-2/server-monitor.html"
},
"run-3": {
"energy-monitor.html": "parallel-start-wait-stop/run-3/energy-monitor.html",
"server-monitor.html": "parallel-start-wait-stop/run-3/server-monitor.html"
},
"run-4": {
"energy-monitor.html": "parallel-start-wait-stop/run-4/energy-monitor.html",
"server-monitor.html": "parallel-start-wait-stop/run-4/server-monitor.html"
}
},
"start-wait-stop": {
"run-1": {
"energy-monitor.html": "start-wait-stop/run-1/energy-monitor.html",
"server-monitor.html": "start-wait-stop/run-1/server-monitor.html"
},
"run-2": {
"energy-monitor.html": "start-wait-stop/run-2/energy-monitor.html",
"server-monitor.html": "start-wait-stop/run-2/server-monitor.html"
},
"run-3": {
"energy-monitor.html": "start-wait-stop/run-3/energy-monitor.html",
"server-monitor.html": "start-wait-stop/run-3/server-monitor.html"
},
"run-4": {
"energy-monitor.html": "start-wait-stop/run-4/energy-monitor.html",
"server-monitor.html": "start-wait-stop/run-4/server-monitor.html"
},
"start-wait-stop.xml": "start-wait-stop/start-wait-stop.xml"
}
}
Loading

0 comments on commit b240d8f

Please sign in to comment.