Skip to content

Commit 308aec4

Browse files
committed
Display har file on testcaseexecution
Fix ReportingMonitor error
1 parent 3f848c1 commit 308aec4

File tree

9 files changed

+299
-55
lines changed

9 files changed

+299
-55
lines changed

source/src/main/webapp/ApplicationList.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!DOCTYPE html>
2424
<html class="crb_html">
2525
<head>
26-
<meta name="active-menu" content="application">
26+
<meta name="active-menu" content="settings">
2727
<meta name="active-submenu" content="ApplicationList.jsp">
2828
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2929
<%@ include file="include/global/dependenciesInclusions.html" %>

source/src/main/webapp/Environment.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!DOCTYPE html>
2424
<html class="h-full">
2525
<head>
26-
<meta name="active-menu" content="integration">
26+
<meta name="active-menu" content="settings">
2727
<meta name="active-submenu" content="Environment.jsp">
2828
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2929
<%@ include file="include/global/dependenciesInclusions.html" %>

source/src/main/webapp/TestCaseExecution.jsp

Lines changed: 156 additions & 47 deletions
Large diffs are not rendered by default.

source/src/main/webapp/css/tailwind/css/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ src/main/webapp/css/
4646
@import "./components.css";
4747
@import "./utilities.css";
4848
@import "./pages/homepage.css";
49-
49+
@import "./pages/testcaseexecution.css";
5050

5151

5252

source/src/main/webapp/css/tailwind/css/migration.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@
1414
@apply bg-slate-700/50 ;
1515
text-decoration: none;
1616
}
17+
18+
19+
/* ===========================
20+
PRE
21+
=========================== */
22+
.crb-pre pre {
23+
all: unset; /* reset Bootstrap */
24+
display: block;
25+
white-space: pre;
26+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.json-view {
2+
white-space: pre;
3+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
4+
@apply bg-slate-50 dark:bg-slate-950 text-slate-900 dark:text-slate-200;
5+
}
6+
7+
.json-key { @apply text-sky-700 dark:text-sky-300; }
8+
.json-string { @apply text-green-700 dark:text-green-300; }
9+
.json-value { @apply text-amber-700 dark:text-amber-300; }

source/src/main/webapp/include/global/header2.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<aside id="crb_sidebar"
33
class="crb_sidebar transition-all duration-300 ease-in-out overflow-hidden"
44
:class="$store.sidebar.expanded ? 'w-72' : 'w-20'"
5-
@mouseenter="$store.sidebar.handleEnter()"
6-
@mouseleave="$store.sidebar.handleLeave()"
75
x-show="!$store.sidebar.hidden">
86

97
<!-- Logo & Header -->

source/src/main/webapp/js/pages/ReportingMonitor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ function refreshMonitorTable(dataFromWs) {
605605
let maxAvailableHPixel = document.getElementById("progressMonitor").offsetWidth - wOffsetH;
606606
let maxNbColumns = maxAvailableHPixel / 120;
607607

608-
let maxAvailableVPixel = document.getElementById("page-layout").offsetHeight - wOffsetV;
608+
let maxAvailableVPixel = document.getElementsByTagName("main").offsetHeight - wOffsetV;
609609
let boxHeigth = wBoxHeigth;
610610

611611
let maxNblines = maxAvailableVPixel / boxHeigth;

source/src/main/webapp/js/pages/TestCaseExecution.js

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,108 @@ $.when($.getScript("js/global/global.js")).then(function () {
104104
});
105105
});
106106

