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

fix: Revert native contains property #547

Merged
merged 3 commits into from
Oct 13, 2021
Merged

fix: Revert native contains property #547

merged 3 commits into from
Oct 13, 2021

Conversation

Alonski
Copy link
Contributor

@Alonski Alonski commented Oct 3, 2021

The change done in this PR: #466 caused a regression.

$.text() can find the text in visibility: hidden or display: none elements.

element.innerText does not return the text.

Fixes: #514

The change done in this PR: san650#466 caused a regression.

$.text() can find the text in `visibility: hidden` or `display: none` elements.

element.innerText does not return the text. 

Fixes: san650#514
Copy link
Collaborator

@ro0gr ro0gr left a comment

Choose a reason for hiding this comment

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

Thanks for moving it forward! Mind adding a test case for this regression? Some unit test here should be fine.

import { findMany, findOne } from '../extend';
import { A } from '@ember/array';
import { assign, every } from '../-private/helpers';
import { findElementWithAssert } from '../extend';
Copy link
Collaborator

Choose a reason for hiding this comment

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

internaly we tend to avoid using findElementWithAssert( in favour of findMany or findOne. I'd appreciate if we can avoid findElementWithAssert here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. However because findMany and findOne return a normal array and not a jQuery Array I needed to convert the elements into a jQuery array for use in the every helper function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

in order to avoid custom every util, we could just wrap each element with $, like instead of

        return A(elements).every((element) => element.innerText.indexOf(textToSearch) >= 0);

we could have

        return A(elements).every((element) => $(element).text().indexOf(textToSearch) >= 0);

Though, I think it isn't that important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I tried this but the every util helper needs a jquery array to be passed in

This keeps the helper in line with other internal helpers.

This required converting the e
lements into a jQuery array as this is what the `every` function receives.
@Alonski
Copy link
Contributor Author

Alonski commented Oct 12, 2021

@ro0gr I added tests and updated the helper to use findMany and findOne

I would love help getting this merged and released as soon as you can :)

It is blocking me on a bug in one of the apps that I maintain.

Thank you so much for this addon and for your continued maintenance! 🥇

@ro0gr
Copy link
Collaborator

ro0gr commented Oct 13, 2021

@Alonski sure! I'm going to publish it tonight

@ro0gr
Copy link
Collaborator

ro0gr commented Oct 13, 2021

So turns out it doesn't really fix the #514 (comment), which has never been a regression. But it fixes a real regression of the contains(. Going to squash the commits excluding the Fixes: #514 part.

@ro0gr
Copy link
Collaborator

ro0gr commented Oct 13, 2021

As a side note, seems Travis does not work for few month already and requires some migration procedure. So I've checked your tests locally, and it works on my end 🟢

@san650 would you be able to migrate this repo to the new Travis service? - https://docs.travis-ci.com/user/migrate/open-source-repository-migration#migrating-a-repository, cause seems I'm not allowed to do this. It'd be awesome.
Otherwise, I'd give a try to Github Actions once time permits, since I hope it should be easier to migrate to GH Actions by myself.

@ro0gr ro0gr merged commit 73238c8 into san650:master Oct 13, 2021
@ro0gr
Copy link
Collaborator

ro0gr commented Oct 13, 2021

published as 1.17.8

@san650
Copy link
Owner

san650 commented Oct 13, 2021

@ro0gr thanks for the heads up. I've migrated the repo to use travis-ci.com https://app.travis-ci.com/github/san650/ember-cli-page-object/requests?requestId=625350776

@ro0gr
Copy link
Collaborator

ro0gr commented Oct 13, 2021

@san650 Awesome. Thank you!

@Alonski
Copy link
Contributor Author

Alonski commented Oct 14, 2021

@ro0gr @san650 I believe the Ember community is moving towards Github Actions vs Travis in the future. So migrating to Actions isn't a bad idea 💡

Thanks for merging and releasing!

@Alonski Alonski deleted the patch-1 branch October 14, 2021 07:06
@Alonski
Copy link
Contributor Author

Alonski commented Oct 14, 2021

@ro0gr It seems that now I added a regression in this PR 🙃

I added a dependency to the every helper function on jQuery which breaks in apps that don't have jQuery integration set to true.

I need to think of a way to fix this as we also can't use element.text() now.

@ro0gr
Copy link
Collaborator

ro0gr commented Oct 14, 2021

@Alonski hm.. that's strange. ec-page-object is supposed to use it's own jquery instance if there is no one provided by a host. It doesn't sound related to your change to me. Do you have a chance to share a reproduction, and maybe create a bug ticket?

@Alonski
Copy link
Contributor Author

Alonski commented Oct 14, 2021

@ro0gr Created a reproduction in StackBlitz:
https://stackblitz.com/edit/github-oujqsi?devtoolsheight=33&file=package.json

In console:

npm i
npm run test:ember --server

image

import { findMany, findOne } from '../extend';
import { A } from '@ember/array';
import $ from 'jquery';
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh... I must be blind.

At the moment in order to use "adaptive" jquery, we had to import it by a synthetic -jquery path, like in other properties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want to create a PR to fix this or want me to whip one up?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can do it, though not sure if I manage to handle it today

Copy link
Collaborator

Choose a reason for hiding this comment

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

so yes, this error pops up in the GH Actions PR #552. and it's fixed there as well. I'd fix it altogether this weekend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome!

bertdeblock pushed a commit to chrislopresto/ember-freestyle that referenced this pull request Oct 15, 2021
@Alonski
Copy link
Contributor Author

Alonski commented Oct 19, 2021

@ro0gr Can you please also add the hacktoberfest-accepted label to this PR as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

content with display: none is still captured (does not match innerText)
3 participants