Commit e8b064cc authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch 'development' of https://gitlab.metager.de/open-source/MetaGer into development

parents ecce3d7d 9b5b4ada
......@@ -21,3 +21,4 @@ npm-debug.log
/.project
composer.lock
local.log
\ No newline at end of file
......@@ -215,5 +215,4 @@ integrationtest:
- sed -i "s#^APP_URL=.*#APP_URL=$URL#g" .env
- sed -i "s#^BRANCH_NAME=.*#BRANCH_NAME=$CI_COMMIT_REF_NAME#g" .env
- sed -i "s#^COMMIT_NAME=.*#COMMIT_NAME=$CI_COMMIT_REF_SLUG#g" .env
- ./vendor/phpunit/phpunit/phpunit
- php artisan dusk
\ No newline at end of file
<?php
namespace App;
use BrowserStack\Local;
use Facebook\WebDriver\Remote\RemoteWebDriver;
class Browserstack
{
private $webdriver, $bs_local = null;
private $LOCALCAPABILITIES = array();
private $CAPABILITIES = array();
public function __construct()
{
$this->setCapabilities();
$caps = null;
if ($this->isLocal()) {
$caps = $this->LOCALCAPABILITIES;
$this->bs_local = new Local();
$bs_local_args = array("key" => env("WEBDRIVER_KEY", ""));
$this->bs_local->start($bs_local_args);
} else {
$caps = $this->CAPABILITIES;
}
$this->webdriver = RemoteWebDriver::create(
getenv("WEBDRIVER_URL"),
$caps
);
}
private function setCapabilities()
{
$this->LOCALCAPABILITIES = array(
"os" => "Windows",
"os_version" => "10",
"browser" => "Firefox",
"browser_version" => "79.0 beta",
"resolution" => "1920x1080",
"project" => env("PROJECT_NAME", "Not Set"),
"build" => env("BRANCH_NAME", "Not Set"),
"name" => env("COMMIT_NAME", "Not Set"),
"browserstack.local" => "true",
"browserstack.console" => "verbose",
"browserstack.networkLogs" => "true",
"browserstack.timezone" => "Europe/Berlin",
"browserstack.selenium_version" => "3.5.2",
);
$this->CAPABILITIES = array(
"os" => "Windows",
"os_version" => "10",
"browser" => "Firefox",
"browser_version" => "79.0 beta",
"resolution" => "1920x1080",
"project" => env("PROJECT_NAME", "Not Set"),
"build" => env("BRANCH_NAME", "Not Set"),
"name" => env("COMMIT_NAME", "Not Set"),
"browserstack.local" => "false",
"browserstack.console" => "verbose",
"browserstack.networkLogs" => "true",
"browserstack.timezone" => "Europe/Berlin",
"browserstack.selenium_version" => "3.5.2",
);
}
public function getWebdriver()
{
return $this->webdriver;
}
public function shutdown()
{
$this->webdriver->quit();
if ($this->bs_local != null) {
$this->bs_local->stop();
}
}
private function isLocal()
{
return env("APP_URL", "") === "http://nginx";
}
}
<?php
namespace App\Traits;
use BrowserStack\Local;
use Facebook\WebDriver\Remote\RemoteWebDriver;
/**
* Run BrowserStack from your tests.
*/
trait SupportsBrowserStack
{
protected static $bs_local;
/**
* Create the BrowserStack WebDriver instance.
*/
public function createBrowserStackDriver(array $config = null): RemoteWebDriver
{
if ($config["capabilities"]["browserstack.local"] === "true") {
$this->bs_local = new Local();
$bs_local_args = [
"key" => $config["key"],
];
$this->bs_local->start($bs_local_args);
}
return RemoteWebDriver::create(
"https://$config[username]:$config[key]@hub-cloud.browserstack.com/wd/hub",
$config["capabilities"]
);
}
/**
* @afterClass
*/
public static function shutdown()
{
if (static::$bs_local && static::$bs_local->isRunning()) {
static::$bs_local->stop();
}
}
}
......@@ -75,4 +75,4 @@ services:
working_dir: /html
volumes:
- .:/html
command: "./vendor/phpunit/phpunit/phpunit"
command: "php artisan dusk"
/bin/sh: 1: ps: not found
/bin/sh: 1: ps: not found
Thu Jul 09 2020 11:17:18 GMT+0000 (UTC) -- [INFO] Started the BrowserStack Binary server on 45691, PID: 22
Thu Jul 09 2020 11:17:19 GMT+0000 (UTC) -- [SUCCESS] You can now access your local server(s) in our remote browser
Thu Jul 09 2020 11:17:19 GMT+0000 (UTC) -- Press Ctrl-C to exit
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class About extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/about';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Was MetaGer auszeichnet")
->assertTitle("Über Uns - MetaGer")
->switchLanguage("English")
->waitForText("MetaGer - Characteristic qualities")
->assertTitle("About Us - MetaGer")
->switchLanguage("Español")
->waitForText("Was MetaGer auszeichnet")
->assertTitle("Sobre nosotros - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class App extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/app';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Diese App bringt die volle Power unserer Suchmaschine auf ihr Smartphone.")
->assertTitle("Apps - MetaGer")
->switchLanguage("English")
->waitForText("This App brings the full Metager power to your smartphone.")
->assertTitle("Apps - MetaGer")
->switchLanguage("Español")
->waitForText("Diese App bringt die volle Power unserer Suchmaschine auf ihr Smartphone.")
->assertTitle("Aplicaciones - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Datenschutz extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/datenschutz';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Datenschutz bei MetaGer/SUMA-EV")
->assertTitle("Datenschutz und Privatsphäre - MetaGer")
->switchLanguage("English")
->waitForText("Data protection at MetaGer/SUMA-EV")
->assertTitle("Privacy - MetaGer")
->switchLanguage("Español")
->waitForText("Data protection at MetaGer/SUMA-EV")
->assertTitle("Protección de datos y privacidad - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Hilfe extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/hilfe';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("MetaGer - Hilfe")
->assertTitle("Hilfe - MetaGer")
->switchLanguage("English")
->waitForText("MetaGer Help")
->assertTitle("Help - MetaGer")
->switchLanguage("Español")
->waitForText("MetaGer - Hilfe")
->assertTitle("Ayuda - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class HomePage extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
# German
$browser->assertPathIs($this->url())
->waitForText("Garantierte Privatsphäre", 1)
->assertTitle('MetaGer - Mehr als eine Suchmaschine')
->assertSee("Vielfältig & Frei")
->assertSee("100% Ökostrom")
->assertSee("Gemeinnütziger Verein")
->switchLanguage("English")
->waitForText("Guaranteed Privacy", 1)
->assertTitle('MetaGer: Privacy Protected Search & Find')
->assertSee("Diverse & free")
->assertSee("100 % renewable energy")
->assertSee("Nonprofit organization")
->switchLanguage("Español")
->waitForText("Privacidad garantizada", 1)
->assertTitle('MetaGer: Buscar & encontrar seguro, proteger la privacidad')
->assertSee("Diversa y libre")
->assertSee("Energía 100% renovable")
->assertSee("Organización sin ánimo de lucro")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@sidebarToggle' => 'label.sidebar-opener[for=sidebarToggle]',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Impress extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/impressum';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Haftungshinweis:")
->assertTitle("Impressum - MetaGer")
->switchLanguage("English")
->waitForText("Liability Note:")
->assertTitle("Site Notice - MetaGer")
->switchLanguage("Español")
->waitForText("Exención de responsabilidad")
->assertTitle("Aviso legal - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Kontakt extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/kontakt';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Sicheres Kontaktformular")
->assertTitle("Kontakt - MetaGer")
->switchLanguage("English")
->waitForText("Secure Contact Form")
->assertTitle("Contact - MetaGer")
->switchLanguage("Español")
->waitForText("Formulario de contacto seguro")
->assertTitle("Contacto - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
use Laravel\Dusk\Page as BasePage;
abstract class Page extends BasePage
{
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public static function siteElements()
{
return [
'@sidebarToggle' => 'label.sidebar-opener[for=sidebarToggle]',
'@languageDropdown' => '#navigationSprache',
];
}
public function switchLanguage(Browser $browser, $language)
{
$browser->waitFor("@sidebarToggle")
->click("@sidebarToggle")
->click("@languageDropdown")
->clickLink($language);
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Plugin extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/plugin';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("MetaGer zum Firefox hinzufügen")
->assertTitle("Plugin - MetaGer")
->switchLanguage("English")
->waitForText("Add MetaGer to your Firefox")
->assertTitle("Plugin - MetaGer")
->switchLanguage("Español")
->waitForText("Añadir MetaGer a Firefox")
->assertTitle("Plugin - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class SitesearchWidget extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/sitesearch/';
}
/**
* Assert that the browser is on the page.