Merge lp:~intellectronica/launchpad/fix-test-mark-duplicate into lp:launchpad

Proposed by Eleanor Berger
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~intellectronica/launchpad/fix-test-mark-duplicate
Merge into: lp:launchpad
Diff against target: 217 lines
1 file modified
lib/lp/bugs/windmill/tests/test_mark_duplicate.py (+110/-92)
To merge this branch: bzr merge lp:~intellectronica/launchpad/fix-test-mark-duplicate
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle code Approve
Review via email: mp+13682@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Eleanor Berger (intellectronica) wrote :

This branch converts the windmill test test_mark_duplicate to work with the new windmill infrastructure. The test itself hasn't changed, and it works fine now.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks fine.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'lib/lp/bugs/windmill/tests/test_bugs/test_mark_duplicate.py' => 'lib/lp/bugs/windmill/tests/test_mark_duplicate.py'
2--- lib/lp/bugs/windmill/tests/test_bugs/test_mark_duplicate.py 2009-08-19 11:59:40 +0000
3+++ lib/lp/bugs/windmill/tests/test_mark_duplicate.py 2009-10-21 01:55:20 +0000
4@@ -1,9 +1,18 @@
5 # Copyright 2009 Canonical Ltd. This software is licensed under the
6 # GNU Affero General Public License version 3 (see the file LICENSE).
7
8+"""Test for the bug tag entry UI."""
9+
10+__metaclass__ = type
11+__all__ = []
12+
13+import unittest
14+
15+from windmill.authoring import WindmillTestClient
16+
17 from canonical.launchpad.windmill.testing import constants, lpuser
18-
19-from windmill.authoring import WindmillTestClient
20+from lp.bugs.windmill.testing import BugsWindmillLayer
21+from lp.testing import TestCaseWithFactory
22
23 MAIN_FORM_ELEMENT = u'//div[@id="duplicate-form-container"]/table'
24 FORM_NOT_VISIBLE = (
25@@ -14,93 +23,102 @@
26 u'//div[@id="duplicate-form-container"]'
27 '//button[@name="field.actions.change"]')
28
29-def test_mark_duplicate_form_overlay():
30- """Test the mark duplicate action on bug pages.
31-
32- This test ensures that with Javascript enabled, the mark duplicate link
33- on a bug page uses the formoverlay to update the duplicateof field via
34- the api.
35- """
36- client = WindmillTestClient("Bug mark duplicate test")
37- lpuser.SAMPLE_PERSON.ensure_login(client)
38-
39- # Open a bug page and wait for it to finish loading
40- client.open(url=u'http://bugs.launchpad.dev:8085/bugs/15')
41- client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
42- client.waits.forElement(xpath=MAIN_FORM_ELEMENT, timeout=constants.FOR_ELEMENT)
43-
44- # Initially the form overlay is hidden
45- client.asserts.assertElemJS(xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)
46-
47- # Clicking on the mark duplicate link brings up the formoverlay.
48- # Entering 1 as the duplicate ID changes the duplicate text.
49- client.click(classname=u'menu-link-mark-dupe')
50- client.asserts.assertElemJS(xpath=MAIN_FORM_ELEMENT, js=FORM_VISIBLE)
51-
52- # Entering the bug id '1' and changing hides the formoverlay
53- # and updates the mark as duplicate:
54- client.type(text=u'1', id=u'field.duplicateof')
55- client.click(xpath=CHANGE_BUTTON)
56- client.asserts.assertElemJS(xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)
57-
58- # The form "Add a comment" now contains a warning about adding
59- # a comment for a duplicate bug.
60- client.waits.forElement(
61- id='warning-comment-on-duplicate', timeout=constants.FOR_ELEMENT)
62-
63- # The duplicate can be cleared:
64- client.click(classname=u'menu-link-mark-dupe')
65- client.type(text=u'', id=u'field.duplicateof')
66- client.click(xpath=CHANGE_BUTTON)
67- client.waits.forElement(
68- xpath=u"//span[@id='mark-duplicate-text']/"
69- u"a[contains(., 'Mark as duplicate')]")
70-
71- # The warning about commenting on a diplucate bug is now gone.
72- client.asserts.assertNotNode(id='warning-comment-on-duplicate')
73-
74- # Entering a false bug number results in input validation errors
75- client.click(classname=u'menu-link-mark-dupe')
76- client.type(text=u'123', id=u'field.duplicateof')
77- client.click(xpath=CHANGE_BUTTON)
78- error_xpath = (
79- MAIN_FORM_ELEMENT +
80- "//div[contains(@class, 'yui-lazr-formoverlay-errors')]/ul/li")
81- client.waits.forElement(xpath=error_xpath)
82-
83- # Clicking change again brings back the error dialog again
84- # (regression test for bug 347258)
85- client.click(xpath=CHANGE_BUTTON)
86- client.waits.forElement(xpath=error_xpath)
87-
88- # But entering a correct bug and submitting gets us back to a normal state
89- client.type(text=u'1', id=u'field.duplicateof')
90- client.click(xpath=CHANGE_BUTTON)
91- client.waits.forElement(
92- xpath=u"//span[@id='mark-duplicate-text']/a[contains(., 'bug #1')]")
93-
94- # Finally, clicking on the link to the bug takes you to the master.
95- client.click(link=u'bug #1')
96- client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
97- client.asserts.assertText(
98- xpath=u"//h1[@id='bug-title']/span[1]",
99- validator=u'Firefox does not support SVG')
100-
101- # When we go back to the page for the duplicate bug...
102- client.open(url=u'http://bugs.launchpad.dev:8085/bugs/15')
103- client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
104- client.waits.forElement(
105- xpath=MAIN_FORM_ELEMENT, timeout=constants.FOR_ELEMENT)
106-
107- # ...we see the same warning about commenting on a duplicate bug
108- # as the one we saw before.
109- client.asserts.assertNode(id='warning-comment-on-duplicate')
110-
111- # Once we remove the duplicate mark...
112- client.click(id=u'change_duplicate_bug')
113- client.type(text=u'', id=u'field.duplicateof')
114- client.click(xpath=CHANGE_BUTTON)
115- client.waits.sleep(milliseconds=constants.SLEEP)
116-
117- # ...the warning is gone.
118- client.asserts.assertNotNode(id='warning-comment-on-duplicate')
119+class TestBugCommenting(TestCaseWithFactory):
120+
121+ layer = BugsWindmillLayer
122+
123+ def test_mark_duplicate_form_overlay(self):
124+ """Test the mark duplicate action on bug pages.
125+
126+ This test ensures that with Javascript enabled, the mark duplicate
127+ link on a bug page uses the formoverlay to update the duplicateof
128+ field via the api.
129+ """
130+ client = WindmillTestClient("Bug mark duplicate test")
131+ lpuser.SAMPLE_PERSON.ensure_login(client)
132+
133+ # Open a bug page and wait for it to finish loading
134+ client.open(url=u'http://bugs.launchpad.dev:8085/bugs/15')
135+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
136+ client.waits.forElement(
137+ xpath=MAIN_FORM_ELEMENT, timeout=constants.FOR_ELEMENT)
138+
139+ # Initially the form overlay is hidden
140+ client.asserts.assertElemJS(
141+ xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)
142+
143+ # Clicking on the mark duplicate link brings up the formoverlay.
144+ # Entering 1 as the duplicate ID changes the duplicate text.
145+ client.click(classname=u'menu-link-mark-dupe')
146+ client.asserts.assertElemJS(xpath=MAIN_FORM_ELEMENT, js=FORM_VISIBLE)
147+
148+ # Entering the bug id '1' and changing hides the formoverlay
149+ # and updates the mark as duplicate:
150+ client.type(text=u'1', id=u'field.duplicateof')
151+ client.click(xpath=CHANGE_BUTTON)
152+ client.asserts.assertElemJS(
153+ xpath=MAIN_FORM_ELEMENT, js=FORM_NOT_VISIBLE)
154+
155+ # The form "Add a comment" now contains a warning about adding
156+ # a comment for a duplicate bug.
157+ client.waits.forElement(
158+ id='warning-comment-on-duplicate', timeout=constants.FOR_ELEMENT)
159+
160+ # The duplicate can be cleared:
161+ client.click(classname=u'menu-link-mark-dupe')
162+ client.type(text=u'', id=u'field.duplicateof')
163+ client.click(xpath=CHANGE_BUTTON)
164+ client.waits.forElement(
165+ xpath=u"//span[@id='mark-duplicate-text']/"
166+ u"a[contains(., 'Mark as duplicate')]")
167+
168+ # The warning about commenting on a diplucate bug is now gone.
169+ client.asserts.assertNotNode(id='warning-comment-on-duplicate')
170+
171+ # Entering a false bug number results in input validation errors
172+ client.click(classname=u'menu-link-mark-dupe')
173+ client.type(text=u'123', id=u'field.duplicateof')
174+ client.click(xpath=CHANGE_BUTTON)
175+ error_xpath = (
176+ MAIN_FORM_ELEMENT +
177+ "//div[contains(@class, 'yui-lazr-formoverlay-errors')]/ul/li")
178+ client.waits.forElement(xpath=error_xpath)
179+
180+ # Clicking change again brings back the error dialog again
181+ # (regression test for bug 347258)
182+ client.click(xpath=CHANGE_BUTTON)
183+ client.waits.forElement(xpath=error_xpath)
184+
185+ # But entering a correct bug and submitting
186+ # gets us back to a normal state
187+ client.type(text=u'1', id=u'field.duplicateof')
188+ client.click(xpath=CHANGE_BUTTON)
189+ client.waits.forElement(
190+ xpath=u"//span[@id='mark-duplicate-text']"
191+ u"/a[contains(., 'bug #1')]")
192+
193+ # Finally, clicking on the link to the bug takes you to the master.
194+ client.click(link=u'bug #1')
195+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
196+ client.asserts.assertText(
197+ xpath=u"//h1[@id='bug-title']/span[1]",
198+ validator=u'Firefox does not support SVG')
199+
200+ # When we go back to the page for the duplicate bug...
201+ client.open(url=u'http://bugs.launchpad.dev:8085/bugs/15')
202+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
203+ client.waits.forElement(
204+ xpath=MAIN_FORM_ELEMENT, timeout=constants.FOR_ELEMENT)
205+
206+ # ...we see the same warning about commenting on a duplicate bug
207+ # as the one we saw before.
208+ client.asserts.assertNode(id='warning-comment-on-duplicate')
209+
210+ # Once we remove the duplicate mark...
211+ client.click(id=u'change_duplicate_bug')
212+ client.type(text=u'', id=u'field.duplicateof')
213+ client.click(xpath=CHANGE_BUTTON)
214+ client.waits.sleep(milliseconds=constants.SLEEP)
215+
216+ # ...the warning is gone.
217+ client.asserts.assertNotNode(id='warning-comment-on-duplicate')