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

Adding test case for deform #103 issue #16

Merged
merged 3 commits into from
Aug 17, 2020
Merged

Conversation

tonthon
Copy link
Contributor

@tonthon tonthon commented Sep 21, 2012

Re-opened pull request.
Do not merge this one until some improvement is done on the provided solution see original issue :
Pylons/deform#103

@stevepiercy stevepiercy added this to the 3.0.0 milestone Jun 22, 2020
@stevepiercy
Copy link
Member

@tonthon I would like to merge this PR, if you rebase it on master and push. Would you please kindly do so? It improves the situation. I've added it to the 3.0.0 milestone for a pending release of Deform.

A new issue for < and > and other HTML entities can be opened.

@tonthon
Copy link
Contributor Author

tonthon commented Aug 4, 2020

@stevepiercy here it is. Sorry for the delay, not working so much lately

@stevepiercy
Copy link
Member

@tonthon for the lint failure, you can use tox -e format to run black on the code, then verify with tox -e lint.

Also for running tests, you can run a single functional test locally until it passes. See https://github.com/Pylons/deform/blob/master/contributing.md in the Deform repo for full details.

Finally v3.0 of Deform drops end-of-life Pythons.

@tonthon
Copy link
Contributor Author

tonthon commented Aug 5, 2020

Test still fail with the current deform master branch (I don't know what was expected)

@@ -2736,6 +2736,16 @@ def test_submit_filled(self):
# py2/py3 compat, py2 adds extra u prefix
self.assertTrue("bar" in text)

def test_special_chars(self):
findid('deformField1').send_keys('foo')
self.assertTrue(findxpath('//p[text()="foo & bar"]').is_displayed())
Copy link
Member

Choose a reason for hiding this comment

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

When I type foo & bar in the input field, no text is displayed in the popup, so this test should fail, but it appears to pass.

self.assertRaises(NoSuchElementException, findcss, ".has-error")
text = findid("captured").text
# py2/py3 compat, py2 adds extra u prefix
self.assertTrue("foo & bar" in text)
Copy link
Member

Choose a reason for hiding this comment

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

This will fail because the output is:

{'text': 'foo '
         '& '
         'bar'}

@stevepiercy
Copy link
Member

I figured it out. This had a chain (literally) of nasty issues, which I only discovered by comparing autocomplete_input and autocomplete_remote_input. @tonthon I opened up a PR against your branch for your review. If it is good, then merge, and then this PR will update and rerun Travis CI automatically. Normally I just push to the open PR, but it looks like you unchecked "Allow maintainers to update" when creating this PR.

Details

First we need to add the option foo & bar for the latter. This made it clear to me that the XHR response was fine, which pointed the finger at the Chameleon template.

We need to add the structure keyword to the autocomplete template's options because it was HTML-encoding & as &amp;.

The test was not actually clicking the element from findcss(".tt-suggestion"). This means that all tests that use this method may be returning false positives. The correct method is to do something like this:

suggestion = findcss(".tt-suggestion")
ActionChains(browser).move_to_element(suggestion).click().perform()

I created a new function to use ActionChains.

Finally pprint.PrettyPrinter(width=1) was a bad choice because it was breaking the output on spaces into a new line for each, so the value never could match.

@stevepiercy stevepiercy merged commit ce7bc71 into Pylons:master Aug 17, 2020
@stevepiercy
Copy link
Member

Closed in favor of #75

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.

2 participants