Skip to content

Commit

Permalink
feat: Event detail autotest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KminekMatej committed Dec 7, 2024
1 parent f78d0b3 commit 01cac6e
Showing 1 changed file with 17 additions and 42 deletions.
59 changes: 17 additions & 42 deletions app/module/autotest/app/event/EventDetailUiTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
namespace Tymy\Module\Autotest\Event;

use Nette;
use Tester\Assert;
use Tester\DomQuery;
use Tymy\Bootstrap;
use Tymy\Module\Autotest\UITest;

Expand All @@ -14,40 +12,13 @@

class EventDetailUiTest extends UITest
{

private function eventDetailInputs()
{
return [
[
[
"adminMode" => TRUE,
"username" => $GLOBALS["testedTeam"]["user_admin"],
"password" => $GLOBALS["testedTeam"]["pass_admin"],
"eventId" => $GLOBALS["testedTeam"]["testEventId"]
]
],
[
[
"adminMode" => FALSE,
"username" => $GLOBALS["testedTeam"]["user"],
"password" => $GLOBALS["testedTeam"]["pass"],
"eventId" => $GLOBALS["testedTeam"]["testEventId"]
]
],
];
}

/** @dataProvider eventDetailInputs */
public function testActionEventAdmin($inputs)
public function testEvent()
{
$this->userTapiAuthenticate($inputs["username"], $inputs["password"]);
$request = new Nette\Application\Request(self::PRESENTERNAME, 'GET', array('action' => 'event', "udalost" => $inputs["eventId"]));
$response = $this->presenter->run($request);

Assert::type('Nette\Application\Responses\TextResponse', $response);

$html = (string) $response->getSource();
$dom = DomQuery::fromHtml($html);
$this->authorizeAdmin();
$event = $this->recordManager->createEvent();

$this->authorizeUser();
$dom = parent::getDomForAction($this->presenter, 'event', ["udalost" => $event["id"]]);

//has navbar
Assert::true($dom->has('div#snippet-navbar-nav'));
Expand All @@ -57,13 +28,8 @@ public function testActionEventAdmin($inputs)
Assert::equal(count($dom->find('ol.breadcrumb li.breadcrumb-item')), 3); //last item aint link
//test body
Assert::true($dom->has('div.container.event div.row div.col div.card.sh-box.my-3 div.card-header div.row div.col h4.card-title'));
$pencilBtn = 'div.container.event div.row div.col div.card.sh-box.my-3 div.card-header div.row div.col.col-md-auto a.btn.btn-sm.btn-light.btn-light-bordered i.fa.fa-edit';
if ($inputs["adminMode"]) {
Assert::true($dom->has($pencilBtn));
} else {
Assert::false($dom->has($pencilBtn));
}



Assert::true($dom->has('div.container.event div.row div.col div.card.sh-box.my-3 div.card-body h6.card-subtitle.mb-2.text-muted span a'));
Assert::true($dom->has('div.container.event div.row div.col div.card.sh-box.my-3 div.card-body p.card-text'));
Assert::equal(count($dom->find('div.container.event div.row div.col div.card.sh-box.my-3 div.card-body div.row div.col-lg-4 table.table.mb-0 tr th')), 3);
Expand All @@ -75,6 +41,15 @@ public function testActionEventAdmin($inputs)

Assert::true($dom->has('div.container.event div.row div.col div.card.sh-box.my-3#snippet--attendanceTabs div.card-header ul.nav.nav-tabs.flex-column.flex-sm-row.card-header-tabs li.nav-item'));
Assert::true($dom->has('div.container.event div.row div.col div.card.sh-box.my-3#snippet--attendanceTabs div.card-body div.tab-content div.tab-pane.fade.player-list div.row.my-2'));

//admin sees also pencil button
$this->authorizeAdmin();
$dom = parent::getDomForAction($this->presenter, 'event', ["udalost" => $event["id"]]);

$pencilBtn = 'div.container.event div.row div.col div.card.sh-box.my-3 div.card-header div.row div.col.col-md-auto a.btn.btn-sm.btn-light.btn-light-bordered i.fa.fa-edit';
Assert::true($dom->has($pencilBtn));

$this->recordManager->deleteEvent($event["id"]);
}

protected function getPresenter(): string
Expand Down

0 comments on commit 01cac6e

Please sign in to comment.