107+
function harViewer() {
108+
return {
109+
har: null,
110+
loaded: false,
111+
loading: false,
112+
113+
filter: '',
114+
statusFilter: 'all',
115+
sortBy: 'time',
116+
selected: null,
117+
118+
init() {
119+
// Watch le store pour charger automatiquement le HAR
120+
this.$watch('$store.har.enrichedHarFile', (file) => {
121+
if (file) {
122+
this.loadFromApi(file);
123+
}
124+
});
125+
},
126+
127+
load(har) {
128+
this.har = har;
129+
this.har.log.entries.forEach((e, i) => e._id = i);
130+
this.loaded = true;
131+
},
132+
133+
loadFromApi(file) {
134+
if (this.loaded || this.loading || !file?.fileName) return;
135+
136+
this.loading = true;
137+
138+
const url =
139+
`./ReadTestCaseExecutionMedia` +
140+
`?filename=${encodeURIComponent(file.fileName)}` +
141+
`&filetype=${file.fileType || 'JSON'}` +
142+
`&filedesc=${encodeURIComponent(file.fileDesc || '')}` +
143+
`&auto=true&autoContentType=N`;
144+
145+
fetch(url)
146+
.then(r => r.text())
147+
.then(txt => this.load(JSON.parse(txt)))
148+
.finally(() => this.loading = false);
149+
},
150+
151+
select(entry) {
152+
console.log(entry);
153+
this.selected = entry; },
154+
155+
statusClass(status) {
156+
if (status >= 500) return 'dark:bg-red-900 dark:text-red-300 bg-red-300 text-red-900';
157+
if (status >= 400) return 'dark:bg-orange-900 dark:text-orange-300 bg-orange-300 text-orange-900';
158+
return 'dark:bg-green-900 dark:text-green-300 bg-green-300 text-green-900';
159+
},
160+
161+
get filteredEntries() {
162+
if (!this.har) return [];
163+
164+
let entries = this.har.log.entries;
165+
166+
if (this.filter) {
167+
entries = entries.filter(e =>
168+
e.request.url.toLowerCase().includes(this.filter.toLowerCase())
169+
);
170+
}
171+
172+
if (this.statusFilter !== 'all') {
173+
entries = entries.filter(e => {
174+
const s = e.response.status;
175+
return this.statusFilter === '2xx' ? s < 300 :
176+
this.statusFilter === '4xx' ? s >= 400 && s < 500 :
177+
s >= 500;
178+
});
179+
}
180+
181+
// SORT IN-PLACE instead of creating a new array
182+
return entries.sort((a, b) => {
183+
if (this.sortBy === 'time') return b.time - a.time;
184+
if (this.sortBy === 'status') return b.response.status - a.response.status;
185+
return b.response.content.size - a.response.content.size;
186+
});
187+
}
188+
}
189+
}
190+
191+
function highlightJson(json) {
192+
if (!json) return '';
193+
return JSON.stringify(json, null, 2)
194+
.replace(/(&)/g, '&amp;')
195+
.replace(/(<)/g, '&lt;')
196+
.replace(/(".*?")(?=\s*:)/g, '<span class="json-key">$1</span>')
197+
.replace(/:\s*(".*?")/g, ': <span class="json-string">$1</span>')
198+
.replace(/:\s*(\d+|\btrue\b|\bfalse\b|\bnull\b)/g,
199+
': <span class="json-value">$1</span>');
200+
}
201+
202+
//Store enrichHarFile link to load it into table
203+
document.addEventListener('alpine:init', () => {
204+
Alpine.store('har', {
205+
enrichedHarFile: null
206+
});
207+
});
208+
107209
// Add the testCase to the page title (<head>)
108210
function updatePageTitle(testcase, doc) {
109211
if (typeof testcase !== 'undefined') {
@@ -244,6 +346,16 @@ function loadExecutionInformation(executionId, steps, sockets) {
244346
}
245347

246348
}
349+
350+
const enrichedHarFile = tce.fileList?.find(f =>
351+
f.fileName?.endsWith("enriched_har.json")
352+
);
353+
354+
if (enrichedHarFile) {
355+
Alpine.store('har').enrichedHarFile = enrichedHarFile; // le composant harViewer va charger automatiquement
356+
}
357+
358+
247359
$("#seeProperties").click(function () {
248360
$("#propertiesModal").modal('show');
249361
});
@@ -1139,10 +1251,11 @@ function update_thirdParty_Chart() {
11391251

11401252
// Display unknown hosts in warning mode.
11411253
$("#detailUnknownList").empty();
1142-
let entryUnknown = $('<li class="list-group-item">').text("Unknown Hosts/Domains:");
1254+
let entryUnknown =$('<li class="">');
1255+
//let entryUnknown = $('<li class="list-group-item">').text("Unknown Hosts/Domains:");
11431256
$("#detailUnknownList").append(entryUnknown);
11441257
for (var key in unknownDomain) {
1145-
let entryUnknown = $('<li class="list-group-item list-group-item-danger">').text(unknownDomain[key]);
1258+
let entryUnknown = $('<li class="">').text(unknownDomain[key]);
11461259
$("#detailUnknownList").append(entryUnknown);
11471260
}
11481261

@@ -1296,6 +1409,10 @@ function drawChart_GanttPerThirdParty(data, titletext, target) {
12961409
title: {
12971410
display: true,
12981411
text: titletext
1412+
},
1413+
options: {
1414+
responsive: true,
1415+
maintainAspectRatio: false
12991416
}
13001417
};
13011418

0 commit comments

Comments
 (0)