Skip to content

Commit

Permalink
Merge pull request #90 from jgiven/WR24
Browse files Browse the repository at this point in the history
Wr24
  • Loading branch information
fudler authored May 3, 2024
2 parents b0c103d + e6e87fd commit 559f6ce
Show file tree
Hide file tree
Showing 28 changed files with 23,001 additions and 989 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
9 changes: 9 additions & 0 deletions ACTION_ITEMS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Refactor Application - SingleScenarioView l. 19ff
- Refactor APplication - ScenarioOverview l. 123
--> involves extracting Items to new components
- Fix width-problem
- Implement Top bar with search bar
- Create links between pages
- Create Bookmark functionality
- Provide a few more tests
- Make sidebar inflatable
27 changes: 27 additions & 0 deletions README_WR24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# The HTML App of JGiven and JsGiven - Workshop Edition 2024

Please perform the following steps before our Workshop takes place. This way, we can investigate any errors which might occur
during installation procedure.

## Prerequisites

Ensure you have the following tooling:
* `npm` (https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
* Typescript
* An IDE supporting Typescript (like IntelliJ ;))
* Firefox or Chrome (perhaps even both).

## Installation

Perform the following steps:
1. Clone the repo `https://github.com/jgiven/jgiven-html-app` and checkout the branch `WR24`.

The repo consists of the existing HTML App (folder `legacy`) and the new HTML App (folder `new`).

2. Navigate to `new` and run `npm install` as well as `npm run build`.
3. After performing `npm start` you should be able to see the new HTML App in your browser on `localhost:3000`.

## Advice

Have a look at JGiven (http://jgiven.org/, https://github.com/TNG/JGiven) and investigate the
existing HTML-App (https://jgiven.org/jgiven-report/html5/) to get an idea on what we plan to modernize.
2,340 changes: 1,744 additions & 596 deletions new/package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.0.1",
"react-router-dom": "^6.22.2",
"react-scripts": "5.0.1",
"typescript": "^4.9.3",
"web-vitals": "^2.1.4"
Expand All @@ -28,7 +29,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"format": "prettier --write ."
},
"prettier": {
"printWidth": 100,
Expand Down Expand Up @@ -67,5 +69,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "3.2.5"
}
}
23 changes: 5 additions & 18 deletions new/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
import "./App.css";
import ReportModel, { ReportStatistics } from "./reportModel";
import ReportModel from "./reportModel";
import * as guaranteedStateScenario from "./sampleData/GuaranteedStateTestScenario.json";
import { SingleScenarioView } from "./components/Scenarios/SingleScenarioView";

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";

const guaranteedStateReport: ReportModel = guaranteedStateScenario as unknown as ReportModel;

