EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311589

Change subject: Fixup search satisfaction browser tests
......................................................................

Fixup search satisfaction browser tests

These tests made a couple assumptions about page existence that
weren't true, they now include some extra calls to create pages where
necessary so all expected pages exist. Additionally the suggester index
expects to be built, so this has been adjusted to build the index via
an api call that only exists in wiki's pulling in the Jenkins.php
configuration from CirrusSearch (available in cirrustestwiki within
vagrant).

Change-Id: I34560301fe8871573f4914406773d5a04fc5d4b1
---
M tests/browser/SearchSatisfactionTests.php
1 file changed, 30 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents 
refs/changes/89/311589/1

diff --git a/tests/browser/SearchSatisfactionTests.php 
b/tests/browser/SearchSatisfactionTests.php
index 2b5654a..fa35bfc 100644
--- a/tests/browser/SearchSatisfactionTests.php
+++ b/tests/browser/SearchSatisfactionTests.php
@@ -44,6 +44,8 @@
  *   sudo rm -rf /var/cache/apache2/mod_cache_disk/*
  */
 class SearchSatisfactionTest extends PHPUnit_Framework_TestCase {
+       static private $mwBaseUrl;
+
        protected $webDriver;
 
        public function setUp() {
@@ -82,10 +84,13 @@
 
                $baseUrl = getenv( 'SELENIUM_URL_BASE' );
                if ( !$baseUrl ) {
-                       $baseUrl = "http://localhost:8080/wiki/";;
+                       // Need to use cirrustest for the api action to rebuild 
the suggester
+                       // to work. Note sure yet if this causes any issues for 
Cirrus browser
+                       // tests...
+                       $baseUrl = 
"http://cirrustest.wiki.local.wmftest.net:8080/wiki/";;
                }
                // evil hax to attach our own property
-               $this->webDriver->mwBaseUrl = $baseUrl;
+               self::$mwBaseUrl = $baseUrl;
 
                $eventLoggingPath = getenv( 'MW_EVENT_LOG' );
                if ( $eventLoggingPath ) {
@@ -95,6 +100,18 @@
                }
                if ( !is_file( $this->eventLoggingPath ) ) {
                        throw new \RuntimeException( "Couldn't find 
eventlogging.log. Please provide a path with MW_EVENT_LOG environment var" );
+               }
+
+
+               static $initializedSuggester = null;
+               if ( $initializedSuggester === null ) {
+                       $initializedSuggester = (bool)getenv( 
'SKIP_SUGGESTER_INIT' );
+               }
+               if ( !$initializedSuggester ) {
+                       // The autocomplete tests expect nothing more than 
'Main Page' to exist, so
+                       // no other setup is necessary.
+                       $this->apiCall(['action' => 'cirrus-suggest-index']);
+                       $initializedSuggester = true;
                }
        }
 
@@ -124,6 +141,7 @@
                        ),
                        "full text search click through, back, click different 
result" => array(
                                array(
+                                       $this->ensurePage('Something else', 
'contains the word main in the content'),
                                        $this->visitPage( 
"Special:Search?search=main" ),
                                        $this->clickSearchResult( 0 ),
                                        $this->sleep( 2 ),
@@ -165,8 +183,9 @@
                        ),
                        "full text search alt title click through" => array(
                                array(
+                                       $this->ensurePage( 'With Headings', 
"Something\n==Role==\nmore content" ),
                                        $this->visitPage( 
"Special:Search?search=role" ),
-                                       $this->ctrlClickAltTitleSearchResult( 0 
),
+                                       $this->clickAltTitleSearchResult( 0 ),
                                ),
                                array(
                                        array( 'action' => 'searchResultPage', 
'source' => 'fulltext', 'position' => null ),
@@ -176,6 +195,7 @@
                        ),
                        "full text search alt title ctrl-click through" => 
array(
                                array(
+                                       $this->ensurePage( 'With Headings', 
"Something\n==Role==\nmore content" ),
                                        $this->visitPage( 
"Special:Search?search=role" ),
                                        $this->ctrlClickAltTitleSearchResult( 0 
),
                                ),
@@ -603,6 +623,10 @@
                $seen = array();
                foreach ( $actualEvents as $idx => $envelope ) {
                        $actualEvent = $envelope['event'];
+                       // Only concerned with satisfaction events
+                       if ( $envelope['schema'] !== 'TestSearchSatisfaction2' 
) {
+                               continue;
+                       }
                        // Filter unreliable checkin events
                        if ( $actualEvent['action'] === 'checkin' ) {
                                continue;
@@ -662,7 +686,7 @@
 
        protected function visitPage( $url ) {
                return function ( $webDriver ) use ( $url ) {
-                       $webDriver->get( $webDriver->mwBaseUrl . $url );
+                       $webDriver->get( self::$mwBaseUrl . $url );
                };
        }
 
@@ -889,7 +913,8 @@
                        $context = null;
                }
 
-               return json_decode( file_get_contents( 
'http://localhost:8080/w/api.php?' . http_build_query( $params + array(
+               $apiUrl = str_replace( '/wiki/', '/w/api.php', self::$mwBaseUrl 
);
+               return json_decode( file_get_contents( $apiUrl . '?' . 
http_build_query( $params + array(
                        'format' => 'json',
                        'formatversion' => 2,
                ) ), false, $context ), true );

-- 
To view, visit https://gerrit.wikimedia.org/r/311589
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I34560301fe8871573f4914406773d5a04fc5d4b1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to