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
bc162ed
commit ebf2c95
Showing
7 changed files
with
125 additions
and
40 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 |
---|---|---|
|
@@ -16,7 +16,8 @@ def check(self, choice=0): | |
self.css('label')[0].click() # activate select | ||
self.css('label')[choice].click() | ||
self.css('button')[0].click() | ||
assert self.wait_for_success() == 'Check your inbox for a verification link.' | ||
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 join emails e on c.nonce = e.nonce') | ||
|
||
def finish_claiming(self): | ||
|
@@ -158,23 +159,23 @@ def setUp(self): | |
, emails=['[email protected]', '[email protected]', '[email protected]'] | ||
) | ||
|
||
def visit_as(self, username): | ||
self.visit('/') | ||
self.sign_in(username) | ||
self.visit('/on/npm/') | ||
|
||
def test_anon_gets_sign_in_prompt(self): | ||
self.visit('/on/npm/') | ||
assert self.css('.important-button button').text == 'Sign in / Sign up' | ||
|
||
def test_auth_without_email_gets_highlighted_link_to_email(self): | ||
self.make_participant('alice', claimed_time='now') | ||
self.visit('/') | ||
self.sign_in('alice') | ||
self.visit('/on/npm/') | ||
self.visit_as('alice') | ||
assert self.css('.highlight').text == 'Link an email' | ||
|
||
def test_auth_without_claimable_packages_gets_disabled_apply_button(self): | ||
self.make_participant('doug', claimed_time='now', email_address='[email protected]') | ||
self.visit('/') | ||
self.sign_in('doug') | ||
self.visit('/on/npm/') | ||
|
||
self.visit_as('doug') | ||
button = self.css('.important-button button') | ||
assert button.text == 'Apply to accept payments' | ||
assert button['disabled'] == 'true' | ||
|
@@ -183,10 +184,7 @@ def test_auth_with_claimable_packages_gets_apply_button(self): | |
alice = self.make_participant('alice', claimed_time='now', | ||
email_address='[email protected]') | ||
self.add_and_verify_email(alice, '[email protected]') | ||
self.visit('/') | ||
self.sign_in('alice') | ||
self.visit('/on/npm/') | ||
|
||
self.visit_as('alice') | ||
button = self.css('.important-button button') | ||
assert button.text == 'Apply to accept payments' | ||
assert button['disabled'] is None | ||
|
@@ -197,12 +195,43 @@ def test_differentiates_claimed_packages(self): | |
email_address='[email protected]') | ||
Package.from_names(NPM, 'foo').get_or_create_linked_team(self.db, alice) | ||
Package.from_names(NPM, 'bar').get_or_create_linked_team(self.db, bob) | ||
self.visit('/') | ||
self.sign_in('alice') | ||
self.visit('/on/npm/') | ||
|
||
self.visit_as('alice') | ||
assert self.css('.i1').has_class('disabled') | ||
assert self.css('.i1 .owner a').text == '~bob' | ||
assert not self.css('.i2').has_class('disabled') | ||
assert self.css('.i3').has_class('disabled') | ||
assert self.css('.i3 .owner a').text == 'you' | ||
|
||
def test_sends_mail(self): | ||
self.make_participant('cat', claimed_time='now', email_address='[email protected]') | ||
self.visit_as('cat') | ||
self.css('.important-button button').click() | ||
assert self.wait_for_success() == 'Check [email protected] for a verification link.' | ||
|
||
def test_sends_one_mail_per_address(self): | ||
cat = self.make_participant('cat', claimed_time='now', email_address='[email protected]') | ||
self.add_and_verify_email(cat, '[email protected]') | ||
self.visit_as('cat') | ||
self.css('.important-button button').click() | ||
assert self.wait_for_success() == 'Check [email protected] for a verification link.' | ||
assert self.wait_for_success() == 'Check [email protected] for a verification link.' | ||
|
||
def test_sends_one_mail_for_multiple_packages(self): | ||
self.make_participant('alice', claimed_time='now', email_address='[email protected]') | ||
self.visit_as('alice') | ||
self.css('.important-button button').click() | ||
assert len(self.css('table.listing td.item')) == 3 | ||
assert self.wait_for_success() == 'Check [email protected] for a verification link.' | ||
assert self.db.one('select count(*) from claims') == 3 | ||
assert self.db.one('select count(*) from email_queue') == 1 | ||
|
||
def test_doesnt_send_for_unclaimable_packages(self): | ||
self.make_participant('alice', claimed_time='now', email_address='[email protected]') | ||
cat = self.make_participant('cat', claimed_time='now', email_address='[email protected]') | ||
Package.from_names(NPM, 'baz').get_or_create_linked_team(self.db, cat) | ||
self.visit_as('alice') | ||
self.css('.important-button button').click() | ||
assert len(self.css('table.listing td.item')) == 3 | ||
assert self.wait_for_success() == 'Check [email protected] for a verification link.' | ||
assert self.db.one('select count(*) from claims') == 2 | ||
assert self.db.one('select count(*) from email_queue') == 1 |
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