Merge lp:~gary/juju-gui/fix-charm-panel-tests into lp:juju-gui/experimental

Proposed by Gary Poster
Status: Merged
Merged at revision: 735
Proposed branch: lp:~gary/juju-gui/fix-charm-panel-tests
Merge into: lp:juju-gui/experimental
Diff against target: 123 lines (+51/-19)
5 files modified
app/subapps/browser/templates/browser_charm.handlebars (+3/-0)
app/subapps/browser/templates/sidebar.handlebars (+3/-0)
app/templates/browser-search.handlebars (+3/-0)
app/templates/charm-token.handlebars (+3/-0)
test/test_charm_running.py (+39/-19)
To merge this branch: bzr merge lp:~gary/juju-gui/fix-charm-panel-tests
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+169502@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :
Download full text (6.0 KiB)

Reviewers: mp+169502_code.launchpad.net,

Message:
Please take a look.

Description:
Fix CI tests

I just added some small fixes to the good work primarily done by Jeff.

https://code.launchpad.net/~gary/juju-gui/fix-charm-panel-tests/+merge/169502

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/10253055/

Affected files:
   A [revision details]
   M app/subapps/browser/templates/browser_charm.handlebars
   M app/subapps/browser/templates/sidebar.handlebars
   M app/templates/charm-token.handlebars
   M test/test_charm_running.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: test/test_charm_running.py
=== modified file 'test/test_charm_running.py'
--- test/test_charm_running.py 2013-06-12 14:14:36 +0000
+++ test/test_charm_running.py 2013-06-14 17:13:29 +0000
@@ -111,27 +111,47 @@

      def deploy(self, charm_name):
          """Deploy a charm."""
- def charm_panel_loaded(driver):
- """Wait for the charm panel to be ready and displayed."""
- charm_search =
driver.find_element_by_id('charm-search-trigger')
- # Click to open the charm panel.
- # Implicit wait should let this resolve.
- self.click(charm_search)
- panel = driver.find_element_by_id('juju-search-charm-panel')
- if panel.is_displayed():
- return panel
-
- charm_panel = self.wait_for(
- charm_panel_loaded, error='Unable to load charm panel.')
+ # Warning!
+ # This depends on manage.jujucharms.com being up and working
properly.
+ # For many reasons, hopefully this is not an issue :-) but if
+ # some inexplicable failure is going on here, try that possible
+ # source.
+ def get_search_box(driver):
+ # The charm browser sidebar should be open by default.
+ return driver.find_element_by_css_selector('[name=bws-search]')
+
+ def get_charm_token(driver):
+ # See
http://www.w3.org/TR/css3-selectors/#attribute-substrings .
+ return driver.find_element_by_css_selector(
+ '.yui3-charmtoken-content '
+ '.charm-token[data-charmid*={}]'.format(charm_name))
+
+ def get_add_button(driver):
+ return
driver.find_element_by_css_selector('.bws-view-data .add')
+
+ def get_deploy_button(driver):
+ return driver.find_element_by_id('charm-deploy')
+
+ # Search for the charm
+ search_box = self.wait_for(
+ get_search_box, error='Charm search box is not visible')
+ search_box.send_keys(charm_name)
+ search_box.send_keys('\n')
+
+ # Open details page
+ charm_token = self.wait_for(
+ get_charm_token, error='Charm sidebar is not visible.')
+ charm_token.click()
+
+ # Create Ghost
+ add_button = self.wait_for(
+ ...

Read more...

Revision history for this message
Richard Harding (rharding) wrote :

LGTM with small notes.

https://codereview.appspot.com/10253055/diff/1/test/test_charm_running.py
File test/test_charm_running.py (right):

https://codereview.appspot.com/10253055/diff/1/test/test_charm_running.py#newcode119
test/test_charm_running.py:119: def get_search_box(driver):
is there any reason to go through search vs the default interesting data
enpoint? Just to verify that search is working?

https://codereview.appspot.com/10253055/diff/1/test/test_charm_running.py#newcode121
test/test_charm_running.py:121: return
driver.find_element_by_css_selector('[name=bws-search]')
so bws-search is another key we need to make sure to not change. I know
there was talk of re-designing the search area of the sidebar at some
point. Please update it with the same notes on breaking CI if it
changes.

https://codereview.appspot.com/10253055/

Revision history for this message
Jeff Pihach (hatch) wrote :

LGTM Thanks for taking over and fixing it up :)

