forked from CIT/Vmeda.Online
		
	MOBILE-3833 behat: Document performance config
This commit is contained in:
		
							parent
							
								
									faec9c4a8e
								
							
						
					
					
						commit
						994d1bb149
					
				@ -14,6 +14,8 @@
 | 
				
			|||||||
// You should have received a copy of the GNU General Public License
 | 
					// You should have received a copy of the GNU General Public License
 | 
				
			||||||
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 | 
					// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Behat\Mink\Exception\DriverException;
 | 
				
			||||||
 | 
					use Facebook\WebDriver\Exception\InvalidArgumentException;
 | 
				
			||||||
use Moodle\BehatExtension\Driver\WebDriver;
 | 
					use Moodle\BehatExtension\Driver\WebDriver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -268,7 +270,7 @@ class performance_measure implements behat_app_listener {
 | 
				
			|||||||
        $scripting = 0;
 | 
					        $scripting = 0;
 | 
				
			||||||
        $styling = 0;
 | 
					        $styling = 0;
 | 
				
			||||||
        $networking = 0;
 | 
					        $networking = 0;
 | 
				
			||||||
        $logs = $this->driver->getWebDriver()->manage()->getLog('performance');
 | 
					        $logs = $this->getPerformanceLogs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach ($logs as $log) {
 | 
					        foreach ($logs as $log) {
 | 
				
			||||||
            // TODO this should filter by end time as well, but it seems like the timestamps are not
 | 
					            // TODO this should filter by end time as well, but it seems like the timestamps are not
 | 
				
			||||||
@ -304,4 +306,39 @@ class performance_measure implements behat_app_listener {
 | 
				
			|||||||
        $this->networking = $networking;
 | 
					        $this->networking = $networking;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get performance logs.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return array Performance logs.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private function getPerformanceLogs(): array {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            return $this->driver->getWebDriver()->manage()->getLog('performance');
 | 
				
			||||||
 | 
					        } catch (InvalidArgumentException $e) {
 | 
				
			||||||
 | 
					            throw new DriverException(
 | 
				
			||||||
 | 
					                implode("\n", [
 | 
				
			||||||
 | 
					                    "It wasn't possible to get performance logs, make sure that you have configured the following capabilities:",
 | 
				
			||||||
 | 
					                    "",
 | 
				
			||||||
 | 
					                    "\$CFG->behat_profiles = [",
 | 
				
			||||||
 | 
					                    "    'default' => [",
 | 
				
			||||||
 | 
					                    "        'browser' => 'chrome',",
 | 
				
			||||||
 | 
					                    "        'wd_host' => 'http://selenium:4444/wd/hub',",
 | 
				
			||||||
 | 
					                    "        'capabilities' => [",
 | 
				
			||||||
 | 
					                    "            'extra_capabilities' => [",
 | 
				
			||||||
 | 
					                    "                'goog:loggingPrefs' => ['performance' => 'ALL'],",
 | 
				
			||||||
 | 
					                    "                'chromeOptions' => [",
 | 
				
			||||||
 | 
					                    "                    'perfLoggingPrefs' => [",
 | 
				
			||||||
 | 
					                    "                        'traceCategories' => 'devtools.timeline',",
 | 
				
			||||||
 | 
					                    "                    ],",
 | 
				
			||||||
 | 
					                    "                ],",
 | 
				
			||||||
 | 
					                    "            ],",
 | 
				
			||||||
 | 
					                    "        ],",
 | 
				
			||||||
 | 
					                    "    ],",
 | 
				
			||||||
 | 
					                    ");",
 | 
				
			||||||
 | 
					                    "",
 | 
				
			||||||
 | 
					                ])
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,25 @@
 | 
				
			|||||||
@app @javascript @performance
 | 
					@app @javascript @performance
 | 
				
			||||||
Feature: Measure performance.
 | 
					Feature: Measure performance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # In order to run performance tests, you need to add the following capabilities to your Behat configuration:
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # $CFG->behat_profiles = [
 | 
				
			||||||
 | 
					  #     'default' => [
 | 
				
			||||||
 | 
					  #         'browser' => 'chrome',
 | 
				
			||||||
 | 
					  #         'wd_host' => 'http://selenium:4444/wd/hub',
 | 
				
			||||||
 | 
					  #         'capabilities' => [
 | 
				
			||||||
 | 
					  #             'extra_capabilities' => [
 | 
				
			||||||
 | 
					  #                 'goog:loggingPrefs' => ['performance' => 'ALL'],
 | 
				
			||||||
 | 
					  #                 'chromeOptions' => [
 | 
				
			||||||
 | 
					  #                     'perfLoggingPrefs' => [
 | 
				
			||||||
 | 
					  #                         'traceCategories' => 'devtools.timeline',
 | 
				
			||||||
 | 
					  #                     ],
 | 
				
			||||||
 | 
					  #                 ],
 | 
				
			||||||
 | 
					  #             ],
 | 
				
			||||||
 | 
					  #         ],
 | 
				
			||||||
 | 
					  #     ],
 | 
				
			||||||
 | 
					  # ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Background:
 | 
					  Background:
 | 
				
			||||||
    Given the following "users" exist:
 | 
					    Given the following "users" exist:
 | 
				
			||||||
      | username |
 | 
					      | username |
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user