Skip to content
Permalink
Browse files
feat(rest): @serenity-js/rest 2.0
affects: @serenity-js/assertions, @serenity-js/core, @serenity-js/cucumber, @serenity-js/rest,
@serenity-js-examples/calculator-app, @serenity-js-examples/cucumber-rest-api-level-testing,
@documentation/esdoc-template, @documentation/website

Completely re-designed version of the REST module
  • Loading branch information
jan-molak committed Nov 11, 2018
1 parent 892ba7a commit ad0a6770a43a13067023c08436d338444e96ba82
Showing with 9,003 additions and 225 deletions.
  1. +3 −0 .gitignore
  2. +8 −7 documentation/esdoc-template/src/class.html
  3. +6 −6 documentation/esdoc-template/src/details.html
  4. +1 −1 documentation/website/build.js
  5. +1 −0 documentation/website/package.json
  6. +9 −3 documentation/website/plugins/highlighEsdoc.js
  7. +1 −1 documentation/website/src/guides/screenplay-pattern.md
  8. +24 −0 examples/calculator-app/index.js
  9. +10 −0 examples/calculator-app/nodemon.json
  10. +3,216 −0 examples/calculator-app/package-lock.json
  11. +12 −3 examples/calculator-app/package.json
  12. +86 −18 examples/calculator-app/spec/Calculator.spec.ts
  13. +1 −1 examples/calculator-app/spec/domain/model/Operator.spec.ts
  14. +35 −1 examples/calculator-app/spec/expect.ts
  15. +37 −0 examples/calculator-app/spec/rest-api/controllers.spec.ts
  16. +72 −0 examples/calculator-app/spec/rest-api/model/Expression.spec.ts
  17. +6 −2 examples/calculator-app/src/Calculator.ts
  18. +6 −0 examples/calculator-app/src/domain/model/Operand.ts
  19. +1 −1 examples/calculator-app/src/domain/model/Operator.ts
  20. +3 −1 examples/calculator-app/src/domain/query-handlers/ResultCalculator.ts
  21. +52 −0 examples/calculator-app/src/rest-api/controllers.ts
  22. +6 −0 examples/calculator-app/src/rest-api/index.ts
  23. +77 −0 examples/calculator-app/src/rest-api/model/Expression.ts
  24. +17 −0 examples/calculator-app/src/rest-api/model/Result.ts
  25. +2 −0 examples/calculator-app/src/rest-api/model/index.ts
  26. +7 −0 examples/cucumber-rest-api-level-testing/.gitignore
  27. +15 −0 examples/cucumber-rest-api-level-testing/features/api/calculations.feature
  28. +17 −0 examples/cucumber-rest-api-level-testing/features/step_definitions/api-level.steps.ts
  29. +20 −0 examples/cucumber-rest-api-level-testing/features/support/configure_serenity.ts
  30. +11 −0 examples/cucumber-rest-api-level-testing/features/support/screenplay/Actors.ts
  31. +2 −0 examples/cucumber-rest-api-level-testing/features/support/screenplay/index.ts
  32. +10 −0 examples/cucumber-rest-api-level-testing/features/support/screenplay/tasks/RequestCalculationOf.ts
  33. +10 −0 examples/cucumber-rest-api-level-testing/features/support/screenplay/tasks/VerifyResultAt.ts
  34. +2 −0 examples/cucumber-rest-api-level-testing/features/support/screenplay/tasks/index.ts
  35. +2,784 −0 examples/cucumber-rest-api-level-testing/package-lock.json
  36. +52 −0 examples/cucumber-rest-api-level-testing/package.json
  37. +10 −0 examples/cucumber-rest-api-level-testing/tsconfig-lint.json
  38. +13 −0 examples/cucumber-rest-api-level-testing/tsconfig.json
  39. +4 −4 package-lock.json
  40. +3 −3 package.json
  41. +25 −19 packages/assertions/spec/Ensure.spec.ts
  42. +1 −1 packages/assertions/spec/assertions/equals.spec.ts
  43. +1 −1 packages/assertions/spec/assertions/not.spec.ts
  44. +2 −2 packages/assertions/src/{assertions → }/Assertion.ts
  45. +7 −8 packages/assertions/src/Ensure.ts
  46. +3 −3 packages/assertions/src/assertions/equals.ts
  47. +1 −0 packages/assertions/src/assertions/index.ts
  48. +1 −1 packages/assertions/src/assertions/not.ts
  49. +20 −0 packages/assertions/src/assertions/startsWith.ts
  50. +1 −0 packages/assertions/src/index.ts
  51. +15 −15 packages/assertions/src/values.ts
  52. +2 −1 packages/assertions/tsconfig.json
  53. +4 −4 packages/core/spec/screenplay/Interaction.spec.ts
  54. +2 −2 packages/core/spec/screenplay/actor/Actor.spec.ts
  55. +5 −5 packages/core/spec/stage/crew/artifact-archiver/ArtifactArchiver.spec.ts
  56. +2 −10 packages/core/src/index.ts
  57. +9 −0 packages/core/src/instance.ts
  58. +16 −0 packages/core/src/io/proxies.ts
  59. +22 −0 packages/core/src/model/artifacts/HTTPRequestResponse.ts
  60. +8 −0 packages/core/src/model/artifacts/TestReport.ts
  61. +2 −0 packages/core/src/model/artifacts/index.ts
  62. +7 −18 packages/core/src/screenplay/Interaction.ts
  63. +8 −0 packages/core/src/screenplay/KnowableUnknown.ts
  64. +0 −6 packages/core/src/screenplay/KnownUnknown.ts
  65. +3 −2 packages/core/src/screenplay/activities/ActivityDescriber.ts
  66. +8 −4 packages/core/src/screenplay/activities/TrackedActivity.ts
  67. +44 −23 packages/core/src/screenplay/actor/Actor.ts
  68. +2 −2 packages/core/src/screenplay/actor/AnswersQuestions.ts
  69. +19 −0 packages/core/src/screenplay/actor/CollectsArtifacts.ts
  70. +1 −0 packages/core/src/screenplay/actor/index.ts
  71. +1 −1 packages/core/src/screenplay/index.ts
  72. +4 −1 packages/core/src/stage/Clock.ts
  73. +34 −21 packages/core/src/stage/crew/artifact-archiver/ArtifactArchiver.ts
  74. +3 −3 packages/core/src/stage/crew/serenity-bdd-reporter/SerenityBDDJsonSchema.ts
  75. +2 −2 packages/core/src/stage/crew/serenity-bdd-reporter/SerenityBDDReporter.ts
  76. +51 −12 packages/core/src/stage/crew/serenity-bdd-reporter/reports/SceneReport.ts
  77. +3 −2 packages/core/src/stage/crew/serenity-bdd-reporter/strategies/SceneReportingStrategy.ts
  78. +1 −1 packages/core/src/stage/index.ts
  79. +2 −1 packages/core/tsconfig.json
  80. +2 −1 packages/cucumber/tsconfig.json
  81. +1 −0 packages/rest/.esdoc.js
  82. +9 −0 packages/rest/.gitignore
  83. +14 −0 packages/rest/.npmignore
  84. +201 −0 packages/rest/LICENSE.md
  85. +1 −0 packages/rest/NOTICE.md
  86. +39 −0 packages/rest/README.md
  87. +82 −0 packages/rest/package.json
  88. +3 −0 packages/rest/register.js
  89. +14 −0 packages/rest/spec/actors.ts
  90. +6 −0 packages/rest/spec/expect.ts
  91. +37 −0 packages/rest/spec/model/DeleteRequest.spec.ts
  92. +37 −0 packages/rest/spec/model/GetRequest.spec.ts
  93. +37 −0 packages/rest/spec/model/HeadRequest.spec.ts
  94. +37 −0 packages/rest/spec/model/OptionsRequest.spec.ts
  95. +51 −0 packages/rest/spec/model/PatchRequest.spec.ts
  96. +42 −0 packages/rest/spec/model/PostRequest.spec.ts
  97. +51 −0 packages/rest/spec/model/PutRequest.spec.ts
  98. +180 −0 packages/rest/spec/screenplay/abilities/CallAnApi.spec.ts
  99. +120 −0 packages/rest/spec/screenplay/interactions/Send.spec.ts
  100. +70 −0 packages/rest/spec/screenplay/questions/LastResponse.spec.ts
  101. +2 −0 packages/rest/src/index.ts
  102. +69 −0 packages/rest/src/model/DeleteRequest.ts
  103. +71 −0 packages/rest/src/model/GetRequest.ts
  104. +77 −0 packages/rest/src/model/HTTPRequest.ts
  105. +61 −0 packages/rest/src/model/HeadRequest.ts
  106. +62 −0 packages/rest/src/model/OptionsRequest.ts
  107. +72 −0 packages/rest/src/model/PatchRequest.ts
  108. +111 −0 packages/rest/src/model/PostRequest.ts
  109. +84 −0 packages/rest/src/model/PutRequest.ts
  110. +8 −0 packages/rest/src/model/index.ts
  111. +168 −0 packages/rest/src/screenplay/abilities/CallAnApi.ts
  112. +1 −0 packages/rest/src/screenplay/abilities/index.ts
  113. +3 −0 packages/rest/src/screenplay/index.ts
  114. +76 −0 packages/rest/src/screenplay/interactions/Send.ts
  115. +1 −0 packages/rest/src/screenplay/interactions/index.ts
  116. +75 −0 packages/rest/src/screenplay/questions/LastResponse.ts
  117. +1 −0 packages/rest/src/screenplay/questions/index.ts
  118. +10 −0 packages/rest/tsconfig-lint.json
  119. +22 −0 packages/rest/tsconfig.json
  120. +1 −1 scripts/travis/script.sh
