Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin #1166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Admin #1166

Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions testplan/runnable/interactive/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ class Report(flask_restx.Resource):

def get(self):
"""Get the state of the root interactive report."""
full = flask.request.args.get("full", "false").lower() == "true"
Copy link
Contributor

@yuxuan-ms yuxuan-ms Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full = bool(flask.request.args.get("full", "false")) ?

with ihandler.report_mutex:
return _serialize_report_entry(ihandler.report)
return _serialize_report_entry(ihandler.report, full=full)

def put(self):
"""Update the state of the root interactive report."""
Expand Down Expand Up @@ -752,16 +753,18 @@ def _validate_json_body(json_body: Dict) -> None:
if json_body is None:
raise werkzeug.exceptions.BadRequest("JSON body is required for PUT")


def _serialize_report_entry(report_entry):
def _serialize_report_entry(report_entry, full=False):
"""
Serialize a report entry representing a testcase or a test group.
For a test group shallow serialization is used instead.
"""
if isinstance(report_entry, TestCaseReport):
return report_entry.serialize()
elif isinstance(report_entry, (TestGroupReport, TestReport)):
return report_entry.shallow_serialize()
if full:
return report_entry.serialize()
else:
return report_entry.shallow_serialize()
else:
raise TypeError(f"Unexpected report entry type: {type(report_entry)}")

Expand Down
29 changes: 18 additions & 11 deletions testplan/web_ui/testing/src/Report/InteractiveReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import { encodeURIComponent2, parseToJson } from "../Common/utils";
import { POLL_MS, CATEGORIES } from "../Common/defaults";
import { AssertionContext, defaultAssertionStatus } from "../Common/context";
import { ErrorBoundary } from "../Common/ErrorBoundary";
import { displayTimeInfoPreference, timeInfoUTCPreference } from "../UserSettings/UserSettings";
import {
displayTimeInfoPreference,
timeInfoUTCPreference,
} from "../UserSettings/UserSettings";

const api_prefix = "/api/v1/interactive";
const pendingEnvRequestAtom = atom("");
Expand Down Expand Up @@ -87,6 +90,7 @@ class InteractiveReportComponent extends BaseReport {
running: false,
aborting: false,
assertionStatus: defaultAssertionStatus,
firstGet: true, // state variable to track the first getReport
};
}

Expand Down Expand Up @@ -119,16 +123,19 @@ class InteractiveReportComponent extends BaseReport {
*
* If running in dev mode we just display a fake report.
*/
getReport() {
getReport(firstGet = true) {
if (this.state.aborting) {
this.setError({ message: "Server is aborting ..." });
return;
}
if (this.props.match.params.uid === "_dev") {
setTimeout(() => this.setReport(FakeInteractiveReport), 1500);
} else {
const url = firstGet
? "/api/v1/interactive/report?full=true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use {params: {full: true}} in axios

: "/api/v1/interactive/report";
axios
.get("/api/v1/interactive/report", { transformResponse: parseToJson })
.get(url, { transformResponse: parseToJson })
.then((response) => {
if (
response.data.runtime_status === "ready" ||
Expand All @@ -142,10 +149,9 @@ class InteractiveReportComponent extends BaseReport {
this.setState({ running: false });
}
}
if (
!this.state.report ||
this.state.report.hash !== response.data.hash
) {
if (firstGet) {
this.setReport(response.data);
} else if (this.state.report.hash !== response.data.hash) {
this.getTests().then((tests) => {
const rawReport = { ...response.data, entries: tests };
this.setReport(rawReport);
Expand All @@ -155,7 +161,10 @@ class InteractiveReportComponent extends BaseReport {
.catch(this.setError)
.finally(() => {
// We poll for updates to the report every second.
setTimeout(this.getReport, this.props.poll_intervall || POLL_MS);
setTimeout(
() => this.getReport(false),
this.props.poll_intervall || POLL_MS
);
});
}
}
Expand Down Expand Up @@ -491,9 +500,7 @@ class InteractiveReportComponent extends BaseReport {
};

if (!isReportLeaf(reportEntry) && !_.isEmpty(entries)) {
pruneEntry.entries = entries.map((entry) =>
this.pruneReportEntry(entry)
);
pruneEntry.entries = entries.map((entry) => this.pruneReportEntry(entry));
}

return pruneEntry;
Expand Down
Loading