Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/WR24' into WR24
Browse files Browse the repository at this point in the history
  • Loading branch information
l-1squared committed Mar 1, 2024
2 parents 1cc0fb6 + d9d8834 commit aa16d6a
Show file tree
Hide file tree
Showing 7 changed files with 639 additions and 650 deletions.
1,154 changes: 583 additions & 571 deletions new/package-lock.json

Large diffs are not rendered by default.

20 changes: 3 additions & 17 deletions new/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import "./App.css";
import ReportModel, { ReportStatistics } from "./reportModel";
import ReportModel from "./reportModel";
import * as guaranteedStateScenario from "./sampleData/GuaranteedStateTestScenario.json";
import { ScenarioOverview } from "./components/Scenarios/ScenarioOverview";
import { useSearchParams } from "react-router-dom";

export const statistics: ReportStatistics[] = [
{
numClasses: 3,
numScenarios: 5,
numFailedScenarios: 2,
numCases: 3,
numFailedCases: 3,
numSteps: 10,
durationInNanos: 12345678910,
numPendingScenarios: 0,
numSuccessfulScenarios: 3
}
];
import {ScenarioOverview} from "./components/Scenarios/ScenarioOverview";
import {useSearchParams} from "react-router-dom";

const guaranteedStateReport: ReportModel = guaranteedStateScenario as unknown as ReportModel;

Expand Down
22 changes: 21 additions & 1 deletion new/src/components/ScenarioOverview/ScenarioHead.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from "@mui/material/styles";
import { Drawer, Link } from "@mui/material";
import { Box, Button, Drawer, Link } from "@mui/material";

