-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Schüler
committed
Mar 1, 2024
1 parent
0e6e778
commit 3af69b6
Showing
4 changed files
with
98 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { ReportStatistics, ScenarioModel } from "../../reportModel"; | ||
import { MenuBar, ScenarioHead } from "../ScenarioOverview/ScenarioHead"; | ||
import { Scenario } from "./Scenario"; | ||
import { useState } from "react"; | ||
import { Grid } from "@mui/material"; | ||
|
||
export function ScenarioOverview(props: { reportName: string, title: string, description: string, scenarios: ScenarioModel[] }) { | ||
const [expanded, setExpanded] = useState(false); | ||
return ( | ||
<> | ||
<Grid container> | ||
<Grid item xs={12} md={1}> | ||
<div style={{ height: "100vh" }}> | ||
<MenuBar /> | ||
</div> | ||
</Grid> | ||
<Grid item xs={12} md={11}> | ||
{" "} | ||
{/* Workshop: Extract to new component. */} | ||
<Grid container direction="column"> | ||
<Grid item xs={12}> | ||
<div style={{ height: "20em" }}> | ||
<ScenarioHead | ||
headers={{ | ||
aboveHeader: props.description, | ||
header: props.title, | ||
}} | ||
statistic={createStatistics(props.scenarios)} | ||
targets={{ | ||
minusButtonTarget: () => { | ||
console.log("Collapsing stuff"); | ||
setExpanded(false); | ||
}, | ||
plusButtonTarget: () => { | ||
console.log("Expanding stuff"); | ||
setExpanded(true); | ||
}, | ||
printButtonTarget: () => { | ||
console.error("print not implemented"); | ||
}, | ||
bookmarkButtonTarget: () => { | ||
console.error("bookmark not implemented"); | ||
} | ||
}} | ||
/> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<div style={{ height: "40em" }}> | ||
<Scenario | ||
reportName={props.reportName} | ||
scenario={props.scenarios[0]} | ||
accordionExpansion={{ | ||
expanded: expanded, | ||
setExpanded: setExpanded | ||
}} | ||
></Scenario> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</> | ||
); | ||
} | ||
|
||
function createStatistics(scenarios: ScenarioModel[]): ReportStatistics { | ||
return { | ||
numClasses: 1, | ||
numScenarios: 1, | ||
// numFailedScenarios: Math.sign( | ||
// findNumberOfCasesWithStatus(scenario.scenarioCases, "FAILED") | ||
// ), | ||
numFailedScenarios: 1, | ||
numCases: 1, //scenario.scenarioCases.length, | ||
numFailedCases: 1, //findNumberOfCasesWithStatus(scenario.scenarioCases, "FAILED"), | ||
numSteps: 1, //scenario.scenarioCases.map(value => value.steps.length).reduce(sum), | ||
durationInNanos: 1, //scenario.durationInNanos, | ||
numPendingScenarios: 1, | ||
//Math.sign( | ||
// findNumberOfCasesWithStatus(scenario.scenarioCases, "SCENARIO_PENDING") | ||
//), | ||
numSuccessfulScenarios: 1, | ||
//Math.sign( | ||
// findNumberOfCasesWithStatus(scenario.scenarioCases, "SUCCESS") | ||
//) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,5 @@ | ||
import { ReportStatistics, ScenarioCaseModel, ScenarioModel } from "../../reportModel"; | ||
import { MenuBar, ScenarioOverview } from "../ScenarioOverview/ScenarioOverview"; | ||
import { Scenario } from "./Scenario"; | ||
import { useState } from "react"; | ||
import { Grid } from "@mui/material"; | ||
import {ScenarioProps} from "./Scenario"; | ||
|
||
export function SingleScenarioView(props: { reportName: string; scenario: ScenarioModel }) { | ||
const [expanded, setExpanded] = useState(false); | ||
return ( | ||
<> | ||
<Grid container> | ||
<Grid item xs={12} md={1}> | ||
<div style={{ height: "100vh" }}> | ||
<MenuBar /> | ||
</div> | ||
</Grid> | ||
<Grid item xs={12} md={11}> | ||
{" "} | ||
{/* Workshop: Extract to new component. */} | ||
<Grid container direction="column"> | ||
<Grid item xs={12}> | ||
<div style={{ height: "20em" }}> | ||
<ScenarioOverview | ||
headers={{ | ||
aboveHeader: props.scenario.className, | ||
header: props.scenario.description | ||
}} | ||
statistic={createStatistics(props.scenario)} | ||
targets={{ | ||
minusButtonTarget: () => { | ||
console.log("Collapsing stuff"); | ||
setExpanded(false); | ||
}, | ||
plusButtonTarget: () => { | ||
console.log("Expanding stuff"); | ||
setExpanded(true); | ||
}, | ||
printButtonTarget: () => { | ||
console.error("print not implemented"); | ||
}, | ||
bookmarkButtonTarget: () => { | ||
console.error("bookmark not implemented"); | ||
} | ||
}} | ||
/> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<div style={{ height: "40em" }}> | ||
<Scenario | ||
reportName={props.reportName} | ||
scenario={props.scenario} | ||
accordionExpansion={{ | ||
expanded: expanded, | ||
setExpanded: setExpanded | ||
}} | ||
></Scenario> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</> | ||
); | ||
} | ||
export function SingleScenarioView(scenario: ScenarioProps) { | ||
|
||
function createStatistics(scenario: ScenarioModel): ReportStatistics { | ||
return { | ||
numClasses: 1, | ||
numScenarios: 1, | ||
numFailedScenarios: Math.sign( | ||
findNumberOfCasesWithStatus(scenario.scenarioCases, "FAILED") | ||
), | ||
numCases: scenario.scenarioCases.length, | ||
numFailedCases: findNumberOfCasesWithStatus(scenario.scenarioCases, "FAILED"), | ||
numSteps: scenario.scenarioCases.map(value => value.steps.length).reduce(sum), | ||
durationInNanos: scenario.durationInNanos, | ||
numPendingScenarios: Math.sign( | ||
findNumberOfCasesWithStatus(scenario.scenarioCases, "SCENARIO_PENDING") | ||
), | ||
numSuccessfulScenarios: Math.sign( | ||
findNumberOfCasesWithStatus(scenario.scenarioCases, "SUCCESS") | ||
) | ||
}; | ||
} | ||
|
||
function findNumberOfCasesWithStatus( | ||
scenarioCases: ScenarioCaseModel[], | ||
status: ScenarioCaseModel["status"] | ||
): number { | ||
return scenarioCases.filter(value => value.status === status).length; | ||
} | ||
|
||
function sum(left: number, right: number): number { | ||
return left + right; | ||
} | ||
} |