Skip to content
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 32 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
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 Dec 16, 2016
3d06fb7
Properly slice out question mark in query string
nhunzaker Dec 16, 2016
bbb643f
Add React options loader.
nhunzaker Dec 16, 2016
65d4795
Make toggleable test cases
nhunzaker Dec 17, 2016
e86948f
Update input example readme
nhunzaker Dec 19, 2016
05ace73
Move new example changes to fixtures folder
nhunzaker Dec 19, 2016
92fe367
Add select, textarea, and range input fixtures
nhunzaker Dec 22, 2016
187bcaf
Update section on number inputs
nhunzaker Dec 22, 2016
f37ff31
Fix lint issues in react-loader
nhunzaker Dec 22, 2016
bf23548
Display value for controlled select and textarea
Dec 22, 2016
5deb982
Use create-react-app for fixtures application
Jan 3, 2017
52a1ee4
Remove duplicate fixture components
Jan 3, 2017
6de9ff2
Remove babel include from react-loader
nhunzaker Jan 4, 2017
f10a1a7
Copy local build before starting
nhunzaker Jan 4, 2017
85aa7ee
Add test prompt message when no fixture is selected
nhunzaker Jan 4, 2017
c31297b
Remove extraneous binds from some fixtures
nhunzaker Jan 4, 2017
b006d05
Test, not text. 🔤
nhunzaker Jan 4, 2017
1d1dd60
Patch in console for IE9
nhunzaker Jan 4, 2017
2d75ae9
Consolidate styles into single file
nhunzaker Jan 4, 2017
3a51db2
Fix some CORS issues in IE
nhunzaker Jan 4, 2017
565d63b
Remove trailing comma, causing crash in IE11
nhunzaker Jan 4, 2017
d585590
Address lint issues.
nhunzaker Jan 4, 2017
5e53c0c
Add missing semicolon
nhunzaker Jan 4, 2017
9617166
Move current fixtures into dom folder
nhunzaker Jan 6, 2017
9d3ceb6
Update readme for DOM Fixtures
nhunzaker Jan 6, 2017
c79b3f1
Fix relative reference to build folder in DOM fixtures
nhunzaker Jan 6, 2017
3c53d31
Move build fixtures to fixtures/build
nhunzaker Jan 6, 2017
3d6a63d
Remove primitive dom fixture READMEs for some test cases
nhunzaker Jan 6, 2017
2085542
Remove fixture react build files from git tracking
Jan 6, 2017
429da39
Move build fixtures to fixtures/packaging, updated paths
Jan 9, 2017
2f8a3e5
Use absolute paths for resolve.root in webpack packaging fixtures
Jan 9, 2017
2dbff6e
Updating paths in packaging fixtures README
Jan 9, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ docs/downloads/*.zip
docs/vendor/bundle
examples/shared/*.js
examples/**/bundle.js
fixtures/dom/public/react-dom.js
fixtures/dom/public/react.js
test/the-files-to-test.generated.js
*.log*
chrome-user-data
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, 👍

Expand Down
10 changes: 0 additions & 10 deletions fixtures/brunch/package.json

This file was deleted.

17 changes: 17 additions & 0 deletions fixtures/dom/.gitignore
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
17 changes: 17 additions & 0 deletions fixtures/dom/README.md
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.
20 changes: 20 additions & 0 deletions fixtures/dom/package.json
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 added fixtures/dom/public/favicon.ico
Binary file not shown.
32 changes: 32 additions & 0 deletions fixtures/dom/public/index.html
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>
43 changes: 43 additions & 0 deletions fixtures/dom/public/react-loader.js
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>');
}
20 changes: 20 additions & 0 deletions fixtures/dom/src/components/App.js
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;
68 changes: 68 additions & 0 deletions fixtures/dom/src/components/Header.js
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;
28 changes: 28 additions & 0 deletions fixtures/dom/src/components/fixtures/index.js
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 fixtures/dom/src/components/fixtures/range-inputs/index.js
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;
37 changes: 37 additions & 0 deletions fixtures/dom/src/components/fixtures/selects/index.js
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;
Loading