Skip to content

Commit

Permalink
Merge pull request mozilla#105 from klrmn/fix_logout
Browse files Browse the repository at this point in the history
Fix logout
  • Loading branch information
stephendonner committed Aug 1, 2012
2 parents efa9e65 + 22acf93 commit 9129bf9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 7 deletions.
10 changes: 7 additions & 3 deletions pages/desktop/base.py
Expand Up @@ -21,6 +21,8 @@ def sign_in(self, user="default"):

def sign_out(self):
self.header.click_logout()
from pages.desktop.support_home_page import SupportHomePage
return SupportHomePage(self.testsetup)

class HeaderRegion(Page):

Expand All @@ -39,9 +41,11 @@ def click_login(self):
return LoginPage(self.testsetup)

def click_logout(self):
account_menu_element = self.selenium.find_element(*self._account_dropdown_locator)
logout_element = self.selenium.find_element(*self._logout_locator)
ActionChains(self.selenium).move_to_element(account_menu_element).move_to_element(logout_element).click().perform()
ActionChains(self.selenium).move_to_element(
self.selenium.find_element(*self._account_dropdown_locator)
).move_to_element(
self.selenium.find_element(*self._logout_locator)
).click().perform()

@property
def is_user_logged_in(self):
Expand Down
76 changes: 72 additions & 4 deletions tests/desktop/test_login_logout.py
Expand Up @@ -18,12 +18,80 @@ def test_login(self, mozwebqa):

Assert.true(home_page.header.is_user_logged_in, 'User not shown to be logged in')

### logging out of the following pages redirects the user to the home page

@pytest.mark.native
@pytest.mark.nondestructive
def test_logout(self, mozwebqa):
home_page = PageProvider(mozwebqa).home_page(do_login=True, user='default')
Assert.true(home_page.header.is_user_logged_in, 'User not shown to be logged in')
@pytest.mark.parametrize('page_method', [
'home_page',
'new_question_page',
'questions_page',
'search_page',
'refine_search_page',
])
def test_logout_from_pages(self, mozwebqa, page_method):
page_under_test = getattr(PageProvider(mozwebqa), page_method)(do_login=True, user='default')
Assert.true(page_under_test.header.is_user_logged_in, 'User not shown to be logged in')

# sign out
home_page = page_under_test.sign_out()
home_page.is_the_current_page
Assert.false(home_page.header.is_user_logged_in)

@pytest.mark.native
@pytest.mark.nondestructive
def test_logout_from_new_kb_article_page(self, mozwebqa):
new_kb_page = PageProvider(mozwebqa).new_kb_article_page()
Assert.true(new_kb_page.header.is_user_logged_in, 'User not shown to be logged in')

# sign out
home_page = new_kb_page.sign_out()
home_page.is_the_current_page
Assert.false(home_page.header.is_user_logged_in)

@pytest.mark.native
@pytest.mark.destructive
def test_logout_from_edit_kb_article_page(self, mozwebqa):
kb_article_history = self._create_new_kb_article(mozwebqa)
kb_edit_article = kb_article_history.navigation.click_edit_article()

# sign out
home_page.sign_out()
home_page = kb_edit_article.sign_out()
home_page.is_the_current_page
Assert.false(home_page.header.is_user_logged_in)

@pytest.mark.native
@pytest.mark.destructive
def test_logout_from_translate_kb_article_page(self, mozwebqa):
kb_article_history = self._create_new_kb_article(mozwebqa)
kb_translate_pg = kb_article_history.navigation.click_translate_article()
kb_translate_pg.click_translate_language('Esperanto (eo)')

# sign out
home_page = kb_translate_pg.sign_out()
home_page.is_the_current_page
Assert.false(home_page.header.is_user_logged_in)

def _create_new_kb_article(self, mozwebqa):
kb_new_article = PageProvider(mozwebqa).new_kb_article_page()
article_info_dict = self._create_new_generic_article(kb_new_article)
kb_new_article.submit_article()
kb_article_history = kb_new_article.set_article_comment_box()
return kb_article_history

def _create_new_generic_article(self, kb_new_article):
import datetime
timestamp = datetime.datetime.now()

article_name = "test_article_%s" % timestamp
article_summary = "this is an automated summary_%s" % timestamp
article_content = "automated content_%s" % timestamp

article_info_dict = {'title': article_name,
'category': 'How to', 'keyword': 'test',
'summary': article_summary, 'content': article_content}

# create a new article
kb_new_article.set_article(article_info_dict)

return article_info_dict

0 comments on commit 9129bf9

Please sign in to comment.