function App() {
return (
<div className="App" aria-label="App">
<SingleScenarioView
<ScenarioOverview
title={"Mein Titel"}
description={"Meine Description"}
reportName={guaranteedStateReport.name}
scenario={guaranteedStateReport.scenarios[0]}
/>
</div>
);
Expand Down
268 changes: 268 additions & 0 deletions new/src/ReportFilter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
import { repository } from "./repository";
import { ScenarioModel } from "./reportModel";
import { filterByStatus } from "./ReportFilter";
import { ScenarioStatusFilter } from "./components/ScenarioOverview/ScenarioCollectionHead";

describe("Report filter status filter", () => {
const fullReport = {
tagFile: { tagTypeMap: {}, tags: {} },
scenarios: [
{
className: "com.tngtech.jgiven.junit5.JUnit5ExecutorTest",
name: "J Unit 5 Executor",
scenarios: [
createSampleScenario({ executionStatus: "SUCCESS" }),
createSampleScenario({ executionStatus: "FAILED" })
]
},
{
className: "com.tngtech.jgiven.tests.TestScenarios",
name: "Test Scenarios",
scenarios: [createSampleScenario({ executionStatus: "FAILED" })]
}
]
};
test("should filter by status", () => {
jest.spyOn(repository, "getReport").mockReturnValue(fullReport);

expect(filterByStatus(ScenarioStatusFilter.SUCCESS)).toEqual([
fullReport.scenarios[0].scenarios[0]
]);
});

test("should ignore undefined status", () => {
jest.spyOn(repository, "getReport").mockReturnValue(fullReport);

expect(filterByStatus(ScenarioStatusFilter.SUCCESS, undefined)).toEqual([
fullReport.scenarios[0].scenarios[0]
]);
});

test("should return the full report if no status is provided", () => {
jest.spyOn(repository, "getReport").mockReturnValue(fullReport);

expect(filterByStatus()).toEqual(fullReport.scenarios.flatMap(s => s.scenarios));
});

test("should return the full report if null is provided", () => {
jest.spyOn(repository, "getReport").mockReturnValue(fullReport);

expect(filterByStatus(undefined)).toEqual(fullReport.scenarios.flatMap(s => s.scenarios));
});
});

function createSampleScenario(scenario: Partial<ScenarioModel>): ScenarioModel {
return {
className: "com.tngtech.jgiven.junit5.JUnit5ExecutorTest",
testMethodName: "after_stage_methods_of_stages_following_failing_stages_are_ignored",
description: "after stage methods of stages following failing stages are ignored",
tagIds: ["com.tngtech.jgiven.tags.FeatureJUnit5"],
explicitParameters: [],
derivedParameters: [],
scenarioCases: [
{
caseNr: 1,
steps: [
{
name: "a failing test with $ steps",
words: [
{
value: "Given",
isIntroWord: true
},
{
value: "a failing test with"
},
{
value: "2",
argumentInfo: {
argumentName: "n",
formattedValue: "2"
}
},
{
value: "steps"
}
],
status: "PASSED",
durationInNanos: 429103,
depth: 0,
parentFailed: false
},
{
name: "the test has $ failing stages",
words: [
{
value: "and",
isIntroWord: true
},
{
value: "the test has"
},
{
value: "2",
argumentInfo: {
argumentName: "n",
formattedValue: "2"
}
},
{
value: "failing stages"
}
],
status: "PASSED",
durationInNanos: 413003,
depth: 0,
parentFailed: false
},
{
name: "stage $ has a failing after stage method",
words: [
{
value: "and",
isIntroWord: true
},
{
value: "stage"
},
{
value: "2",
argumentInfo: {
argumentName: "i",
formattedValue: "2"
}
},
{
value: "has a failing after stage method"
}
],
status: "PASSED",
durationInNanos: 297902,
depth: 0,
parentFailed: false
},
{
name: "step $ fails",
words: [
{
value: "and",
isIntroWord: true
},
{
value: "step"
},
{
value: "1",
argumentInfo: {
argumentName: "i",
formattedValue: "1"
}
},
{
value: "fails"
}
],
status: "PASSED",
durationInNanos: 1022008,
depth: 0,
parentFailed: false
},
{
name: "the test is executed with JUnit5",
words: [
{
value: "When",
isIntroWord: true
},
{
value: "the test is executed with JUnit5"
}
],
status: "PASSED",
durationInNanos: 518574231,
depth: 0,
parentFailed: false
},
{
name: "the test fails",
words: [
{
value: "Then",
isIntroWord: true
},
{
value: "the test fails"
}
],
status: "PASSED",
durationInNanos: 1932714,
depth: 0,
parentFailed: false
},
{
name: "step $ is reported as failed",
words: [
{
value: "and",
isIntroWord: true
},
{
value: "step"
},
{
value: "1",
argumentInfo: {
argumentName: "i",
formattedValue: "1"
}
},
{
value: "is reported as failed"
}
],
status: "PASSED",
durationInNanos: 1136408,
depth: 0,
parentFailed: false
},
{
name: "step $ is reported as skipped",
words: [
{
value: "and",
isIntroWord: true
},
{
value: "step"
},
{
value: "2",
argumentInfo: {
argumentName: "i",
formattedValue: "2"
}
},
{
value: "is reported as skipped"
}
],
status: "PASSED",
durationInNanos: 287102,
depth: 0,
parentFailed: false
}
],
explicitArguments: [],
derivedArguments: [],
status: "SUCCESS",
durationInNanos: 525725382
}
],
casesAsTable: false,
durationInNanos: 525725382,
executionStatus: "SUCCESS",
tags: [{}],
classTitle: "J Unit 5 Executor",
...scenario
};
}
Loading

0 comments on commit 559f6ce

Please sign in to comment.