Skip to content

Commit

Permalink
3.3.0 (#317)
Browse files Browse the repository at this point in the history
* version update

* re-introduced Maven skip option

* re-introduced Maven skip option

* removed Twitter link

* removed twitter

* click on bar charts work

* skipped state handling

* updated changelog for 3.3.0
  • Loading branch information
bischoffdev authored Aug 7, 2023
1 parent 37ed3c4 commit ab12cea
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 61 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [3.3.0] - 2023-08-07

### Fixed
* Scenarios having skipped steps after a passed step are now considered skipped (used to be passed) (#314)
* `skip` parameter in Cluecumber Maven was not recognized anymore (#316)

### Added
* Charts in "All Tags", "All Features" and "All Steps" can now be clicked and redirect to the according detail page

## [3.2.2] - 2023-05-12

### Fixed
Expand Down Expand Up @@ -737,6 +746,7 @@ steps with status `pending` or `undefined` (default value is `false`) (#74)

Initial project version on GitHub and Maven Central.

[3.3.0]: https://github.com/trivago/cluecumber-report-plugin/tree/3.3.0
[3.2.2]: https://github.com/trivago/cluecumber-report-plugin/tree/3.2.2
[3.2.1]: https://github.com/trivago/cluecumber-report-plugin/tree/3.2.1
[3.2.0]: https://github.com/trivago/cluecumber-report-plugin/tree/3.2.0
Expand Down
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>cluecumber-core</artifactId>
<version>3.2.2</version>
<version>3.3.0</version>
<packaging>jar</packaging>

<parent>
<artifactId>cluecumber-parent</artifactId>
<groupId>com.trivago.rta</groupId>
<version>3.2.2</version>
<version>3.3.0</version>
</parent>

<name>Cluecumber Core</name>
Expand Down
4 changes: 2 additions & 2 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<parent>
<artifactId>cluecumber-parent</artifactId>
<groupId>com.trivago.rta</groupId>
<version>3.2.2</version>
<version>3.3.0</version>
</parent>

<artifactId>cluecumber-engine</artifactId>
<version>3.2.2</version>
<version>3.3.0</version>
<packaging>jar</packaging>

<name>Cluecumber Engine</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public Status getStatus() {
if (failOnPendingOrUndefined) {
return Status.FAILED;
}
return Status.PASSED;
return Status.SKIPPED;
}

// If all steps are skipped return skipped (or failed if failOnPendingOrUndefined is true).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
* Information about the report generation date and Cluecumber version.
*/
public class ReportDetails {
private final String date;
private String chartJson;

private Map<String, String> chartUrlLookup = new HashMap<>();

/**
* Constructor setting the generation date.
Expand Down Expand Up @@ -75,4 +77,12 @@ public String getGeneratorName() {
return String.format("%s version %s",
Settings.NAME, RenderingUtils.getPluginVersion());
}

public Map<String, String> getChartUrlLookup() {
return chartUrlLookup;
}

public void setChartUrlLookup(Map<String, String> chartUrlLookup) {
this.chartUrlLookup = chartUrlLookup;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -87,9 +88,15 @@ private void addChartJsonToReportDetails(final AllFeaturesPageCollection allFeat
List<Float> passed = new ArrayList<>();
List<Float> failed = new ArrayList<>();
List<Float> skipped = new ArrayList<>();
Map<String, String> urlLookup = new HashMap<>();

int maximumNumberOfRuns = 0;
for (Map.Entry<Feature, ResultCount> entry : allFeaturesPageCollection.getFeatureResultCounts().entrySet()) {
urlLookup.put(
entry.getKey().getName(),
propertyManager.getGeneratedHtmlReportDirectory() + "/" +
Settings.PAGES_DIRECTORY + Settings.FEATURE_SCENARIOS_PAGE_FRAGMENT +
entry.getKey().getIndex() + Settings.HTML_FILE_EXTENSION);
ResultCount featureResultCount = entry.getValue();
passed.add((float) featureResultCount.getPassed());
failed.add((float) featureResultCount.getFailed());
Expand Down Expand Up @@ -117,6 +124,7 @@ private void addChartJsonToReportDetails(final AllFeaturesPageCollection allFeat
.build();

allFeaturesPageCollection.getReportDetails().setChartJson(convertChartToJson(chart));
allFeaturesPageCollection.getReportDetails().setChartUrlLookup(urlLookup);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -86,9 +87,15 @@ private void addChartJsonToReportDetails(final AllStepsPageCollection allTagsPag
List<Float> passed = new ArrayList<>();
List<Float> failed = new ArrayList<>();
List<Float> skipped = new ArrayList<>();
Map<String, String> urlLookup = new HashMap<>();

int maximumNumberOfRuns = 0;
for (Map.Entry<Step, ResultCount> entry : allTagsPageCollection.getStepResultCounts().entrySet()) {
urlLookup.put(
entry.getKey().returnNameWithArgumentPlaceholders(),
propertyManager.getGeneratedHtmlReportDirectory() + "/" +
Settings.PAGES_DIRECTORY + Settings.STEP_SCENARIO_PAGE_FRAGMENT +
entry.getKey().getUrlFriendlyName() + Settings.HTML_FILE_EXTENSION);
ResultCount stepResultCount = entry.getValue();
passed.add((float) stepResultCount.getPassed());
failed.add((float) stepResultCount.getFailed());
Expand Down Expand Up @@ -117,5 +124,6 @@ private void addChartJsonToReportDetails(final AllStepsPageCollection allTagsPag


allTagsPageCollection.getReportDetails().setChartJson(convertChartToJson(chart));
allTagsPageCollection.getReportDetails().setChartUrlLookup(urlLookup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -87,9 +88,15 @@ private void addChartJsonToReportDetails(final AllTagsPageCollection allTagsPage
List<Float> passed = new ArrayList<>();
List<Float> failed = new ArrayList<>();
List<Float> skipped = new ArrayList<>();
Map<String, String> urlLookup = new HashMap<>();

int maximumNumberOfRuns = 0;
for (Map.Entry<Tag, ResultCount> entry : allTagsPageCollection.getTagResultCounts().entrySet()) {
urlLookup.put(
entry.getKey().getName(),
propertyManager.getGeneratedHtmlReportDirectory() + "/" +
Settings.PAGES_DIRECTORY + Settings.TAG_SCENARIO_PAGE_FRAGMENT +
entry.getKey().getUrlFriendlyName() + Settings.HTML_FILE_EXTENSION);
ResultCount tagResultCount = entry.getValue();
passed.add((float) tagResultCount.getPassed());
failed.add((float) tagResultCount.getFailed());
Expand All @@ -116,6 +123,7 @@ private void addChartJsonToReportDetails(final AllTagsPageCollection allTagsPage
.build();

allTagsPageCollection.getReportDetails().setChartJson(convertChartToJson(chart));
allTagsPageCollection.getReportDetails().setChartUrlLookup(urlLookup);
}
}

2 changes: 1 addition & 1 deletion engine/src/main/resources/template/macros/page.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ limitations under the License.
<div id="canvas-holder" class="w-auto h-auto text-center" style="min-height: 15rem;" data-cluecumber-item="chart">
<canvas id="chart-area" class="w-100"></canvas>
</div>
</#macro>
</#macro>
97 changes: 57 additions & 40 deletions engine/src/main/resources/template/snippets/js.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -48,51 +48,68 @@ limitations under the License.
// Chart
<#if (reportDetails.chartJson?has_content)>
var canvas = document.getElementById('chart-area');
var ctx = canvas.getContext("2d");
var chart = new Chart(ctx, ${reportDetails.chartJson});
var original;
if (chart.config.type === "pie") {
original = Chart.defaults.pie.legend.onClick;
} else {
original = Chart.defaults.global.legend.onClick;
}
chart.options.onClick = function (evt, elements) {
if (chart.config.type !== "pie") return;
chartArea = elements[0];
if (chartArea === undefined) return;
chartArea.hidden = !chartArea.hidden;
chart.update();
toggleVisibilityByStatus(chartArea._model.label, !chartArea.hidden)
};
chart.options.legend.onClick = function (evt, label) {
original.call(this, evt, label);
toggleVisibilityByStatus(label.text, label.hidden);
};
var canvas = document.getElementById('chart-area');
var ctx = canvas.getContext("2d");
var chart = new Chart(ctx, ${reportDetails.chartJson});
var original;
if (chart.config.type === "pie") {
original = Chart.defaults.pie.legend.onClick;
chart.options.onClick = function (evt, elements) {
chartArea = elements[0];
if (chartArea === undefined) return;
chartArea.hidden = !chartArea.hidden;
chart.update();
toggleVisibilityByStatus(chartArea._model.label, !chartArea.hidden)
};
} else if (chart.config.type === "bar") {
<#if (reportDetails.chartUrlLookup?has_content)>
console.log("LOOKUP: " + ${reportDetails.chartUrlLookup?size})
const chartUrls = {
<#list reportDetails.chartUrlLookup as stepName, urlFriendlyStepName>
"${stepName?js_string}": "${urlFriendlyStepName}",
</#list>
};
canvas.onclick = function (evt) {
const activePoints = chart.getElementsAtEvent(evt);
if (activePoints.length <= 0) return;
const clickedElementindex = activePoints[0]["_index"];
const label = chart.data.labels[clickedElementindex];
if (label == null) return;
urlSnippet = chartUrls[label];
//const url = document.evaluate("//a[text()='" + label + "']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
console.log(urlSnippet);
if (urlSnippet == null) return;
window.location.href = urlSnippet;
}
</#if>
original = Chart.defaults.global.legend.onClick;
}
function toggleVisibilityByStatus(statusText, show) {
var card = $("#card_" + statusText);
if (card !== undefined) {
if (show) {
card.show();
} else {
card.hide();
chart.options.legend.onClick = function (evt, label) {
original.call(this, evt, label);
toggleVisibilityByStatus(label.text, label.hidden);
};
function toggleVisibilityByStatus(statusText, show) {
var card = $("#card_" + statusText);
if (card !== undefined) {
if (show) {
card.show();
} else {
card.hide();
}
}
}
var row = $(".table-row-" + statusText);
if (row !== undefined) {
if (show) {
row.show();
} else {
row.hide();
var row = $(".table-row-" + statusText);
if (row !== undefined) {
if (show) {
row.show();
} else {
row.hide();
}
}
}
}
</#if>
if (${expandBeforeAfterHooks?c}) {
Expand Down
9 changes: 8 additions & 1 deletion engine/src/main/resources/template/step-summary.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ preheadlineLink="">
</table>
</@page.card>
</div>
</@page.page>
<#-- <script>-->
<#-- const chartUrls = {-->
<#-- <#list stepResultCounts as step, stepResultCount>-->
<#-- "${step.name?js_string}": "${step.getUrlFriendlyName()}",-->
<#-- </#list>-->
<#-- };-->
<#-- </script>-->
</@page.page>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void getPassedStatusTest() {
}

@Test
public void passedStatusOnPassedAndSkippedStepsTest() {
public void skippedStatusOnPassedAndSkippedStepsTest() {
List<Step> steps = new ArrayList<>();
Step step = new Step();
Result result = new Result();
Expand All @@ -60,7 +60,7 @@ public void passedStatusOnPassedAndSkippedStepsTest() {
element.setSteps(steps);

Status status = element.getStatus();
assertEquals(status, Status.PASSED);
assertEquals(status, Status.SKIPPED);
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion examples/core-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>blog.softwaretester</groupId>
<artifactId>core-example</artifactId>
<version>3.2.2</version>
<version>3.3.0</version>
<packaging>pom</packaging>

<properties>
Expand Down
Loading

0 comments on commit ab12cea

Please sign in to comment.