-
Notifications
You must be signed in to change notification settings - Fork 64
Textarea functional tests #324
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a6698f8
Add Textarea functional tests
pottedmeat 5a402fe
Move extraClasses to wrapped div
pottedmeat 745e838
Skip Safari 9 - add version log to allow targeting
pottedmeat 22a23d6
activeElement workaround. Skip browsers.
pottedmeat bfd9088
Target internet explorer
pottedmeat 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 hidden or 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 contains hidden or 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 contains hidden or 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,164 @@ | ||
| const { registerSuite } = intern.getInterface('object'); | ||
| const { assert } = intern.getPlugin('chai'); | ||
|
|
||
| import { Remote } from 'intern/lib/executors/Node'; | ||
| import keys from '@theintern/leadfoot/keys'; | ||
| import * as css from '../../styles/textarea.m.css'; | ||
| import * as baseCss from '../../../common/styles/base.m.css'; | ||
|
|
||
| function getPage(remote: Remote) { | ||
| return remote | ||
| .get('http://localhost:9000/_build/common/example/?module=textarea') | ||
| .setFindTimeout(5000); | ||
| } | ||
|
|
||
| registerSuite('Textarea', { | ||
| 'should be visible'() { | ||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t1 .${css.root}`) | ||
| .isDisplayed() | ||
| .findByCssSelector(`.${css.inputWrapper}`) | ||
| .isDisplayed() | ||
| .end() | ||
|
|
||
| .findByCssSelector(`.${css.input}`) | ||
| .getSize() | ||
| .then(({ height, width }) => { | ||
| assert.isAbove(height, 0, 'The height of the textarea should be greater than zero.'); | ||
| assert.isAbove(width, 0, 'The width of the textarea should be greater than zero.'); | ||
| }) | ||
| .end() | ||
| .end(); | ||
| }, | ||
| 'label should be as defined'() { | ||
| const { browserName = '' } = this.remote.session.capabilities; | ||
| if (browserName.toLowerCase() === 'internet explorer') { | ||
| this.skip('Label is including textarea placeholder.'); | ||
| } | ||
|
|
||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t1 .${css.root}`) | ||
| .getVisibleText() | ||
| .then(text => { | ||
| assert.strictEqual(text, 'Type Something'); | ||
| }) | ||
| .end(); | ||
| }, | ||
| 'should gain focus when clicking on the label'() { | ||
| const { browserName } = this.remote.session.capabilities; | ||
| if (browserName === 'firefox') { | ||
| this.skip('Firefox is not locating the input.'); | ||
| } | ||
|
|
||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t1 .${css.root}`) | ||
| .click() | ||
| .sleep(1000) | ||
| .end() | ||
| .execute(`return document.activeElement === document.querySelector('#example-t1 .${css.root} .${css.input}');`) | ||
| .then(isEqual => { | ||
| assert.isTrue(isEqual); | ||
| }); | ||
| }, | ||
| 'should allow input to be typed'() { | ||
| const { browserName } = this.remote.session.capabilities; | ||
| if (browserName === 'firefox') { | ||
| this.skip('Firefox is not locating the input.'); | ||
| } | ||
|
|
||
| const testInput = 'test text'; | ||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t1 .${css.root}`) | ||
| .click() | ||
| .findByCssSelector(`.${css.input}`) | ||
| .type(testInput) | ||
| .getProperty('value') | ||
| .then((value: string) => { | ||
| assert.strictEqual(value, testInput); | ||
| }) | ||
| .end() | ||
| .end(); | ||
| }, | ||
| 'disabled should not allow input to be typed'() { | ||
| const initValue = 'Initial value'; | ||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t2 .${css.root} .${css.input}`) | ||
| .click() | ||
| .then(null, () => {}) | ||
| .type('text') | ||
| .then(null, () => {}) | ||
| .getProperty('value') | ||
| .then((value: string) => { | ||
| assert.strictEqual(value, initValue); | ||
| }) | ||
| .end(); | ||
| }, | ||
| 'validated should update style based on validity'() { | ||
| const { browserName, version } = this.remote.session.capabilities; | ||
| if (browserName === 'safari') { | ||
| this.skip('Classes are not being updated for this unit test in Safari 9 ' + version); | ||
| } | ||
|
|
||
| const validText = 'exists'; | ||
| const backspaces = []; | ||
| for (let i = 0; i < validText.length; i++) { | ||
| backspaces.push(keys.BACKSPACE); | ||
| } | ||
|
|
||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t3 .${css.root}`) | ||
| .getProperty('className') | ||
| .then((className: string) => { | ||
| assert.notInclude(className, css.invalid); | ||
| assert.notInclude(className, css.valid); | ||
| }) | ||
| .findByCssSelector(`.${css.input}`) | ||
| .click() | ||
| .type(validText) | ||
| .end() | ||
| .end() | ||
| // focus another input | ||
| .findByCssSelector(`#example-t1 .${css.root} .${css.input}`) | ||
| .click() | ||
| .end() | ||
| .sleep(500) | ||
| // enter invalid value | ||
| .findByCssSelector(`#example-t3 .${css.root}`) | ||
| .getProperty('className') | ||
| .then((className: string) => { | ||
| assert.notInclude(className, css.invalid); | ||
| assert.include(className, css.valid); | ||
| }) | ||
| .findByCssSelector(`.${css.input}`) | ||
| .click() | ||
| .type(backspaces) | ||
| .end() | ||
| .end() | ||
| // focus another input | ||
| .findByCssSelector(`#example-t1 .${css.root} .${css.input}`) | ||
| .click() | ||
| .end() | ||
| .sleep(500) | ||
| .findByCssSelector(`#example-t3 .${css.root}`) | ||
| .getProperty('className') | ||
| .then((className: string) => { | ||
| assert.notInclude(className, css.valid); | ||
| assert.include(className, css.invalid); | ||
| }) | ||
| .end(); | ||
| }, | ||
| 'hidden label should not be displayed'() { | ||
| return getPage(this.remote) | ||
| .findByCssSelector(`#example-t4 .${css.root}`) | ||
| .getVisibleText() | ||
| .then(text => { | ||
| assert.isTrue(text && text.length > 0); | ||
| }) | ||
| .findByCssSelector(`.${baseCss.visuallyHidden}`) | ||
| .then(element => { | ||
| assert(element, 'element with specified class "visuallyHidden" should exist.`'); | ||
| }) | ||
| .end() | ||
| .end(); | ||
| } | ||
| }); | ||
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.
I'm not sure we need to add an example and test for this, since it's part of label functionality rather than textarea functionality (and I'm not a fan of hidden labels, so not big on modeling them in all the widget examples)