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

Matching against text content of the multi-line HTML pieces is tricky #1

Open
manicki opened this issue Apr 20, 2017 · 0 comments
Open

Comments

@manicki
Copy link
Member

manicki commented Apr 20, 2017

This has been discovered in https://gerrit.wikimedia.org/r/#/c/348756/2/resources/templates.php.
There HTML being validated is generated from the template. For convenience it makes sense to have a bit complex HTML split into multiple lines.

Resulting HTML could then be something like:

<div>
    <span class="foo">This is just an example.</span>
    <span class="quux">More text:
        <span class="value">Foo</span>
    </span>
</div>

If for any reason it was important to check this HTML piece contains "More text: Foo", current implementation of havingTextContents (ie. havingTextContents(constainsString('More text: Foo')) would fail to do so. This is because currently it strictly checks the text contains expected substring including all the whitespace.

In order to deal with cases like the above, there could be a custom matcher added ignoring the whitespace.
The alternative way might be to change havingTextContents do the whitespace normalization magic. I don't think this would be nice, though. On the other hand, that would kind of be replicating the behaviour of browsers etc, that also treat multiple white space as a single one.

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

No branches or pull requests

1 participant