@@ -2,6 +2,9 @@
.idea
*.iml

# Serenity BDD
*.jar

# OS
.DS_Store

@@ -16,39 +16,40 @@ <h1 data-ice="name"></h1>
<span data-ice="instanceDoc"></span>
</div>

<div class="description" data-ice="description"></div>

<div class="expression-extends" data-ice="expressionExtends"><h4>Expression Extends:</h4><pre><code data-ice="expressionExtendsCode"></code></pre></div>
<div class="flat-list" data-ice="mixinExtends"><h4>Mixin Extends:</h4></div>
<div class="flat-list" data-ice="extendsChain"><h4>Extends:</h4></div>
<div class="flat-list" data-ice="directSubclass"><h4>Direct Subclass:</h4></div>
<div class="flat-list" data-ice="indirectSubclass"><h4>Indirect Subclass:</h4></div>
<div class="flat-list" data-ice="directSubclass"><h4>Direct Subclasses:</h4></div>
<div class="flat-list" data-ice="indirectSubclass"><h4>Indirect Subclasses:</h4></div>
<div class="flat-list" data-ice="implements"><h4>Implements:</h4></div>
<div class="flat-list" data-ice="indirectImplements"><h4>Indirect Implements:</h4></div>
<div class="flat-list" data-ice="directImplemented"><h4>Direct Implemented:</h4></div>
<div class="flat-list" data-ice="indirectImplemented"><h4>Indirect Implemented:</h4></div>

