Permalink
Browse files

fix(interactions): Is.stale() renamed to Is.absent() to better reflec…

…t the purpose of the matcher

Protractor's `ExpectedCondtions.stalenessOf` funciton is an alias for `not.present()`. This meaning

is inconsistent with WebDriver's definition of "staleness", which only refers to elements detached

from the DOM we have a reference for, not merely "any element we can't find". Thanks to @nbarrett

for pointing this out!
  • Loading branch information...
jan-molak committed Dec 30, 2016
1 parent 3db8c8e commit 8a42a822f7a2d9eed2fd64e95a9b7a0140e3be80
@@ -45,7 +45,7 @@
<pre ng-if="triggered" class="result">{{ result }}</pre>
</script>
<script type="text/ng-template" id="Stale">
<script type="text/ng-template" id="Absent">
<pre ng-if="! triggered" class="result">{{ result }}</pre>
</script>
@@ -76,7 +76,7 @@
'Visible',
'Invisible',
'Present',
'Stale',
'Absent',
'Selected',
'Clickable'
];
@@ -184,20 +184,20 @@ synced.describe ('When waiting for things to happen, a test scenario', function
])));
});
synced.describe('to determine if an element is stale (detached from the DOM)', () => {
synced.describe('to determine if an element is not present in the DOM', () => {
synced.it('will fail if the condition is not met within the timeout', () =>
expect(james.attemptsTo(
ChooseAnExample.whereElementBecomes('Stale').after(Trigger_Delay).using(timeoutFunction),
Wait.upTo(Not_Long_Enough).until(Playground.Result, Is.stale()),
)).to.be.rejectedWith('The result did not become stale'));
ChooseAnExample.whereElementBecomes('Absent').after(Trigger_Delay).using(timeoutFunction),
Wait.upTo(Not_Long_Enough).until(Playground.Result, Is.absent()),
)).to.be.rejectedWith('The result did not become absent'));
synced.it('will pass if the condition is met within the timeout', () =>
expect(james.attemptsTo(
ChooseAnExample.whereElementBecomes('Stale').after(Trigger_Delay).using(timeoutFunction),
Wait.upTo(Long_Enough).until(Playground.Result, Is.stale()),
ChooseAnExample.whereElementBecomes('Absent').after(Trigger_Delay).using(timeoutFunction),
Wait.upTo(Long_Enough).until(Playground.Result, Is.absent()),
)).to.be.fulfilled.
then(() => Promise.all([
@@ -37,12 +37,12 @@ export class ActiveWait {
}
export class Is {
static visible = () => Is.aTargetThat(new IsVisible());
static invisible = () => Is.aTargetThat(new IsInvisible());
static present = () => Is.aTargetThat(new IsPresent());
static stale = () => Is.aTargetThat(new IsStale());
static selected = () => Is.aTargetThat(new IsSelected());
static clickable = () => Is.aTargetThat(new IsClickable());
static visible = () => Is.aTargetThat(new IsVisible());
static invisible = () => Is.aTargetThat(new IsInvisible());
static present = () => Is.aTargetThat(new IsPresent());
static absent = () => Is.aTargetThat(new Absent());
static selected = () => Is.aTargetThat(new IsSelected());
static clickable = () => Is.aTargetThat(new IsClickable());
private static aTargetThat(condition: Condition<ElementFinder>): SuccessCondition<Target>{
return (target: Target, timeout: Duration) => new WaitUntil(target, condition, timeout);
@@ -78,9 +78,9 @@ class IsPresent implements Condition<ElementFinder> {
name = () => 'invisible';
}
class IsStale implements Condition<ElementFinder> {
class Absent implements Condition<ElementFinder> {
check = (thing: ElementFinder): Function => protractor.ExpectedConditions.stalenessOf(thing);
name = () => 'stale';
name = () => 'absent';
}
class IsSelected implements Condition<ElementFinder> {

1 comment on commit 8a42a82

@nbarrett

This comment has been minimized.

Show comment
Hide comment
@nbarrett

nbarrett Dec 30, 2016

Contributor

Nice one! 😄

Contributor

nbarrett commented on 8a42a82 Dec 30, 2016

Nice one! 😄

Please sign in to comment.