-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic testing page for browser quicks #8589
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
49f74f1
Add basic testing page
nhunzaker 3d06fb7
Properly slice out question mark in query string
nhunzaker bbb643f
Add React options loader.
nhunzaker 65d4795
Make toggleable test cases
nhunzaker e86948f
Update input example readme
nhunzaker 05ace73
Move new example changes to fixtures folder
nhunzaker 92fe367
Add select, textarea, and range input fixtures
nhunzaker 187bcaf
Update section on number inputs
nhunzaker f37ff31
Fix lint issues in react-loader
nhunzaker bf23548
Display value for controlled select and textarea
5deb982
Use create-react-app for fixtures application
52a1ee4
Remove duplicate fixture components
6de9ff2
Remove babel include from react-loader
nhunzaker f10a1a7
Copy local build before starting
nhunzaker 85aa7ee
Add test prompt message when no fixture is selected
nhunzaker c31297b
Remove extraneous binds from some fixtures
nhunzaker b006d05
Test, not text. 🔤
nhunzaker 1d1dd60
Patch in console for IE9
nhunzaker 2d75ae9
Consolidate styles into single file
nhunzaker 3a51db2
Fix some CORS issues in IE
nhunzaker 565d63b
Remove trailing comma, causing crash in IE11
nhunzaker d585590
Address lint issues.
nhunzaker 5e53c0c
Add missing semicolon
nhunzaker 9617166
Move current fixtures into dom folder
nhunzaker 9d3ceb6
Update readme for DOM Fixtures
nhunzaker c79b3f1
Fix relative reference to build folder in DOM fixtures
nhunzaker 3c53d31
Move build fixtures to fixtures/build
nhunzaker 3d6a63d
Remove primitive dom fixture READMEs for some test cases
nhunzaker 2085542
Remove fixture react build files from git tracking
429da39
Move build fixtures to fixtures/packaging, updated paths
2f8a3e5
Use absolute paths for resolve.root in webpack packaging fixtures
2dbff6e
Updating paths in packaging fixtures README
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# testing | ||
coverage | ||
|
||
# production | ||
build | ||
public/react.js | ||
public/react-dom.js | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# DOM Fixtures | ||
|
||
A set of DOM test cases for quickly identifying browser issues. | ||
|
||
## Setup | ||
|
||
To reference a local build of React, first run `npm run build` at the root | ||
of the React project. Then: | ||
|
||
``` | ||
cd fixtures/dom | ||
npm install | ||
npm start | ||
``` | ||
|
||
The `start` command runs a script that copies over the local build of react into | ||
the public directory. |
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 @@ | ||
{ | ||
"name": "react-fixtures", | ||
"version": "0.1.0", | ||
"private": true, | ||
"devDependencies": { | ||
"react-scripts": "0.8.4" | ||
}, | ||
"dependencies": { | ||
"query-string": "^4.2.3", | ||
"react": "^15.4.1", | ||
"react-dom": "^15.4.1" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"prestart": "cp ../../build/{react,react-dom}.js public/", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
} | ||
} |
Binary file not shown.
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,32 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tag above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
|
||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
<script src="react-loader.js"></script> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
|
||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
|
||
To begin the development, run `npm start`. | ||
To create a production bundle, use `npm run build`. | ||
--> | ||
</body> | ||
</html> |
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,43 @@ | ||
/** | ||
* Take a version from the window query string and load a specific | ||
* version of React. | ||
* | ||
* @example | ||
* http://localhost:3000?version=15.4.1 | ||
* (Loads React 15.4.1) | ||
*/ | ||
|
||
var REACT_PATH = 'react.js'; | ||
var DOM_PATH = 'react-dom.js'; | ||
|
||
function parseQuery(qstr) { | ||
var query = {}; | ||
|
||
var a = qstr.substr(1).split('&'); | ||
|
||
for (var i = 0; i < a.length; i++) { | ||
var b = a[i].split('='); | ||
|
||
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || ''); | ||
} | ||
|
||
return query; | ||
} | ||
|
||
var query = parseQuery(window.location.search); | ||
var version = query.version || 'local'; | ||
|
||
if (version !== 'local') { | ||
REACT_PATH = 'https://unpkg.com/react@' + version + '/dist/react.min.js'; | ||
DOM_PATH = 'https://unpkg.com/react-dom@' + version + '/dist/react-dom.min.js'; | ||
} | ||
|
||
document.write('<script src="' + REACT_PATH + '"></script>'); | ||
|
||
// Versions earlier than 14 do not use ReactDOM | ||
if (version === 'local' || parseFloat(version, 10) > 0.13) { | ||
document.write('<script src="' + DOM_PATH + '"></script>'); | ||
} else { | ||
// Aliasing React to ReactDOM for compatability. | ||
document.write('<script>ReactDOM = React</script>'); | ||
} |
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 @@ | ||
const React = window.React; | ||
import Header from './Header'; | ||
import Fixtures from './fixtures'; | ||
|
||
import '../style.css'; | ||
|
||
const App = React.createClass({ | ||
render() { | ||
return ( | ||
<div> | ||
<Header /> | ||
<div className="container" > | ||
<Fixtures /> | ||
</div> | ||
</div> | ||
); | ||
}, | ||
}); | ||
|
||
export default App; |
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,68 @@ | ||
import { parse, stringify } from 'query-string'; | ||
const React = window.React; | ||
|
||
const Header = React.createClass({ | ||
getInitialState() { | ||
const query = parse(window.location.search); | ||
const version = query.version || 'local'; | ||
const versions = [version]; | ||
return { version, versions }; | ||
}, | ||
componentWillMount() { | ||
fetch('https://api.github.com/repos/facebook/react/tags', { mode: 'cors' }) | ||
.then(res => res.json()) | ||
.then(tags => { | ||
let versions = tags.map(tag => tag.name.slice(1)); | ||
versions = ['local', ...versions]; | ||
this.setState({ versions }); | ||
}); | ||
}, | ||
handleVersionChange(event) { | ||
const query = parse(window.location.search); | ||
query.version = event.target.value; | ||
if (query.version === 'local') { | ||
delete query.version; | ||
} | ||
window.location.search = stringify(query); | ||
}, | ||
handleFixtureChange(event) { | ||
window.location.pathname = event.target.value; | ||
}, | ||
render() { | ||
return ( | ||
<header className="header"> | ||
<div className="header__inner"> | ||
<span className="header__logo"> | ||
<img src="https://facebook.github.io/react/img/logo.svg" alt="" width="32" height="32" /> | ||
React Sandbox (v{React.version}) | ||
</span> | ||
|
||
<div className="header-controls"> | ||
<label htmlFor="example"> | ||
<span className="sr-only">Select an example</span> | ||
<select value={window.location.pathname} onChange={this.handleFixtureChange}> | ||
<option value="/">Select a Fixture</option> | ||
<option value="/range-inputs">Range Inputs</option> | ||
<option value="/text-inputs">Text Inputs</option> | ||
<option value="/selects">Selects</option> | ||
<option value="/textareas">Textareas</option> | ||
</select> | ||
</label> | ||
<label htmlFor="react_version"> | ||
<span className="sr-only">Select a version to test</span> | ||
<select | ||
value={this.state.version} | ||
onChange={this.handleVersionChange}> | ||
{this.state.versions.map(version => ( | ||
<option key={version} value={version}>{version}</option> | ||
))} | ||
</select> | ||
</label> | ||
</div> | ||
</div> | ||
</header> | ||
); | ||
}, | ||
}); | ||
|
||
export default Header; |
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,28 @@ | ||
const React = window.React; | ||
import RangeInputFixtures from './range-inputs'; | ||
import TextInputFixtures from './text-inputs'; | ||
import SelectFixtures from './selects'; | ||
import TextAreaFixtures from './textareas/'; | ||
|
||
/** | ||
* A simple routing component that renders the appropriate | ||
* fixture based on the location pathname. | ||
*/ | ||
const FixturesPage = React.createClass({ | ||
render() { | ||
switch (window.location.pathname) { | ||
case '/text-inputs': | ||
return <TextInputFixtures />; | ||
case '/range-inputs': | ||
return <RangeInputFixtures />; | ||
case '/selects': | ||
return <SelectFixtures />; | ||
case '/textareas': | ||
return <TextAreaFixtures />; | ||
default: | ||
return <p>Please select a test fixture.</p>; | ||
} | ||
}, | ||
}); | ||
|
||
module.exports = FixturesPage; |
28 changes: 28 additions & 0 deletions
28
fixtures/dom/src/components/fixtures/range-inputs/index.js
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,28 @@ | ||
const React = window.React; | ||
|
||
const RangeInputs = React.createClass({ | ||
getInitialState() { | ||
return { value: 0.5 }; | ||
}, | ||
onChange(event) { | ||
this.setState({ value: event.target.value }); | ||
}, | ||
render() { | ||
return ( | ||
<form> | ||
<fieldset> | ||
<legend>Controlled</legend> | ||
<input type="range" value={this.state.value} onChange={this.onChange} /> | ||
<span className="hint">Value: {this.state.value}</span> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Uncontrolled</legend> | ||
<input type="range" defaultValue={0.5} /> | ||
</fieldset> | ||
</form> | ||
); | ||
}, | ||
}); | ||
|
||
export default RangeInputs; |
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,37 @@ | ||
const React = window.React; | ||
|
||
const SelectFixture = React.createClass({ | ||
getInitialState() { | ||
return { value: '' }; | ||
}, | ||
onChange(event) { | ||
this.setState({ value: event.target.value }); | ||
}, | ||
render() { | ||
return ( | ||
<form> | ||
<fieldset> | ||
<legend>Controlled</legend> | ||
<select value={this.state.value} onChange={this.onChange}> | ||
<option value="">Select a color</option> | ||
<option value="red">Red</option> | ||
<option value="blue">Blue</option> | ||
<option value="green">Green</option> | ||
</select> | ||
<span className="hint">Value: {this.state.value}</span> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Uncontrolled</legend> | ||
<select defaultValue=""> | ||
<option value="">Select a color</option> | ||
<option value="red">Red</option> | ||
<option value="blue">Blue</option> | ||
<option value="gree">Green</option> | ||
</select> | ||
</fieldset> | ||
</form> | ||
); | ||
}, | ||
}); | ||
|
||
export default SelectFixture; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, 👍