This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd88251
commit ae7ca59
Showing
5 changed files
with
82 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,25 @@ | |
|
||
class Test(BrowserHarness): | ||
|
||
def check(self, choice=0): | ||
self.make_participant('alice', claimed_time='now') | ||
def setUp(self): | ||
BrowserHarness.setUp(self) | ||
self.alice = self.make_participant( 'alice' | ||
, claimed_time='now' | ||
, email_address='[email protected]' | ||
) | ||
self.add_and_verify_email(self.alice, '[email protected]') | ||
self.sign_in('alice') | ||
|
||
def choose(self, choice=0): | ||
self.css('#content li.selected label').click() # activate select | ||
want = self.css('#content label')[choice] | ||
want.click() | ||
return want.text | ||
|
||
def check(self, choice=0): | ||
self.visit('/on/npm/foo') | ||
self.css('#content label')[0].click() # activate select | ||
self.css('#content label')[choice].click() | ||
self.css('#content button')[0].click() | ||
self.choose(choice) | ||
self.css('#content .important-button button').click() | ||
address = ('alice' if choice == 0 else 'bob') + '@example.com' | ||
assert self.wait_for_success() == 'Check {} for a verification link.'.format(address) | ||
return self.db.one('select address from claims c ' | ||
|
@@ -39,18 +51,33 @@ def test_can_send_to_second_email(self): | |
self.make_package(emails=['[email protected]', '[email protected]']) | ||
assert self.check(choice=1) == '[email protected]' | ||
|
||
def test_disabled_items_are_disabled(self): | ||
self.make_package(emails=['[email protected]', '[email protected]']) | ||
alice = self.make_participant('alice', claimed_time='now') | ||
self.add_and_verify_email(alice, '[email protected]', 'bob@example.com') | ||
self.sign_in('alice') | ||
def test_button_varies_with_email_state(self): | ||
self.make_package(emails=['[email protected]', '[email protected]', '[email protected]', | ||
'[email protected]', '[email protected]']) | ||
self.make_participant('doug', claimed_time='now', email_address='doug@example.com') | ||
self.alice.start_email_verification('[email protected]') | ||
self.visit('/on/npm/foo') | ||
self.css('#content label')[0].click() # activate select | ||
self.css('#content label')[1].click() # click second item | ||
self.css('#content li')[0].has_class('selected') # first item is still selected | ||
self.css('#content ul')[0].has_class('open') # still open | ||
self.css('#content button').has_class('disabled') | ||
assert self.db.all('select * from claims') == [] | ||
|
||
self.choose(0) == '[email protected]' | ||
self.css('li.selected').text.endswith('Your primary email address') | ||
self.css('button').text == 'Apply to accept payments' | ||
|
||
self.choose(1) == '[email protected]' | ||
self.css('li.selected').text.endswith('Linked to your account') | ||
self.css('button').text == 'Apply to accept payments' | ||
|
||
self.choose(2) == '[email protected]' | ||
self.css('li.selected').text.endswith('Verification pending') | ||
self.css('button').text == 'Verify email address' | ||
|
||
self.choose(3) == '[email protected]' | ||
self.css('li.selected').text.endswith('Ready to verify') | ||
self.css('button').text == 'Verify email address' | ||
|
||
# doug is last, can't even be selected | ||
self.choose(4) == '[email protected]' | ||
self.css('li.selected label') == '[email protected]' | ||
self.css('#content li')[4].text.endswith('Linked to a different account') | ||
|
||
|
||
def test_claimed_packages_can_be_given_to(self): | ||
|
@@ -79,7 +106,7 @@ def test_visiting_verify_link_shows_helpful_information(self): | |
self.make_package() | ||
self.check() | ||
|
||
link = pickle.loads(self.db.one('select context from email_messages'))['link'] | ||
link = pickle.loads(self.db.all('select context from email_messages')[-1])['link'] | ||
link = link[len(self.base_url):] # strip because visit will add it back | ||
|
||
self.visit(link) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters