-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alert list splits alerts into keyword and representative alerts. New alert creation wizard which makes complicated alerts easier to create and also suggests related terms if we have any. Also allows editing alerts. Retains existing form for adding MP/postcode alerts.
- Loading branch information
Showing
15 changed files
with
1,686 additions
and
197 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -15,19 +15,29 @@ private function fetch_page($vars) { | |
return $this->base_fetch_page($vars, 'alert'); | ||
} | ||
|
||
private function get_page($vars = []) { | ||
return $this->base_fetch_page_user($vars, '1.fbb689a0c092f5534b929d302db2c8a9', 'alert'); | ||
} | ||
|
||
public function testFetchPage() { | ||
$page = $this->fetch_page([]); | ||
$this->assertStringContainsString('TheyWorkForYou Email Alerts', $page); | ||
} | ||
|
||
public function testKeywordOnly() { | ||
$page = $this->fetch_page([ 'alertsearch' => 'elephant']); | ||
$this->assertStringContainsString('Receive alerts when [elephant] is mentioned', $page); | ||
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); | ||
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value="elephant"', $page); | ||
} | ||
|
||
public function testSpeakerId() { | ||
$page = $this->fetch_page([ 'alertsearch' => 'speaker:2']); | ||
$this->assertStringContainsString('Mrs Test Current-MP', $page); | ||
} | ||
|
||
public function testPostCodeOnly() { | ||
$page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE']); | ||
$this->assertStringContainsString('when Mrs Test Current-MP', $page); | ||
$this->assertStringContainsString('Mrs Test Current-MP', $page); | ||
} | ||
|
||
public function testPostCodeWithKeyWord() { | ||
|
@@ -49,4 +59,73 @@ public function testPostcodeAndKeywordWithNoSittingMP() { | |
$this->assertStringContainsString('You have used a postcode and something else', $page); | ||
$this->assertStringNotContainsString('Did you mean to get alerts for when your MP', $page); | ||
} | ||
|
||
public function testBasicKeyWordAlertsCreation() { | ||
$page = $this->fetch_page([ 'step' => 'define']); | ||
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); | ||
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | ||
|
||
$page = $this->fetch_page([ 'step' => 'review', 'email' => '[email protected]', 'words[]' => 'fish']); | ||
$this->assertStringContainsString('Review Your Alert', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | ||
|
||
$page = $this->fetch_page([ 'step' => 'confirm', 'email' => '[email protected]', 'words[]' => 'fish']); | ||
$this->assertStringContainsString('We’re nearly done', $page); | ||
$this->assertStringContainsString('You should receive an email shortly', $page); | ||
} | ||
|
||
public function testMultipleKeyWordAlertsCreation() { | ||
$page = $this->fetch_page([ 'step' => 'define']); | ||
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); | ||
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | ||
|
||
$page = $this->fetch_page([ 'step' => 'review', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); | ||
$this->assertStringContainsString('Review Your Alert', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="salmon"', $page); | ||
|
||
$page = $this->fetch_page([ 'step' => 'confirm', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); | ||
$this->assertStringContainsString('You should receive an email shortly', $page); | ||
} | ||
|
||
public function testMultipleKeyWordAlertsCreationLoggedIn() { | ||
$page = $this->get_page(['step' => 'define']); | ||
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); | ||
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | ||
|
||
$page = $this->get_page([ 'step' => 'review', 'words[]' => ['fish', 'salmon']]); | ||
$this->assertStringContainsString('Review Your Alert', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="salmon"', $page); | ||
|
||
$page = $this->get_page([ 'step' => 'confirm', 'words[]' => ['fish', 'salmon']]); | ||
$this->assertStringContainsString('You will now receive email alerts on any day when [fish salmon] is mentioned in parliament', $page); | ||
} | ||
|
||
public function testKeyWordAndSectionAlertsCreationLoggedIn() { | ||
$page = $this->get_page(['step' => 'define']); | ||
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); | ||
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | ||
|
||
$page = $this->get_page(['step' => 'review', 'words[]' => 'fish', 'search_section' => 'debates']); | ||
$this->assertStringContainsString('Review Your Alert', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | ||
|
||
$page = $this->get_page(['step' => 'confirm', 'words[]' => 'fish', 'search_section' => 'debates']); | ||
$this->assertStringContainsString('You will now receive email alerts on any day when [fish] is mentioned in House of Commons debates', $page); | ||
} | ||
|
||
public function testKeyWordAndSpeakerAlertsCreationLoggedIn() { | ||
$page = $this->get_page(['step' => 'define']); | ||
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); | ||
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | ||
|
||
$page = $this->get_page(['step' => 'review', 'words[]' => 'fish', 'representative' => 'Mrs Test Current-MP']); | ||
$this->assertStringContainsString('Review Your Alert', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | ||
$this->assertStringContainsString('<input type="hidden" name="representative" value="Mrs Test Current-MP"', $page); | ||
|
||
$page = $this->get_page([ 'step' => 'confirm', 'words[]' => 'fish', 'representative' => 'Mrs Test Current-MP']); | ||
$this->assertStringContainsString('You will now receive email alerts on any day when Mrs Test Current-MP mentions [fish] in parliament', $page); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -150,6 +150,14 @@ | |
<table_data name="titles_ignored"> | ||
</table_data> | ||
<table_data name="users"> | ||
<row> | ||
<field name="user_id">1</field> | ||
<field name="firstname">Test</field> | ||
<field name="lastname">User</field> | ||
<field name="email">[email protected]</field> | ||
<field name="password">$2y$10$UNelQZqpPpO1jT.f7DLgeOdp.WBT81c5ECvOeTMFeQTBTyq3aCh8q</field> | ||
<field name="confirmed">1</field> | ||
</row> | ||
</table_data> | ||
<table_data name="uservotes"> | ||
</table_data> | ||
|
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
Oops, something went wrong.