From 14863c9a8722281b6bf1d0d9fc7b95b44e189354 Mon Sep 17 00:00:00 2001
From: Sasha Aickin
Date: Sun, 26 Mar 2017 20:51:40 -0700
Subject: [PATCH 1/4] Adding SSR test for form fields.
---
scripts/fiber/tests-failing.txt | 36 ++
scripts/fiber/tests-passing-except-dev.txt | 30 +
scripts/fiber/tests-passing.txt | 57 +-
.../ReactDOMServerIntegration-test.js | 562 +++++++++++++++++-
4 files changed, 670 insertions(+), 15 deletions(-)
diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt
index b99355d063..3bd47469ac 100644
--- a/scripts/fiber/tests-failing.txt
+++ b/scripts/fiber/tests-failing.txt
@@ -102,6 +102,42 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
* renders >,<, and & as single child with client render on top of good server markup
* renders >,<, and & as multiple children with server string render
* renders >,<, and & as multiple children with client render on top of good server markup
+* renders an input with a value and an onChange with client render on top of good server markup
+* renders an input with a value and readOnly with client render on top of good server markup
+* renders an input with a value and no onChange/readOnly with client render on top of good server markup
+* renders an input with a defaultValue with client render on top of good server markup
+* renders an input value overriding defaultValue with client render on top of good server markup
+* renders an input value overriding defaultValue no matter the prop order with client render on top of good server markup
+* renders a checkbox that is checked with an onChange with client render on top of good server markup
+* renders a checkbox that is checked with readOnly with client render on top of good server markup
+* renders a checkbox that is checked and no onChange/readOnly with client render on top of good server markup
+* renders a checkbox with defaultChecked with client render on top of good server markup
+* renders a checkbox checked overriding defaultChecked with client render on top of good server markup
+* renders a checkbox checked overriding defaultChecked no matter the prop order with client render on top of good server markup
+* renders a textarea with a value and an onChange with client render on top of good server markup
+* renders a textarea with a value and readOnly with client render on top of good server markup
+* renders a textarea with a value and no onChange/readOnly with client render on top of good server markup
+* renders a textarea with a defaultValue with client render on top of good server markup
+* renders a textarea value overriding defaultValue with client render on top of good server markup
+* renders a textarea value overriding defaultValue no matter the prop order with client render on top of good server markup
+* renders a select with a value and an onChange with client render on top of good server markup
+* renders a select with a value and readOnly with client render on top of good server markup
+* renders a select with a multiple values and an onChange with client render on top of good server markup
+* renders a select with a multiple values and readOnly with client render on top of good server markup
+* renders a select with a value and no onChange/readOnly with client render on top of good server markup
+* renders a select with a defaultValue with client render on top of good server markup
+* renders a select value overriding defaultValue with client render on top of good server markup
+* renders a select value overriding defaultValue no matter the prop order with client render on top of good server markup
+* renders a controlled text input with client render on top of good server markup
+* renders a controlled textarea with client render on top of good server markup
+* renders a controlled checkbox with client render on top of good server markup
+* renders a controlled select with client render on top of good server markup
+* should not blow away user-entered text on successful reconnect to an uncontrolled input
+* should not blow away user-entered text on successful reconnect to a controlled input
+* should not blow away user-entered text on successful reconnect to an uncontrolled checkbox
+* should not blow away user-entered text on successful reconnect to a controlled checkbox
+* should not blow away user-selected value on successful reconnect to an uncontrolled select
+* should not blow away user-selected value on successful reconnect to an controlled select
* renders class child with context with client render on top of good server markup
* renders stateless child with context with client render on top of good server markup
* renders class child without context with client render on top of good server markup
diff --git a/scripts/fiber/tests-passing-except-dev.txt b/scripts/fiber/tests-passing-except-dev.txt
index 5b7ce16d92..203bd2f0e5 100644
--- a/scripts/fiber/tests-passing-except-dev.txt
+++ b/scripts/fiber/tests-passing-except-dev.txt
@@ -95,6 +95,36 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
* throws when rendering an undefined component with client render on top of bad server markup
* throws when rendering a number component with clean client render
* throws when rendering a number component with client render on top of bad server markup
+* renders an input with a value and an onChange with client render on top of bad server markup
+* renders an input with a value and readOnly with client render on top of bad server markup
+* renders an input with a value and no onChange/readOnly with client render on top of bad server markup
+* renders an input with a defaultValue with client render on top of bad server markup
+* renders an input value overriding defaultValue with client render on top of bad server markup
+* renders an input value overriding defaultValue no matter the prop order with client render on top of bad server markup
+* renders a checkbox that is checked with an onChange with client render on top of bad server markup
+* renders a checkbox that is checked with readOnly with client render on top of bad server markup
+* renders a checkbox that is checked and no onChange/readOnly with client render on top of bad server markup
+* renders a checkbox with defaultChecked with client render on top of bad server markup
+* renders a checkbox checked overriding defaultChecked with client render on top of bad server markup
+* renders a checkbox checked overriding defaultChecked no matter the prop order with client render on top of bad server markup
+* renders a textarea with a value and an onChange with client render on top of bad server markup
+* renders a textarea with a value and readOnly with client render on top of bad server markup
+* renders a textarea with a value and no onChange/readOnly with client render on top of bad server markup
+* renders a textarea with a defaultValue with client render on top of bad server markup
+* renders a textarea value overriding defaultValue with client render on top of bad server markup
+* renders a textarea value overriding defaultValue no matter the prop order with client render on top of bad server markup
+* renders a select with a value and an onChange with client render on top of bad server markup
+* renders a select with a value and readOnly with client render on top of bad server markup
+* renders a select with a multiple values and an onChange with client render on top of bad server markup
+* renders a select with a multiple values and readOnly with client render on top of bad server markup
+* renders a select with a value and no onChange/readOnly with client render on top of bad server markup
+* renders a select with a defaultValue with client render on top of bad server markup
+* renders a select value overriding defaultValue with client render on top of bad server markup
+* renders a select value overriding defaultValue no matter the prop order with client render on top of bad server markup
+* renders a controlled text input with client render on top of bad server markup
+* renders a controlled textarea with client render on top of bad server markup
+* renders a controlled checkbox with client render on top of bad server markup
+* renders a controlled select with client render on top of bad server markup
* renders class child with context with client render on top of bad server markup
* renders stateless child with context with client render on top of bad server markup
* renders class child without context with client render on top of bad server markup
diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt
index 05ca4a1b2b..79e243d664 100644
--- a/scripts/fiber/tests-passing.txt
+++ b/scripts/fiber/tests-passing.txt
@@ -1154,6 +1154,62 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
* throws when rendering string with server string render
* throws when rendering string with clean client render
* throws when rendering string with client render on top of bad server markup
+* renders an input with a value and an onChange with server string render
+* renders an input with a value and an onChange with clean client render
+* renders an input with a value and readOnly with server string render
+* renders an input with a value and readOnly with clean client render
+* renders an input with a value and no onChange/readOnly with server string render
+* renders an input with a value and no onChange/readOnly with clean client render
+* renders an input with a defaultValue with server string render
+* renders an input with a defaultValue with clean client render
+* renders an input value overriding defaultValue with server string render
+* renders an input value overriding defaultValue with clean client render
+* renders an input value overriding defaultValue no matter the prop order with server string render
+* renders an input value overriding defaultValue no matter the prop order with clean client render
+* renders a checkbox that is checked with an onChange with server string render
+* renders a checkbox that is checked with an onChange with clean client render
+* renders a checkbox that is checked with readOnly with server string render
+* renders a checkbox that is checked with readOnly with clean client render
+* renders a checkbox that is checked and no onChange/readOnly with server string render
+* renders a checkbox that is checked and no onChange/readOnly with clean client render
+* renders a checkbox with defaultChecked with server string render
+* renders a checkbox with defaultChecked with clean client render
+* renders a checkbox checked overriding defaultChecked with server string render
+* renders a checkbox checked overriding defaultChecked with clean client render
+* renders a checkbox checked overriding defaultChecked no matter the prop order with server string render
+* renders a checkbox checked overriding defaultChecked no matter the prop order with clean client render
+* renders a textarea with a value and an onChange with server string render
+* renders a textarea with a value and an onChange with clean client render
+* renders a textarea with a value and readOnly with server string render
+* renders a textarea with a value and readOnly with clean client render
+* renders a textarea with a value and no onChange/readOnly with server string render
+* renders a textarea with a value and no onChange/readOnly with clean client render
+* renders a textarea with a defaultValue with server string render
+* renders a textarea with a defaultValue with clean client render
+* renders a textarea value overriding defaultValue with server string render
+* renders a textarea value overriding defaultValue with clean client render
+* renders a textarea value overriding defaultValue no matter the prop order with server string render
+* renders a textarea value overriding defaultValue no matter the prop order with clean client render
+* renders a select with a value and an onChange with server string render
+* renders a select with a value and an onChange with clean client render
+* renders a select with a value and readOnly with server string render
+* renders a select with a value and readOnly with clean client render
+* renders a select with a multiple values and an onChange with server string render
+* renders a select with a multiple values and an onChange with clean client render
+* renders a select with a multiple values and readOnly with server string render
+* renders a select with a multiple values and readOnly with clean client render
+* renders a select with a value and no onChange/readOnly with server string render
+* renders a select with a value and no onChange/readOnly with clean client render
+* renders a select with a defaultValue with server string render
+* renders a select with a defaultValue with clean client render
+* renders a select value overriding defaultValue with server string render
+* renders a select value overriding defaultValue with clean client render
+* renders a select value overriding defaultValue no matter the prop order with server string render
+* renders a select value overriding defaultValue no matter the prop order with clean client render
+* renders a controlled text input with clean client render
+* renders a controlled textarea with clean client render
+* renders a controlled checkbox with clean client render
+* renders a controlled select with clean client render
* renders class child with context with server string render
* renders class child with context with clean client render
* renders stateless child with context with server string render
@@ -1193,7 +1249,6 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
* should reconnect Pure Component to Bare Element
* should reconnect Bare Element to Bare Element
* should reconnect a div with a number and string version of number
-* should reconnect if component trees differ but resulting markup is the same
src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
* updates a mounted text component in place
diff --git a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
index 2eda9c38fc..403254c66f 100644
--- a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
+++ b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
@@ -16,6 +16,7 @@ let React;
let ReactDOM;
let ReactDOMServer;
let ReactDOMFeatureFlags;
+let ReactTestUtils;
// Helper functions for rendering tests
// ====================================
@@ -209,6 +210,7 @@ function resetModules() {
ReactDOM = require('ReactDOM');
ReactDOMServer = require('ReactDOMServer');
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
+ ReactTestUtils = require('ReactTestUtils');
ExecutionEnvironment = require('ExecutionEnvironment');
}
@@ -1022,6 +1024,552 @@ describe('ReactDOMServerIntegration', () => {
});
});
+ describe('form controls', function() {
+ describe('inputs', function() {
+ itRenders('an input with a value and an onChange', async render => {
+ const e = await render( {}} />);
+ expect(e.value).toBe('foo');
+ });
+
+ itRenders('an input with a value and readOnly', async render => {
+ const e = await render();
+ expect(e.value).toBe('foo');
+ });
+
+ itRenders(
+ 'an input with a value and no onChange/readOnly',
+ async render => {
+ // this configuration should raise a dev warning that value without
+ // onChange or readOnly is a mistake.
+ const e = await render(, 1);
+ expect(e.value).toBe('foo');
+ },
+ );
+
+ itRenders('an input with a defaultValue', async render => {
+ const e = await render();
+ expect(e.value).toBe('foo');
+ expect(e.getAttribute('defaultValue')).toBe(null);
+ });
+
+ itRenders('an input value overriding defaultValue', async render => {
+ const e = await render(
+ ,
+ 1,
+ );
+ expect(e.value).toBe('foo');
+ expect(e.getAttribute('defaultValue')).toBe(null);
+ });
+
+ itRenders(
+ 'an input value overriding defaultValue no matter the prop order',
+ async render => {
+ const e = await render(
+ ,
+ 1,
+ );
+ expect(e.value).toBe('foo');
+ expect(e.getAttribute('defaultValue')).toBe(null);
+ },
+ );
+ });
+
+ describe('checkboxes', function() {
+ itRenders('a checkbox that is checked with an onChange', async render => {
+ const e = await render(
+ {}} />,
+ );
+ expect(e.checked).toBe(true);
+ });
+
+ itRenders('a checkbox that is checked with readOnly', async render => {
+ const e = await render(
+ ,
+ );
+ expect(e.checked).toBe(true);
+ });
+
+ itRenders(
+ 'a checkbox that is checked and no onChange/readOnly',
+ async render => {
+ // this configuration should raise a dev warning that checked without
+ // onChange or readOnly is a mistake.
+ const e = await render(, 1);
+ expect(e.checked).toBe(true);
+ },
+ );
+
+ itRenders('a checkbox with defaultChecked', async render => {
+ const e = await render();
+ expect(e.checked).toBe(true);
+ expect(e.getAttribute('defaultChecked')).toBe(null);
+ });
+
+ itRenders(
+ 'a checkbox checked overriding defaultChecked',
+ async render => {
+ const e = await render(
+ ,
+ 1,
+ );
+ expect(e.checked).toBe(true);
+ expect(e.getAttribute('defaultChecked')).toBe(null);
+ },
+ );
+
+ itRenders(
+ 'a checkbox checked overriding defaultChecked no matter the prop order',
+ async render => {
+ const e = await render(
+ ,
+ 1,
+ );
+ expect(e.checked).toBe(true);
+ expect(e.getAttribute('defaultChecked')).toBe(null);
+ },
+ );
+ });
+
+ describe('textareas', function() {
+ // textareas
+ // ---------
+ itRenders('a textarea with a value and an onChange', async render => {
+ const e = await render(
- If you can see this, React is not working right. This is probably because you're viewing
- this on your file system instead of a web server.
- Try navigating to the React root
-
- If you can see this, React is not working right. This is probably because you're viewing
- this on your file system instead of a web server. Try running
-
- To install React, follow the instructions on
- GitHub.
-
-
- If you can see this, React is not working right.
- If you checked out the source from GitHub make sure to run grunt.
-
-
-
-
Example Details
-
- This example demonstrates Web Component / React Component interoperability
- by rendering a React Component, which renders a Web Component, which renders
- another React Component in the Web Component's shadow DOM.
-
-
-
-
-
-
-
-
-
diff --git a/fixtures/fiber-debugger/.env b/fixtures/fiber-debugger/.env
new file mode 100644
index 0000000000..9be7932319
--- /dev/null
+++ b/fixtures/fiber-debugger/.env
@@ -0,0 +1 @@
+NODE_PATH=../../build/packages
\ No newline at end of file
diff --git a/examples/fiber/debugger/.gitignore b/fixtures/fiber-debugger/.gitignore
similarity index 100%
rename from examples/fiber/debugger/.gitignore
rename to fixtures/fiber-debugger/.gitignore
diff --git a/examples/fiber/debugger/README.md b/fixtures/fiber-debugger/README.md
similarity index 100%
rename from examples/fiber/debugger/README.md
rename to fixtures/fiber-debugger/README.md
diff --git a/examples/fiber/debugger/package.json b/fixtures/fiber-debugger/package.json
similarity index 100%
rename from examples/fiber/debugger/package.json
rename to fixtures/fiber-debugger/package.json
diff --git a/examples/fiber/debugger/public/favicon.ico b/fixtures/fiber-debugger/public/favicon.ico
similarity index 100%
rename from examples/fiber/debugger/public/favicon.ico
rename to fixtures/fiber-debugger/public/favicon.ico
diff --git a/examples/fiber/debugger/public/index.html b/fixtures/fiber-debugger/public/index.html
similarity index 100%
rename from examples/fiber/debugger/public/index.html
rename to fixtures/fiber-debugger/public/index.html
diff --git a/examples/fiber/debugger/src/App.js b/fixtures/fiber-debugger/src/App.js
similarity index 100%
rename from examples/fiber/debugger/src/App.js
rename to fixtures/fiber-debugger/src/App.js
diff --git a/examples/fiber/debugger/src/Editor.js b/fixtures/fiber-debugger/src/Editor.js
similarity index 100%
rename from examples/fiber/debugger/src/Editor.js
rename to fixtures/fiber-debugger/src/Editor.js
diff --git a/examples/fiber/debugger/src/Fibers.js b/fixtures/fiber-debugger/src/Fibers.js
similarity index 100%
rename from examples/fiber/debugger/src/Fibers.js
rename to fixtures/fiber-debugger/src/Fibers.js
diff --git a/examples/fiber/debugger/src/describeFibers.js b/fixtures/fiber-debugger/src/describeFibers.js
similarity index 100%
rename from examples/fiber/debugger/src/describeFibers.js
rename to fixtures/fiber-debugger/src/describeFibers.js
diff --git a/examples/fiber/debugger/src/index.css b/fixtures/fiber-debugger/src/index.css
similarity index 100%
rename from examples/fiber/debugger/src/index.css
rename to fixtures/fiber-debugger/src/index.css
diff --git a/examples/fiber/debugger/src/index.js b/fixtures/fiber-debugger/src/index.js
similarity index 100%
rename from examples/fiber/debugger/src/index.js
rename to fixtures/fiber-debugger/src/index.js
diff --git a/examples/fiber/debugger/yarn.lock b/fixtures/fiber-debugger/yarn.lock
similarity index 100%
rename from examples/fiber/debugger/yarn.lock
rename to fixtures/fiber-debugger/yarn.lock
diff --git a/examples/fiber/index.html b/fixtures/fiber-triangle/index.html
similarity index 100%
rename from examples/fiber/index.html
rename to fixtures/fiber-triangle/index.html
diff --git a/fixtures/packaging/babel-standalone.html b/fixtures/packaging/babel-standalone.html
new file mode 100644
index 0000000000..ea37f34df0
--- /dev/null
+++ b/fixtures/packaging/babel-standalone.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file