-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate
findElement
and findElementWithAssert
- Loading branch information
Showing
5 changed files
with
164 additions
and
6 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
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,72 @@ | ||
--- | ||
layout: page | ||
title: Deprecations | ||
--- | ||
|
||
This is a list of deprecations introduced in 2.x cycle: | ||
|
||
## Find element | ||
|
||
**ID**: ember-cli-page-object.find-element | ||
|
||
**Until**: 3.0.0 | ||
|
||
Both `findElement(` and `findElementWithAssert()` have jQuery collection as their return value. Since we are going away from jQuery usage, these two finders are deprecated now. | ||
|
||
Please consider using `findOne(` or `findMany(` instead. | ||
|
||
Bad: | ||
|
||
```js | ||
import { getter } from 'ember-cli-page-object/macros'; | ||
import { findElementWithAssert } from 'ember-cli-page-object/extend'; | ||
|
||
export default function isDisabled(selector, options = {}) { | ||
return getter(function() { | ||
return findElementWithAssert(this, selector, options).is(':disabled'); | ||
}); | ||
} | ||
``` | ||
|
||
Good: | ||
|
||
```js | ||
import { getter } from 'ember-cli-page-object/macros'; | ||
import { findOne } from 'ember-cli-page-object/extend'; | ||
|
||
export default function isDisabled(selector, options = {}) { | ||
return getter(function() { | ||
return findOne(this, selector, options).disabled; | ||
}); | ||
} | ||
|
||
``` | ||
|
||
Bad: | ||
|
||
```js | ||
import { getter } from 'ember-cli-page-object/macros'; | ||
import { findElement } from 'ember-cli-page-object/extend'; | ||
|
||
export default function count(selector, options = {}) { | ||
return getter(function() { | ||
return findElement(this, selector, { | ||
...options, | ||
multiple: true | ||
}).length; | ||
}); | ||
} | ||
``` | ||
|
||
Good: | ||
|
||
```js | ||
import { getter } from 'ember-cli-page-object/macros'; | ||
import { findMany } from 'ember-cli-page-object/extend'; | ||
|
||
export default function count(selector, options = {}) { | ||
return getter(function() { | ||
return findMany(this, selector, options).length; | ||
}); | ||
} | ||
``` |
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
49 changes: 49 additions & 0 deletions
49
test-app/tests/integration/deprecations/find-element-test.ts
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,49 @@ | ||
import { module, test } from 'qunit'; | ||
import { create } from 'ember-cli-page-object'; | ||
import deprecate from 'ember-cli-page-object/-private/deprecate'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { render } from '@ember/test-helpers'; | ||
import { findElement, findElementWithAssert } from 'ember-cli-page-object/extend'; | ||
import { setupRenderingTest } from '../../helpers'; | ||
|
||
module('Deprecation | find-element', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function () { | ||
deprecate.__calls = []; | ||
}); | ||
|
||
hooks.afterEach(function () { | ||
delete deprecate.__calls; | ||
}); | ||
|
||
test('findElement', async function (assert) { | ||
await render(hbs`<span></span>`); | ||
|
||
findElement(create(), 'span'); | ||
|
||
assert.deepEqual(deprecate.__calls, [ | ||
[ | ||
"find-element", | ||
"`findElement(` is deprecated. Please, consider using the `findOne(` or `findMany(` instead.", | ||
"2.2.0", | ||
"3.0.0" | ||
], | ||
]); | ||
}); | ||
|
||
test('findElementWithAssert', async function (assert) { | ||
await render(hbs`<span></span>`); | ||
|
||
findElementWithAssert(create(), 'span'); | ||
|
||
assert.deepEqual(deprecate.__calls, [ | ||
[ | ||
"find-element", | ||
"`findElementWithAssert(` is deprecated. Please, consider using the `findOne(` instead.", | ||
"2.2.0", | ||
"3.0.0" | ||
], | ||
]); | ||
}); | ||
}); |
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