export const StyledDrawer = styled(Drawer)({
// width: 240,
Expand All @@ -17,3 +17,23 @@ export const StyledContent = styled("div")(({ theme }) => ({
export const StyledLink = styled(Link)({
cursor: "pointer"
});

export const StyledIconContainer = styled(Box)({
width: "30px",
height: "30px",
p: 0.01,
display: "flex",
alignItems: "center",
justifyContent: "center",
border: "1px solid grey",
borderRadius: 1,
marginRight: "5px"
});

export const StyledIconButton = styled(Button)({
"&:hover": { textDecoration: "none", color: "inherit" },
"min-width": "1px",
"min-height": "1px",
height: "30px",
color: "black"
});
59 changes: 21 additions & 38 deletions new/src/components/ScenarioOverview/ScenarioHead.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { ReportStatistics } from "../../reportModel";
import {
Box,
Breadcrumbs,
Button,
Divider,
Grid,
Link,
Expand All @@ -23,7 +21,13 @@ import { createReportCircle } from "./DonutChart";
import React, { MouseEventHandler } from "react";
import { processWords } from "../../wordProcessor";
import { useSearchParams } from "react-router-dom";
import { StyledContent, StyledDrawer, StyledLink } from "./ScenarioHead.styles";
import {
StyledContent,
StyledDrawer,
StyledIconButton,
StyledIconContainer,
StyledLink
} from "./ScenarioHead.styles";

export interface ScenarioOverviewProps {
statistic: ReportStatistics;
Expand Down Expand Up @@ -147,57 +151,36 @@ function ScenarioActionButtons(props: { targets: ActionButtonTargets }) {
return (
<Grid container>
<Grid item>
<ScenarioOverviewItem action={props.targets.minusButtonTarget}>
<ScenarioHeaderIcon action={props.targets.minusButtonTarget}>
<RemoveIcon fontSize="inherit" />
</ScenarioOverviewItem>
</ScenarioHeaderIcon>
</Grid>
<Grid item>
<ScenarioOverviewItem action={props.targets.plusButtonTarget}>
<AddIcon></AddIcon>
</ScenarioOverviewItem>
<ScenarioHeaderIcon action={props.targets.plusButtonTarget}>
<AddIcon />
</ScenarioHeaderIcon>
</Grid>
<Grid item>
<ScenarioOverviewItem action={props.targets.printButtonTarget}>
<ScenarioHeaderIcon action={props.targets.printButtonTarget}>
<PrintOutlinedIcon fontSize="inherit" />
</ScenarioOverviewItem>
</ScenarioHeaderIcon>
</Grid>
<Grid item>
<ScenarioOverviewItem action={props.targets.bookmarkButtonTarget}>
<ScenarioHeaderIcon action={props.targets.bookmarkButtonTarget}>
<BookmarkOutlinedIcon fontSize="inherit" />
</ScenarioOverviewItem>
</ScenarioHeaderIcon>
</Grid>
</Grid>
);
}

function ScenarioOverviewItem(props: { children: React.ReactNode; action: MouseEventHandler }) {
const sx = {
width: "12px", // or some other value
height: "12px", // same as width
p: 0.01,
display: "flex",
alignItems: "center",
justifyContent: "center",
border: "1px solid grey",
borderRadius: 1,
marginRight: "5px"
};
function ScenarioHeaderIcon(props: { children: React.ReactNode; action: MouseEventHandler }) {
return (
<Box sx={sx} component="span">
<Button
className="actionPanelButton"
color="inherit"
sx={{
"&:hover": { textDecoration: "none", color: "inherit" },
"min-width": "1px",
"min-height": "1px",
height: sx.height
}}
onClick={props.action}
>
<StyledIconContainer>
<StyledIconButton className="actionPanelButton" onClick={props.action}>
{props.children}
</Button>
</Box>
</StyledIconButton>
</StyledIconContainer>
);
}

Expand Down
28 changes: 9 additions & 19 deletions new/src/components/Scenarios/ScenarioOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,16 @@ export function ScenarioOverview(props: {

function createStatistics(scenarios: ScenarioModel[]): ReportStatistics {
const allCases = scenarios.flatMap((scenario) => scenario.scenarioCases);
const allSteps = allCases.flatMap((scenarioCase) => {scenarioCase.steps});
const failedCases = allCases.filter((scenarioCase) => scenarioCase.status === "FAILED" );

const failedScenarios = scenarios.filter((scenario) => scenario.scenarioCases.some((scenarioCase) => scenarioCase.status === "FAILED"));
const pendingScenarios = scenarios.filter((scenario) => scenario.scenarioCases.some((scenarioCase) => scenarioCase.status === "SOME_STEPS_PENDING" || scenarioCase.status === "SCENARIO_PENDING"));
const failedScenarios = scenarios.filter((scenario) => scenario.executionStatus === "FAILED");
const pendingScenarios = scenarios.filter((scenario) => scenario.executionStatus === "PENDING");
const successfulScenarios = scenarios.filter((scenario) => scenario.executionStatus === "SUCCESS");
return {
numClasses: 1,
numScenarios: scenarios.length,
numFailedScenarios: failedScenarios.length,
numCases: allCases.length,
numFailedCases: failedCases.length,
numSteps: allSteps.length,
durationInNanos: 1, //scenario.durationInNanos,
numFailedScenarios: failedScenarios.length,
durationInNanos: allCases
.map((scenarioCase) => scenarioCase.durationInNanos)
.reduce((totalDuration, current) => totalDuration + current),
numPendingScenarios: pendingScenarios.length,
//Math.sign(
// findNumberOfCasesWithStatus(scenario.scenarioCases, "SCENARIO_PENDING")
//),
numSuccessfulScenarios: 1
//Math.sign(
// findNumberOfCasesWithStatus(scenario.scenarioCases, "SUCCESS")
//)
numSuccessfulScenarios: successfulScenarios.length,
};
}
}
4 changes: 0 additions & 4 deletions new/src/reportModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ interface ReportModelFile {
file: File;
}
interface ReportStatistics {
numClasses: number;
numScenarios: number;
numFailedScenarios: number;
numCases: number;
numFailedCases: number;
numSteps: number;
durationInNanos: number;
numPendingScenarios: number;
numSuccessfulScenarios: number;
Expand Down
2 changes: 2 additions & 0 deletions new/src/sampleData/GuaranteedStateTestScenario.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "Guaranteed State",
"scenarios": [
{
"executionStatus": "SUCCESS",
"className": "com.tngtech.jgiven.impl.GuaranteedStateTest",
"testMethodName": "assure_before_method_of_first_test_is_executed_after_guaranteed_fields_validation",
"description": "assure before method of first test is executed after guaranteed fields validation",
Expand Down Expand Up @@ -84,6 +85,7 @@
{
"className": "com.tngtech.jgiven.impl.GuaranteedStateTest",
"testMethodName": "assure_before_method_of_second_test_is_executed_if_guaranteed_initialized",
"executionStatus": "PENDING",
"description": "assure before method of second test is executed if guaranteed initialized",
"tagIds": [],
"explicitParameters": [],
Expand Down

0 comments on commit aa16d6a

Please sign in to comment.