<div class="deprecated" data-ice="deprecated"></div>
<div class="experimental" data-ice="experimental"></div>
<div class="description" data-ice="description"></div>
<div class="decorator" data-ice="decorator"><h4>Decorators:</h4></div>

<div data-ice="see"><h4>See:</h4></div>

<div data-ice="exampleDocs">
<h4>Example:</h4>
<h4 id="examples">Examples:</h4>
<div class="example-doc" data-ice="exampleDoc">
<div class="example-caption" data-ice="exampleCaption"></div>
<pre class="source-code"><code data-ice="exampleCode"></code></pre>
</div>
</div>

<div data-ice="tests">
<h4>Test:</h4>
<h4 id="tests">Tests:</h4>
<ul>
<li data-ice="test"></li>
</ul>
</div>

<div data-ice="todo"><h4>TODO:</h4></div>

<div data-ice="see"><h4>See also:</h4></div>
</div>

<div data-ice="staticMemberSummary"><h2>Static Member Summary</h2></div>
@@ -25,7 +25,7 @@ <h3 data-ice="anchor">
<div data-ice="properties"></div>

<div class="return-params" data-ice="returnParams">
<h4>Return:</h4>
<h4>Returns:</h4>
<table>
<tbody>
<tr>
@@ -38,7 +38,7 @@ <h4>Return:</h4>
</div>

<div data-ice="emitWrap">
<h4>Emit:</h4>
<h4>Emits:</h4>
<table>
<tbody>
<tr class="emit" data-ice="emit">
@@ -50,7 +50,7 @@ <h4>Emit:</h4>
</div>

<div data-ice="listenWrap">
<h4>Listen:</h4>
<h4>Listens:</h4>
<table>
<tbody>
<tr class="listen" data-ice="listen">
@@ -62,7 +62,7 @@ <h4>Listen:</h4>
</div>

<div data-ice="throwWrap">
<h4>Throw:</h4>
<h4>Throws:</h4>
<table>
<tbody>
<tr class="throw" data-ice="throw">
@@ -76,15 +76,15 @@ <h4>Throw:</h4>
<div data-ice="decorator"><h4>Decorators:</h4></div>

<div data-ice="example">
<h4>Example:</h4>
<h4 id="examples">Examples:</h4>
<div class="example-doc" data-ice="exampleDoc">
<div class="example-caption" data-ice="exampleCaption"></div>
<pre class="source-code"><code data-ice="exampleCode"></code></pre>
</div>
</div>

<div data-ice="tests">
<h4>Test:</h4>
<h4>Tests:</h4>
<ul>
<li data-ice="test"></li>
</ul>
@@ -22,7 +22,7 @@ const
browserSync = devMode ? require('metalsmith-browser-sync') : noop,
highlight = require('highlight.js'),

highlightedLanguages = ['typescript', 'javascript', 'json'];
highlightedLanguages = ['typescript', 'javascript', 'json', 'gherkin'];

Metalsmith(__dirname)
.source('src')
@@ -39,6 +39,7 @@
"@serenity-js/assertions": "*",
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*",
"@serenity-js/rest": "*",
"cheerio": "1.0.0-rc.2",
"clean-css": "4.2.1",
"glob": "7.1.3",
@@ -1,13 +1,13 @@
'use strict';

const fs = require('fs');
const cheerio = require('cheerio');

let i = 0;

module.exports = function highlightEsdoc(highlight, languages) {

return function(files, ms, done) {

setImmediate(done);

Object.keys(files).filter(path => /\.html$/.test(path)).forEach(path => {
const $ = cheerio.load(files[path].contents.toString('utf8'));

@@ -16,12 +16,18 @@ module.exports = function highlightEsdoc(highlight, languages) {

const result = highlight.highlightAuto(el.text(), languages);

if (! result.language) {
return done(new Error(`Could not detect the language of the following code sample: ${result.value}`));
}

el.html(result.value);
el.addClass('hljs');
el.addClass(result.language);
});

files[path].contents = Buffer.from($.html());
});

return done();
};
}
@@ -82,7 +82,7 @@ expect(james.toSee(TodoListItems.Displayed)).eventually.equal([ 'Buy some milk'

The Goal of an Actor is represented by the subject of the scenario:

``` gherkin
```gherkin
Scenario: Adding the first todo item
```

@@ -0,0 +1,24 @@
const
port = process.env.PORT || 3000,
runningInDevMode = `${ process.env.NODE_ENV }`.toLocaleLowerCase() === 'test';

(runningInDevMode ? inMemoryServer() : compiledServer())
.use(require('morgan')('combined'))
.listen(port, () => console.log(`Calculator server started on port ${ port }`));

// ---

function inMemoryServer() {
require('ts-node/register');
return require('./src/rest-api');
}

function compiledServer() {
try {
return require('./lib/rest-api');
}
catch(e) {
console.error('Remember to compile the module before trying to start the server: npm run compile');
process.exit(1);
}
}
@@ -0,0 +1,10 @@
{
"ignore": [
"spec/**/*.ts",
"node_modules"
],
"watch": [
"src"
],
"ext": "ts"
}

0 comments on commit ad0a677

Please sign in to comment.