Skip to content

Commit

Permalink
feat(playground): an in-memory todo list app
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Jul 1, 2020
1 parent bdba549 commit e164438
Show file tree
Hide file tree
Showing 7 changed files with 1,956 additions and 1,468 deletions.
2 changes: 1 addition & 1 deletion e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports.config = {
crew: [
ArtifactArchiver.storingArtifactsAt('./target/site/serenity'),
ConsoleReporter.forDarkTerminals(),
Photographer.whoWill(TakePhotosOfFailures), // or Photographer.whoWill(TakePhotosOfInteractions),
Photographer.whoWill(TakePhotosOfInteractions), // or Photographer.whoWill(TakePhotosOfInteractions),
new SerenityBDDReporter(),
]
},
Expand Down
16 changes: 13 additions & 3 deletions e2e/src/playground.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { contain, containAtLeastOneItemThat, Ensure, equals, not, property } from '@serenity-js/assertions';
import { actorCalled, actorInTheSpotlight, engage, Log } from '@serenity-js/core';
import {
contain,
containAtLeastOneItemThat,
Ensure,
equals,
isGreaterThan,
not,
property,
} from '@serenity-js/assertions';
import { actorCalled, actorInTheSpotlight, engage, Log, Note, TakeNote } from '@serenity-js/core';
import { LocalServer, StartLocalServer, StopLocalServer } from '@serenity-js/local-server';
import { Browser } from '@serenity-js/protractor';
import { logging } from 'protractor';
Expand All @@ -14,7 +22,7 @@ import {
Start,
ToggleItem,
} from './screenplay';
import { GetRequest, LastResponse, Send } from '@serenity-js/rest';
import { ChangeApiUrl, GetRequest, LastResponse, Send } from '@serenity-js/rest';

describe('Playground Todo App', () => {

Expand All @@ -26,6 +34,7 @@ describe('Playground Todo App', () => {
Log.the(LocalServer.url()),
Send.a(GetRequest.to(LocalServer.url())),
Ensure.that(LastResponse.status(), equals(200)),
TakeNote.of(LocalServer.url()),
));

afterAll(() =>
Expand All @@ -37,6 +46,7 @@ describe('Playground Todo App', () => {

it('can record new items', () =>
actorCalled('Jasmine').attemptsTo(
ChangeApiUrl.to(Note.of(LocalServer.url())),
Start.withAnEmptyList(),
RecordItem.called('Walk a dog'),
Ensure.that(RecordedItems(), contain('Walk a dog')),
Expand Down
5 changes: 4 additions & 1 deletion e2e/src/screenplay/Actors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Actor, Cast } from '@serenity-js/core';
import { Actor, Cast, TakeNotes } from '@serenity-js/core';
import { ManageALocalServer } from '@serenity-js/local-server';
import { BrowseTheWeb } from '@serenity-js/protractor';

Expand All @@ -12,12 +12,15 @@ export class Actors implements Cast {
switch (actor.name) {
case 'Adam':
return actor.whoCan(
TakeNotes.usingASharedNotepad(),
BrowseTheWeb.using(protractor.browser), // todo: fixme, remove
ManageALocalServer.runningAHttpListener(server), // todo: `server` should be parametrised
CallAnApi.at('http://localhost'),
);
case 'Jasmine':
default:
return actor.whoCan(
TakeNotes.usingASharedNotepad(),
CallAnApi.at(protractor.browser.baseUrl),
BrowseTheWeb.using(protractor.browser),
);
Expand Down
Loading

0 comments on commit e164438

Please sign in to comment.