Commit 6096d80e authored by Dominik Hebeler's avatar Dominik Hebeler

Added basic tests for the availability of the startpage

parent 150d2b81
......@@ -21,3 +21,5 @@ npm-debug.log
/.project
composer.lock
local.log
tests/Browser/console/browserstack.log
<?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";
}
}
......@@ -23,12 +23,14 @@
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"php-webdriver/webdriver": "^1.6",
"browserstack/browserstack-local": "^1.1",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"galahad/dusk-browserstack": "^2.0",
"laravel/dusk": "^5.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"php-webdriver/webdriver": "^1.6",
"phpunit/phpunit": "^7.5"
},
"config": {
......@@ -69,4 +71,4 @@
"@php artisan key:generate --ansi"
]
}
}
\ No newline at end of file
}
......@@ -75,4 +75,4 @@ services:
working_dir: /html
volumes:
- .:/html
command: "./vendor/phpunit/phpunit/phpunit"
command: "php artisan dusk"
<?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 Spende extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/spende';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Ihre Spende für SUMA-EV und MetaGer")
->assertTitle("Spenden - MetaGer")
->switchLanguage("English")
->waitForText("Your Donation for MetaGer to SUMA-EV")
->assertTitle("Donation - MetaGer")
->switchLanguage("Español")
->waitForText("Su donación para SUME-EV y MetaGer")
->assertTitle("Donaciones - 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 Team extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/team';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("geschäftsführender Vorstand")
->assertTitle("Team - MetaGer")
->switchLanguage("English")
->waitForText("CEO")
->assertTitle("Team - MetaGer")
->switchLanguage("Español")
->waitForText("Director ejecutivo [CEO]")
->assertTitle("Nuestra gente - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\About;
use Tests\Browser\Pages\App;
use Tests\Browser\Pages\Datenschutz;
use Tests\Browser\Pages\Hilfe;
use Tests\Browser\Pages\HomePage;
use Tests\Browser\Pages\Impress;
use Tests\Browser\Pages\Kontakt;
use Tests\Browser\Pages\Spende;
use Tests\Browser\Pages\Team;
use Tests\DuskTestCase;
class StaticPagesTest extends DuskTestCase
{
private $bs = null;
/**
* Tests for each static page on MetaGers website whether it can be reached by navigation
*
* @return void
*/
public function testStartpage()
{