https://codereview.appspot.com/10253055/diff/1/app/subapps/browser/templates/browser_charm.handlebars
File app/subapps/browser/templates/browser_charm.handlebars (right):

https://codereview.appspot.com/10253055/diff/1/app/subapps/browser/templates/browser_charm.handlebars#newcode15
app/subapps/browser/templates/browser_charm.handlebars:15: the other one
too! }}
Good idea with the comment!

https://codereview.appspot.com/10253055/

735. By Gary Poster

respond to review

Revision history for this message
Gary Poster (gary) wrote :

On 2013/06/14 17:26:32, rharding wrote:
> LGTM with small notes.

https://codereview.appspot.com/10253055/diff/1/test/test_charm_running.py
> File test/test_charm_running.py (right):

https://codereview.appspot.com/10253055/diff/1/test/test_charm_running.py#newcode119
> test/test_charm_running.py:119: def get_search_box(driver):
> is there any reason to go through search vs the default interesting
data
> enpoint? Just to verify that search is working?

At least in theory, this is a utility that lets you deploy arbitrary
charms. My goal was to duplicate the previous behavior--or at least the
advertised behavior :-) .

But yeah, even beyond that, this is in service of some integration
tests. I figured searching was not a bad thing in that context.

https://codereview.appspot.com/10253055/diff/1/test/test_charm_running.py#newcode121
> test/test_charm_running.py:121: return
> driver.find_element_by_css_selector('[name=bws-search]')
> so bws-search is another key we need to make sure to not change. I
know there
> was talk of re-designing the search area of the sidebar at some point.
Please
> update it with the same notes on breaking CI if it changes.

Done, thanks.

https://codereview.appspot.com/10253055/

Revision history for this message
Gary Poster (gary) wrote :

*** Submitted:

Fix CI tests

R=rharding, jeff.pihach
CC=
https://codereview.appspot.com/10253055

