Merge lp:~wallyworld/launchpad/fix-enable-review-type into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 12019
Proposed branch: lp:~wallyworld/launchpad/fix-enable-review-type
Merge into: lp:launchpad
Diff against target: 43 lines (+13/-2)
2 files modified
lib/lp/code/templates/branch-register-merge.pt (+1/-1)
lib/lp/code/windmill/tests/test_branchmergeproposal_review.py (+12/-1)
To merge this branch: bzr merge lp:~wallyworld/launchpad/fix-enable-review-type
Reviewer Review Type Date Requested Status
Māris Fogels Pending
Review via email: mp+41123@code.launchpad.net

This proposal supersedes a proposal from 2010-11-08.

Description of the change

= Summary =

As per bug 671665, when the popup selection widget is used to choose the reviewer for a mp, the review type field does not become enabled.

= Implementation =

There are 2 parts to the fix.
1. Enhance lazr-js so that focus is returned to the input field when the user finishes selecting the value from the popup
2. Change the mechanism to trigger the review_type field enable update from onchange to onblur

The enabled processing will occur when the user tabs out of the reviewer field, and will work in the same way whether the reviewer value is typed or entered using the popup.

This branch should be merged only once lazr-js is upgraded. The relevant branch there is lp:~wallyworld/lazr-js/popup-selection-focus-fix

= Tests =

The code.windmill.test_branchmergeproposal_review.py test was enhanced to the that the correct behaviour occurred when using the popup selector.

bin/test -vvt test_branchmergeproposal_review

= Lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/code/templates/branch-register-merge.pt
  lib/lp/code/windmill/tests/test_branchmergeproposal_review.py

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote : Posted in a previous version of this proposal

The merge proposal for lazr-js branch lp:~wallyworld/lazr-js/popup-selection-focus-fix has now been approved

Revision history for this message
Māris Fogels (mars) wrote : Posted in a previous version of this proposal

Hi Ian,

This change looks good.

I noticed one spot that may be an issue: is a JavaScript execution step triggered by an event after client.keyPress(), but before client.assertProperty()? (Is this where the blur event occurs?) If so, you may need to insert a programmatic wait into the test at that point to give time for the JS to execute, and then for the browser to update the DOM (assertProperty() might already wait for you; the documentation would say for sure).

If the test does not wait, then you accidentally introduce a race condition between the browser and the testrunner, similar to the ones we have been seeing in buildbot. It is best to try and catch such races now. They are hard to track down after landing.

With that consideration, r=mars

review: Approve
Revision history for this message
Ian Booth (wallyworld) wrote : Posted in a previous version of this proposal

Hi Maris

Thanks for the pointer about the possible race condition. You are right
in that the keyPress() call is to send a tab key press to cause the blur
event. I've added a small 500ms wait.

On 09/11/10 23:42, Māris Fogels wrote:
> Review: Approve
> Hi Ian,
>
> This change looks good.
>
> I noticed one spot that may be an issue: is a JavaScript execution step triggered by an event after client.keyPress(), but before client.assertProperty()? (Is this where the blur event occurs?) If so, you may need to insert a programmatic wait into the test at that point to give time for the JS to execute, and then for the browser to update the DOM (assertProperty() might already wait for you; the documentation would say for sure).
>
> If the test does not wait, then you accidentally introduce a race condition between the browser and the testrunner, similar to the ones we have been seeing in buildbot. It is best to try and catch such races now. They are hard to track down after landing.
>
> With that consideration, r=mars

Revision history for this message
Ian Booth (wallyworld) wrote :

I resubmitted the mp so that it is targeted to land in devel rather than db-devel

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/templates/branch-register-merge.pt'
2--- lib/lp/code/templates/branch-register-merge.pt 2010-10-01 05:34:25 +0000
3+++ lib/lp/code/templates/branch-register-merge.pt 2010-11-18 01:30:34 +0000
4@@ -69,7 +69,7 @@
5 review_type = document.getElementById('field.review_type');
6 review_type.disabled = (reviewer == '');
7 };
8- Y.on('change',
9+ Y.on('blur',
10 function(e) {
11 reviewer_changed(e.target.get('value'))
12 },
13
14=== modified file 'lib/lp/code/windmill/tests/test_branchmergeproposal_review.py'
15--- lib/lp/code/windmill/tests/test_branchmergeproposal_review.py 2010-11-04 19:59:02 +0000
16+++ lib/lp/code/windmill/tests/test_branchmergeproposal_review.py 2010-11-18 01:30:34 +0000
17@@ -57,15 +57,26 @@
18 # reviewer field is empty works.
19 client.asserts.assertProperty(
20 id=u"field.review_type", validator='disabled|true')
21+ # User types into reviewer field manually.
22 client.type(text=u'mark', id=u'field.reviewer')
23 client.asserts.assertProperty(
24 id=u"field.review_type", validator='disabled|false')
25 client.type(text=u'', id=u'field.reviewer')
26 client.asserts.assertProperty(
27 id=u"field.review_type", validator='disabled|true')
28+ # User selects reviewer using popup selector widget.
29+ client.click(id=u'show-widget-field-reviewer')
30+ search_and_select_picker_widget(client, u'name12', 1)
31+ # Tab out of the field.
32+ client.keyPress(
33+ options='\\9,true,false,false,false,false',
34+ id=u'field.reviewer')
35+ # Give javascript event handler time to run
36+ client.waits.sleep(milliseconds=unicode(500))
37+ client.asserts.assertProperty(
38+ id=u"field.review_type", validator='disabled|false')
39
40 client.click(id=u'field.actions.register')
41-
42 client.waits.forPageLoad(timeout=u'10000')
43 client.click(id=u'request-review')
44