Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
feat(protractor): browser tags include browser version and platform name
Closes #132
- Loading branch information
Showing
with
197 additions
and 77 deletions.
- +65 −61 examples/protractor-jasmine-todomvc/spec/manage_a_todo_list_with_plain_old_protractor.spec.ts
- +1 −1 packages/core/spec/model/Tag.spec.ts
- +19 −2 packages/core/src/model/tags/BrowserTag.ts
- +1 −0 packages/core/src/model/tags/ContextTag.ts
- +12 −0 packages/core/src/model/tags/PlatformTag.ts
- +4 −0 packages/core/src/model/tags/Tag.ts
- +1 −0 packages/core/src/model/tags/index.ts
- +5 −5 packages/protractor/spec/adapter/ProtractorFrameworkAdapter.spec.ts
- +9 −2 packages/protractor/src/adapter/ProtractorFrameworkAdapter.ts
- +61 −0 packages/protractor/src/adapter/browser-detector/BrowserDetector.ts
- +1 −0 packages/protractor/src/adapter/browser-detector/index.ts
- +8 −4 .../serenity-bdd/spec/stage/crew/serenity-bdd-reporter/SerenityBDDReporter/tagging_scenarios.spec.ts
- +10 −2 packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/reports/SceneReport.ts
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
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
@@ -0,0 +1,12 @@ | ||
import { Tag } from './Tag'; | ||
|
||
/** | ||
* @access public | ||
*/ | ||
export class PlatformTag extends Tag { | ||
static readonly Type = 'platform'; | ||
|
||
constructor(platform: string) { | ||
super(platform, PlatformTag.Type); | ||
} | ||
} |
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
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
@@ -0,0 +1,61 @@ | ||
import { Stage } from '@serenity-js/core'; | ||
import { AsyncOperationAttempted, AsyncOperationCompleted, DomainEvent, SceneStarts, SceneTagged } from '@serenity-js/core/lib/events'; | ||
import { BrowserTag, CorrelationId, Description, PlatformTag } from '@serenity-js/core/lib/model'; | ||
import { StageCrewMember } from '@serenity-js/core/lib/stage'; | ||
import { protractor } from 'protractor'; | ||
|
||
/** | ||
* @private | ||
* | ||
* @see https://github.com/serenity-js/serenity-js/issues/455 | ||
* @see https://github.com/serenity-bdd/serenity-core/pull/1860/files | ||
* @see https://github.com/serenity-js/serenity-js/issues/132 | ||
*/ | ||
export class BrowserDetector implements StageCrewMember { | ||
|
||
constructor( | ||
private readonly stage: Stage = null, | ||
) { | ||
} | ||
|
||
assignedTo(stage: Stage): StageCrewMember { | ||
return new BrowserDetector(stage); | ||
} | ||
|
||
notifyOf(event: DomainEvent): void { | ||
if (event instanceof SceneStarts) { | ||
const id = CorrelationId.create(); | ||
|
||
this.stage.announce(new AsyncOperationAttempted( | ||
new Description(`[${ this.constructor.name }] Detecting web browser details...`), | ||
id, | ||
this.stage.currentTime(), | ||
)); | ||
|
||
protractor.browser.getCapabilities().then(capabilities => { | ||
const | ||
platform = capabilities.get('platform'), | ||
browserName = capabilities.get('browserName'), | ||
browserVersion = capabilities.get('version'); | ||
|
||
this.stage.announce(new SceneTagged( | ||
event.value, | ||
new BrowserTag(browserName, browserVersion), | ||
this.stage.currentTime(), | ||
)); | ||
|
||
this.stage.announce(new SceneTagged( | ||
event.value, | ||
new PlatformTag(platform), | ||
this.stage.currentTime(), | ||
)); | ||
|
||
this.stage.announce(new AsyncOperationCompleted( | ||
new Description(`[${ this.constructor.name }] Detected web browser details`), | ||
id, | ||
this.stage.currentTime(), | ||
)); | ||
}); | ||
} | ||
} | ||
} |
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
@@ -0,0 +1 @@ | ||
export * from './BrowserDetector'; |
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
Oops, something went wrong.