https://codereview.appspot.com/10253055/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/subapps/browser/templates/browser_charm.handlebars'
2--- app/subapps/browser/templates/browser_charm.handlebars 2013-06-14 13:14:27 +0000
3+++ app/subapps/browser/templates/browser_charm.handlebars 2013-06-14 18:06:25 +0000
4@@ -9,6 +9,9 @@
5 Close
6 {{/if}}
7 </a>
8+ {{! The add class is used by the deploy method in
9+ test/test_charm_running.py. If you change this name, change
10+ the other one too! }}
11 <a href="" class="add">Add</a>
12 <a href="" class="share">
13 <img src="/juju-ui/assets/images/browser_share_button_icon.png"
14
15=== modified file 'app/subapps/browser/templates/sidebar.handlebars'
16--- app/subapps/browser/templates/sidebar.handlebars 2013-04-22 03:35:20 +0000
17+++ app/subapps/browser/templates/sidebar.handlebars 2013-06-14 18:06:25 +0000
18@@ -5,6 +5,9 @@
19 <div class="bws-content">
20 </div>
21 </div>
22+ {{! The bws-view-data class is used by the deploy method in
23+ test/test_charm_running.py. If you change this name, change the other
24+ one too! }}
25 <div class="bws-view-data">
26 <div></div>
27 </div>
28
29=== modified file 'app/templates/browser-search.handlebars'
30--- app/templates/browser-search.handlebars 2013-05-02 04:32:19 +0000
31+++ app/templates/browser-search.handlebars 2013-06-14 18:06:25 +0000
32@@ -8,6 +8,9 @@
33 <a href="" class="delete">
34 <img src="/juju-ui/assets/images/browser_searchbox_delete_icon.png"
35 alt="Delete" /></a>
36+ {{! The bws-search name is used by the deploy method in
37+ test/test_charm_running.py. If you change this name, change
38+ the other one too! }}
39 <input type="search" name="bws-search"
40 value="{{ filters.text }}"
41 placeholder="Search charms"/>
42
43=== modified file 'app/templates/charm-token.handlebars'
44--- app/templates/charm-token.handlebars 2013-06-14 13:14:27 +0000
45+++ app/templates/charm-token.handlebars 2013-06-14 18:06:25 +0000
46@@ -1,3 +1,6 @@
47+{{! The charm-token class is used by the deploy method in
48+ test/test_charm_running.py. If you change this name, change the other
49+ one too! }}
50 <a href="/{{id}}"
51 class="charm-token yui3-g {{size}}"
52 data-charmid="{{id}}">
53
54=== modified file 'test/test_charm_running.py'
55--- test/test_charm_running.py 2013-06-12 14:14:36 +0000
56+++ test/test_charm_running.py 2013-06-14 18:06:25 +0000
57@@ -111,27 +111,47 @@
58
59 def deploy(self, charm_name):
60 """Deploy a charm."""
61- def charm_panel_loaded(driver):
62- """Wait for the charm panel to be ready and displayed."""
63- charm_search = driver.find_element_by_id('charm-search-trigger')
64- # Click to open the charm panel.
65- # Implicit wait should let this resolve.
66- self.click(charm_search)
67- panel = driver.find_element_by_id('juju-search-charm-panel')
68- if panel.is_displayed():
69- return panel
70-
71- charm_panel = self.wait_for(
72- charm_panel_loaded, error='Unable to load charm panel.')
73+ # Warning!
74+ # This depends on manage.jujucharms.com being up and working properly.
75+ # For many reasons, hopefully this is not an issue :-) but if
76+ # some inexplicable failure is going on here, try that possible
77+ # source.
78+ def get_search_box(driver):
79+ # The charm browser sidebar should be open by default.
80+ return driver.find_element_by_css_selector('[name=bws-search]')
81+
82+ def get_charm_token(driver):
83+ # See http://www.w3.org/TR/css3-selectors/#attribute-substrings .
84+ return driver.find_element_by_css_selector(
85+ '.yui3-charmtoken-content '
86+ '.charm-token[data-charmid*={}]'.format(charm_name))
87+
88+ def get_add_button(driver):
89+ return driver.find_element_by_css_selector('.bws-view-data .add')
90+
91+ def get_deploy_button(driver):
92+ return driver.find_element_by_id('charm-deploy')
93+
94+ # Search for the charm
95+ search_box = self.wait_for(
96+ get_search_box, error='Charm search box is not visible')
97+ search_box.send_keys(charm_name)
98+ search_box.send_keys('\n')
99+
100+ # Open details page
101+ charm_token = self.wait_for(
102+ get_charm_token, error='Charm sidebar is not visible.')
103+ charm_token.click()
104+
105+ # Create Ghost
106+ add_button = self.wait_for(
107+ get_add_button, error='Charm details page is not visible.')
108+ add_button.click()
109
110 # Deploy a charm.
111- deploy_button = charm_panel.find_element_by_css_selector(
112- # See http://www.w3.org/TR/css3-selectors/#attribute-substrings
113- 'button.deploy[data-url*={}]'.format(charm_name))
114- self.click(deploy_button)
115- # Click to confirm deployment.
116- confirm_button = charm_panel.find_element_by_id('charm-deploy')
117- self.click(confirm_button)
118+ deploy_button = self.wait_for(
119+ get_deploy_button, error='Charm config panel is not visible.')
120+ deploy_button.click()
121
122 # Zoom out so that it is possible to see the deployed service in
123 # Saucelabs. This also seems to fix a Firefox bug preventing the name

Subscribers

People subscribed via source and target branches