Skip to content
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

Provide selector methods for filtering nodes by visibility (closes #1018) #2093

Merged
merged 2 commits into from
Feb 7, 2018

Conversation

AlexKamaev
Copy link
Contributor

No description provided.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit e5a5b85 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit e73867a have failed. See details:

@DevExpress DevExpress deleted a comment from testcafe-build-bot Feb 2, 2018
@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit e73867a have passed. See details:

@AndreyBelym AndreyBelym changed the title Provide selector methods for filtering nodes by visibility (#1018) Provide selector methods for filtering nodes by visibility (closes #1018) Feb 2, 2018
import ClientFunctionExecutor from '../client-function-executor';
import { exists, visible } from '../visibility-function';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to rename visibility-function.js to something like element-constraints.js? \cc @AlexanderMoskovkin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt about the constraints word but I agree with the idea to rename this since exists is not visibility function.
Maybe something like check-element or element-utils

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit e73867a have passed. See details:

@@ -41,6 +42,14 @@ hammerhead.nativeMethods.objectDefineProperty.call(window, window, '%testCafeSel
else
throw new InvalidSelectorResultError();

filtered = [].slice.call(filtered).filter(n => exists(n));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use arrayUtils.filter, like here. It this case you need not to use the [].slice.call.

One more reason: Array.prototype.slice can be overwritten by a script on the tested page. In this case your script will fail. But arrayUtils contains initial functions from Array.prototype (like filter, forEach etc..)

import ClientFunctionExecutor from '../client-function-executor';
import { exists, visible } from '../visibility-function';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt about the constraints word but I agree with the idea to rename this since exists is not visibility function.
Maybe something like check-element or element-utils

@@ -15,6 +15,34 @@ const isIEFunction = ClientFunction(() => {
appName === 'Netscape' && isIE11Re.exec(userAgent) !== null;
});


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's place this tests near other filter tests in the file (for example after the Combination of filter methods test).


elements = elements.filterVisible().child('p');

await t.expect(elements.count).eql(6);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  ...
 <p class="class1">2</p>
 <p class="class1">3</p>
 <p class="class1" style="display: none;">4</p>
 ...

Let's add a check for a compound filtered selector. For example:

await t.expect(elements.filterVisible().filter('.class1').count).eql(2);

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0d0f949 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0d0f949 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0d0f949 have failed. See details:

1 similar comment
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0d0f949 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 0d0f949 have passed. See details:

@AlexKamaev
Copy link
Contributor Author

FPR

@AlexanderMoskovkin
Copy link
Contributor

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0d0f949 have failed. See details:

1 similar comment
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0d0f949 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 0d0f949 have passed. See details:

@AlexanderMoskovkin
Copy link
Contributor

/cc @AndreyBelym

@AlexKamaev
Copy link
Contributor Author

@AndreyBelym please review

Copy link
Contributor

@AndreyBelym AndreyBelym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@AndreyBelym AndreyBelym merged commit f0c960b into DevExpress:master Feb 7, 2018
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants