This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(todomvc): add todomvc example project
- Loading branch information
Showing
51 changed files
with
12,757 additions
and
47 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.DS_Store | ||
coverage/ | ||
dist/ | ||
error-screenshot.png | ||
lerna-debug.log | ||
node_modules/ | ||
npm-debug.log | ||
|
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
2 changes: 1 addition & 1 deletion
2
@pageobject/base/src/Component.test.ts → @pageobject/base/src/tests/Component.test.ts
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
2 changes: 1 addition & 1 deletion
2
@pageobject/base/src/Predicate.test.ts → @pageobject/base/src/tests/Predicate.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Predicate} from '.'; | ||
import {Predicate} from '..'; | ||
|
||
interface JestGlobal { | ||
expect?: typeof expect; | ||
|
2 changes: 1 addition & 1 deletion
2
@pageobject/base/src/Test.test.ts → @pageobject/base/src/tests/Test.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Effect, Predicate, Test} from '.'; | ||
import {Effect, Predicate, Test} from '..'; | ||
|
||
const {is} = Predicate; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../protractor/src/ProtractorAdapter.spec.ts → ...actor/src/tests/ProtractorAdapter.spec.ts
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
2 changes: 1 addition & 1 deletion
2
...ct/puppeteer/src/PuppeteerAdapter.test.ts → ...peteer/src/tests/PuppeteerAdapter.test.ts
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
2 changes: 1 addition & 1 deletion
2
...ium-webdriver/src/SeleniumAdapter.test.ts → ...bdriver/src/tests/SeleniumAdapter.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# @pageobject/todomvc | ||
|
||
> TODO. | ||
--- | ||
|
||
Copyright (c) 2017-present, Clemens Akens. Released under the terms of the [MIT License][internal-license]. | ||
|
||
[internal-license]: https://github.com/clebert/pageobject/blob/master/LICENSE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@pageobject/todomvc", | ||
"private": true, | ||
"dependencies": { | ||
"@pageobject/base": "^9.1.0", | ||
"@pageobject/puppeteer": "^9.1.0", | ||
"@pageobject/web": "^9.1.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {WebComponent} from '@pageobject/web'; | ||
|
||
export class Label extends WebComponent { | ||
public readonly selector: string = 'label'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {WebComponent} from '@pageobject/web'; | ||
|
||
export class NewTodoInput extends WebComponent { | ||
public readonly selector: string = '.new-todo'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {WebComponent} from '@pageobject/web'; | ||
import {Label} from './Label'; | ||
import {Toggle} from './Toggle'; | ||
|
||
export class Todo extends WebComponent { | ||
public readonly selector: string = 'li'; | ||
|
||
public readonly label = new Label(this.adapter, this); | ||
public readonly toggle = new Toggle(this.adapter, this); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {WebComponent} from '@pageobject/web'; | ||
import {Todo} from './Todo'; | ||
|
||
export class TodoList extends WebComponent { | ||
public readonly selector: string = '.todo-list'; | ||
|
||
public readonly todos = new Todo(this.adapter, this); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {Test, TestCallback} from '@pageobject/base'; | ||
import {PuppeteerAdapter} from '@pageobject/puppeteer'; | ||
import {WebComponent} from '@pageobject/web'; | ||
import {NewTodoInput} from './NewTodoInput'; | ||
import {TodoList} from './TodoList'; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000; | ||
|
||
const args = | ||
process.env.CI === 'true' | ||
? ['--disable-dev-shm-usage', '--disable-setuid-sandbox', '--no-sandbox'] | ||
: []; | ||
|
||
export class TodoMVC extends WebComponent { | ||
public static jest(name: string, callback: TestCallback<TodoMVC>): void { | ||
test(name, async () => { | ||
const adapter = await PuppeteerAdapter.create( | ||
{args}, | ||
{waitUntil: 'domcontentloaded'} | ||
); | ||
|
||
try { | ||
await Test.run(new TodoMVC(adapter), 10, callback); | ||
} catch (e) { | ||
await adapter.page.screenshot({path: 'error-screenshot.png'}); | ||
|
||
throw e; | ||
} finally { | ||
await adapter.quit(); | ||
} | ||
}); | ||
} | ||
|
||
public readonly selector: string = '.todoapp'; | ||
|
||
public readonly newTodoInput = new NewTodoInput(this.adapter, this); | ||
public readonly todoList = new TodoList(this.adapter, this); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Effect} from '@pageobject/base'; | ||
import {WebComponent} from '@pageobject/web'; | ||
|
||
export class Toggle extends WebComponent { | ||
public readonly selector: string = '.toggle'; | ||
|
||
public isChecked(): Effect<boolean> { | ||
return async () => | ||
(await this.findUniqueNode()).execute( | ||
(element: HTMLInputElement) => element.checked | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Predicate} from '@pageobject/base'; | ||
import {TodoMVC} from '../TodoMVC'; | ||
|
||
const {is} = Predicate; | ||
|
||
TodoMVC.jest('Completing a todo', (test, app) => { | ||
test.perform(app.page.goto('http://todomvc.com/examples/react/#/'), 30); | ||
|
||
test | ||
.assert(app.newTodoInput.hasFocus(), is(true)) | ||
.perform(app.keyboard.type('My todo')) | ||
.perform(app.keyboard.press('Enter')); | ||
|
||
const todo = app.todoList.todos.first(); | ||
|
||
test | ||
.assert(todo.toggle.isChecked(), is(false)) | ||
.perform(todo.toggle.click()) | ||
.assert(todo.toggle.isChecked(), is(true)); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Predicate} from '@pageobject/base'; | ||
import {TodoMVC} from '../TodoMVC'; | ||
|
||
const {is} = Predicate; | ||
|
||
TodoMVC.jest('Creating todos', (test, app) => { | ||
test.perform(app.page.goto('http://todomvc.com/examples/react/#/'), 30); | ||
|
||
test | ||
.assert(app.newTodoInput.hasFocus(), is(true)) | ||
.perform(app.keyboard.type('My first todo')) | ||
.perform(app.keyboard.press('Enter')) | ||
|
||
.assert(app.newTodoInput.hasFocus(), is(true)) | ||
.perform(app.keyboard.type('My second todo')) | ||
.perform(app.keyboard.press('Enter')) | ||
|
||
.assert(app.todoList.todos.first().label.getText(), is('My first todo')) | ||
.assert(app.todoList.todos.last().label.getText(), is('My second todo')); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src/**/*.ts", "types/**/*.d.ts"] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tslint.json" | ||
} |
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
2 changes: 1 addition & 1 deletion
2
@pageobject/web/src/JSDOMAdapter.test.ts → ...object/web/src/tests/JSDOMAdapter.test.ts
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
2 changes: 1 addition & 1 deletion
2
@pageobject/web/src/WebComponent.test.ts → ...object/web/src/tests/WebComponent.test.ts
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.