Skip to content
Permalink
Browse files
fix(reporting): execution context of a scenario is considered when ge…
…nerating the scenario ID and na

affects: @serenity-js/core

This solves the problem where, if there are several scenario with identical names, only one of them
would be clickable in the reports.

ISSUES CLOSED: Closes #75
  • Loading branch information
jan-molak committed Sep 29, 2017
1 parent 244e903 commit cd71d719e979db1284939f0980cf82e753f0201c
Showing with 19 additions and 5 deletions.
  1. +7 −3 packages/core/spec/reporting/serenity_bdd_reporter.spec.ts
  2. +12 −2 packages/core/src/reporting/serenity_bdd_reporter.ts
@@ -560,7 +560,9 @@ describe('When reporting on what happened during the rehearsal', () => {
);

return stageManager.waitForNextCue().then(_ =>
expect(producedReport('4ec27293d39642f72c52b21e57675a49.json')).to.deep.equal(expectedReportWith({
expect(producedReport('4062be5f843076e45e7704049f4b8cf1.json')).to.deep.equal(expectedReportWith({
id: 'checkout;paying-with-a-default-card;browser:chrome',
name: 'checkout;paying-with-a-default-card;browser:chrome',
duration: 2,
result: 'SUCCESS',
tags: [{
@@ -583,7 +585,9 @@ describe('When reporting on what happened during the rehearsal', () => {
);

return stageManager.waitForNextCue().then(_ =>
expect(producedReport('898a20ecc17b8d1dc3bf94b26147db3a.json')).to.deep.equal(expectedReportWith({
expect(producedReport('7f0e8e67887c2de55c2ca087e1ca14cb.json')).to.deep.equal(expectedReportWith({
id: 'checkout;paying-with-a-default-card;context:chrome',
name: 'checkout;paying-with-a-default-card;context:chrome',
duration: 2,
result: 'SUCCESS',
tags: [{
@@ -701,7 +705,7 @@ describe('When reporting on what happened during the rehearsal', () => {
function expectedReportWith(overrides: any) {
const report = {
id: 'checkout;paying-with-a-default-card',
name: 'Paying with a default card',
name: 'checkout;paying-with-a-default-card',
testSteps: [],
issues: [],
userStory: {
@@ -82,9 +82,9 @@ export class SerenityBDDReportExporter implements ReportExporter<JSONObject> {
return Promise.all(node.children.map(child => child.exportedUsing(this)))
.then((children: ActivityReport[]) => this.errorExporter.tryToExport(node.outcome.error).then(error => {
return node.promisedTags().then(tags => ({
id: `${this.dashified(node.value.category)};${this.dashified(node.value.name)}`,
id: this.idOf(node, tags),
title: node.value.name,
name: node.value.name,
name: this.idOf(node, tags),
context: tags.filter(tag => tag.type === 'context').map(tag => tag.value).pop(),
description: '',
startTime: node.startedAt,
@@ -121,6 +121,16 @@ export class SerenityBDDReportExporter implements ReportExporter<JSONObject> {
})));
}

private idOf(node: ScenePeriod, tags: Tag[]) {
const combined = (ts: Tag[]) => (tags || []).map(tag => `${ tag.type }:${tag.value}`).join(';');

return [
this.dashified(node.value.category),
this.dashified(node.value.name),
combined(tags),
].join(';').replace(/;$/, '');
}

private dashified = (name: string) => name
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/[ \t\W]/g, '-')

0 comments on commit cd71d71

Please sign in to comment.