Skip to content

Commit 55e4e12

Browse files
authored
Setup cypress testing suite, and w3c web platform tests (#197)
* adding tests * 50% passing * 28 passing, 12 failing * 36 pass, 4 fail * fix compile error * fix build * Better comments * better comments for block: nearest * tiny adjustment * just two tests left that are failing * 1 test left * all 40 tests are passing * add support for scrollMode * compiler error * retry
1 parent 91227f9 commit 55e4e12

File tree

17 files changed

+464
-113
lines changed

17 files changed

+464
-113
lines changed

integration-tests/core/components/Expect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default class Expect extends Component {
1717
state = { test: undefined }
1818

1919
componentDidMount() {
20+
console.log('interesting')
2021
const node = this.target.current
2122
const { setup, options, toBe } = this.props
2223

@@ -29,9 +30,8 @@ export default class Expect extends Component {
2930
return this.props.children({
3031
target: (
3132
<div
32-
className="bulls-eye"
33+
className={`test-assertion test-${this.state.test}`}
3334
ref={this.target}
34-
data-test={this.state.test}
3535
/>
3636
),
3737
})

integration-tests/core/cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://localhost:3000"
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('ScrollLogicalPosition: block', function() {
2+
before(function() {
3+
cy.visit('/block')
4+
})
5+
6+
const simplePositions = ['start', 'center', 'end']
7+
context('one scrollbox', () => {
8+
simplePositions.forEach(position => {
9+
it(`should align to ${position} correctly`, () => {
10+
cy.get(`#${position}`).click()
11+
cy.wait(200)
12+
cy.get('.test-assertion').should('have.class', 'test-pass')
13+
cy.wait(200)
14+
})
15+
})
16+
})
17+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
module.exports = (on, config) => {
15+
// `on` is used to hook into various events Cypress emits
16+
// `config` is the resolved Cypress config
17+
}
131 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This is will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

integration-tests/core/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
"next": "5.1.0",
1515
"react": "16.3.2",
1616
"react-dom": "16.3.2"
17+
},
18+
"devDependencies": {
19+
"cypress": "2.1.0"
1720
}
1821
}

integration-tests/core/pages/block.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const tests = {
3030
options={{ block: 'center' }}
3131
toBe={node => {
3232
const clientRect = node.getBoundingClientRect()
33-
return clientRect.top === window.innerHeight / 2 - SIZE / 2
33+
return clientRect.top === Math.round(window.innerHeight / 2 - SIZE / 2)
3434
}}
3535
>
3636
{({ target }) => (
@@ -63,31 +63,26 @@ const tests = {
6363
const keys = Object.keys(tests).sort()
6464

6565
export default class extends Component {
66-
state = { test: keys[0], mounted: false }
67-
68-
componentDidMount() {
69-
// @TODO Workaround annoying chrome behavior, implement event listeners like window.onload instead
70-
setTimeout(() => this.setState({ mounted: true }), 100)
71-
}
66+
state = { test: false }
7267

7368
render() {
7469
const buttons = keys
75-
const ActiveTest = tests[this.state.test]
70+
const ActiveTest = this.state.test ? tests[this.state.test] : false
7671
return (
7772
<Fragment>
7873
<navbar className="test-switcher">
7974
{buttons.map(name => (
80-
<button key={name} onClick={() => this.setState({ test: name })}>
75+
<button
76+
key={name}
77+
onClick={() => this.setState({ test: name })}
78+
id={name}
79+
>
8180
{name}
8281
</button>
8382
))}
8483
</navbar>
8584

86-
{this.state.mounted ? (
87-
<ActiveTest key={this.state.test} />
88-
) : (
89-
'mounting…'
90-
)}
85+
{(ActiveTest && <ActiveTest key={this.state.test} />) || 'Ready!'}
9186
</Fragment>
9287
)
9388
}

0 commit comments

Comments
 (0)