mirror of
https://github.com/tchapi/davis.git
synced 2025-01-17 21:08:17 +01:00
Add first tests for dashboard pages
This commit is contained in:
parent
cad3e98507
commit
1cc5b2e5b7
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -73,4 +73,4 @@ jobs:
|
||||
if: matrix.dependencies == 'highest'
|
||||
run: composer update --no-progress --ansi
|
||||
- name: Run tests with PHPUnit
|
||||
run: vendor/bin/phpunit --colors=always
|
||||
run: vendor/bin/phpunit --process-isolation --colors=always
|
||||
|
@ -50,9 +50,9 @@
|
||||
<div class="hero">
|
||||
<img src="/images/logo.png" width="60px">
|
||||
<h3>{{ "davis.running"|trans }}</h3>
|
||||
<div>CalDAV : {% if calDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div>CardDAV : {% if cardDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div>WebDAV : {% if webDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div class="caldav">CalDAV : {% if calDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div class="carddav">CardDAV : {% if cardDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div class="webdav">WebDAV : {% if webDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<a href="{{ path('dashboard') }}" class="admin">{{ "admin.interface"|trans }}</a>
|
||||
</div>
|
||||
</body>
|
||||
|
88
tests/Functional/DashboardTest.php
Normal file
88
tests/Functional/DashboardTest.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class DashboardTest extends WebTestCase
|
||||
{
|
||||
public function testIndexPage(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertSelectorTextContains('h3', 'Davis is running.');
|
||||
|
||||
$this->assertSelectorExists('div.caldav');
|
||||
$this->assertSelectorExists('div.carddav');
|
||||
$this->assertSelectorExists('div.webdav');
|
||||
}
|
||||
|
||||
public function testDashboardPage(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/dashboard');
|
||||
|
||||
$this->assertResponseRedirects('/login');
|
||||
}
|
||||
|
||||
public function testLoginPage(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/login');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertSelectorTextContains('h1', 'Please sign in');
|
||||
$this->assertSelectorExists('nav.navbar');
|
||||
}
|
||||
|
||||
public function testLoginIncorrectUsername(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$crawler = $client->request('GET', '/login');
|
||||
|
||||
$form = $crawler->selectButton('Submit')->form();
|
||||
$form['username']->setValue('bad_'.$_ENV['ADMIN_LOGIN']);
|
||||
$form['password']->setValue('bad_password');
|
||||
|
||||
$client->submit($form);
|
||||
$this->assertResponseRedirects('/login');
|
||||
$crawler = $client->followRedirect();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$this->assertSelectorTextContains('div.alert.alert-danger', 'Username could not be found.');
|
||||
}
|
||||
|
||||
public function testLoginIncorrectPassword(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$crawler = $client->request('GET', '/login');
|
||||
|
||||
$form = $crawler->selectButton('Submit')->form();
|
||||
$form['username']->setValue($_ENV['ADMIN_LOGIN']);
|
||||
$form['password']->setValue('bad_password');
|
||||
|
||||
$client->submit($form);
|
||||
$this->assertResponseRedirects('/login');
|
||||
$crawler = $client->followRedirect();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$this->assertSelectorTextContains('div.alert.alert-danger', 'Invalid credentials.');
|
||||
}
|
||||
|
||||
public function testLoginCorrect(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$crawler = $client->request('GET', '/login');
|
||||
|
||||
$form = $crawler->selectButton('Submit')->form();
|
||||
$form['username']->setValue($_ENV['ADMIN_LOGIN']);
|
||||
$form['password']->setValue($_ENV['ADMIN_PASSWORD']);
|
||||
|
||||
$client->submit($form);
|
||||
$this->assertResponseRedirects('/dashboard');
|
||||
$crawler = $client->followRedirect();
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user