-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dom fixture for autofilled form state (#17951)
- Loading branch information
1 parent
3e9251d
commit 2078aa9
Showing
3 changed files
with
121 additions
and
0 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
60 changes: 60 additions & 0 deletions
60
fixtures/dom/src/components/fixtures/form-state/ControlledFormFixture.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,60 @@ | ||
import Fixture from '../../Fixture'; | ||
const React = window.React; | ||
|
||
class ControlledFormFixture extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = {name: '', email: ''}; | ||
|
||
this.handleEmailChange = this.handleEmailChange.bind(this); | ||
this.handleNameChange = this.handleNameChange.bind(this); | ||
} | ||
|
||
handleEmailChange(event) { | ||
this.setState({email: event.target.value}); | ||
} | ||
|
||
handleNameChange(event) { | ||
this.setState({name: event.target.value}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Fixture> | ||
<form> | ||
<label> | ||
Name: | ||
<input | ||
type="text" | ||
value={this.state.name} | ||
onChange={this.handleNameChange} | ||
name="name" | ||
x-autocompletetype="name" | ||
/> | ||
</label> | ||
<br /> | ||
<label> | ||
Email: | ||
<input | ||
type="text" | ||
value={this.state.email} | ||
onChange={this.handleEmailChange} | ||
name="email" | ||
x-autocompletetype="email" | ||
/> | ||
</label> | ||
</form> | ||
<br /> | ||
<div> | ||
<span>States</span> | ||
<br /> | ||
<span>Name: {this.state.name}</span> | ||
<br /> | ||
<span>Email: {this.state.email}</span> | ||
</div> | ||
</Fixture> | ||
); | ||
} | ||
} | ||
|
||
export default ControlledFormFixture; |
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,60 @@ | ||
import FixtureSet from '../../FixtureSet'; | ||
import TestCase from '../../TestCase'; | ||
import ControlledFormFixture from './ControlledFormFixture'; | ||
const React = window.React; | ||
|
||
export default class FormStateCases extends React.Component { | ||
render() { | ||
return ( | ||
<FixtureSet title="Form State"> | ||
<TestCase | ||
title="Form state autofills from browser" | ||
description="Form start should autofill/autocomplete if user has autocomplete/autofill information saved. The user may need to set-up autofill or autocomplete with their specific browser."> | ||
<TestCase.Steps> | ||
<li> | ||
Set up autofill/autocomplete for your browser. | ||
<br /> | ||
Instructions: | ||
<ul> | ||
<li> | ||
<SafeLink | ||
href="https://support.google.com/chrome/answer/142893?co=GENIE.Platform%3DDesktop&hl=en" | ||
text="Google Chrome" | ||
/> | ||
</li> | ||
<li> | ||
<SafeLink | ||
href="https://support.mozilla.org/en-US/kb/autofill-logins-firefox" | ||
text="Mozilla FireFox" | ||
/> | ||
</li> | ||
<li> | ||
<SafeLink | ||
href="https://support.microsoft.com/en-us/help/4027718/microsoft-edge-automatically-fill-info" | ||
text="Microsoft Edge" | ||
/> | ||
</li> | ||
</ul> | ||
</li> | ||
<li>Click into any input.</li> | ||
<li>Select any autofill option.</li> | ||
</TestCase.Steps> | ||
<TestCase.ExpectedResult> | ||
Autofill options should appear when clicking into fields. Selected | ||
autofill options should change state (shown underneath, under | ||
"States"). | ||
</TestCase.ExpectedResult> | ||
<ControlledFormFixture /> | ||
</TestCase> | ||
</FixtureSet> | ||
); | ||
} | ||
} | ||
|
||
const SafeLink = ({text, href}) => { | ||
return ( | ||
<a target="_blank" rel="noreferrer" href={href}> | ||
{text} | ||
</a> | ||
); | ||
}; |