add test for one stop scenario
This commit is contained in:
parent
8cb1f9342c
commit
2e2cf65a46
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"supportFile": "cypress/support/index.ts",
|
"supportFile": "cypress/support/index.ts",
|
||||||
"fixturesFolder": false,
|
"fixturesFolder": false,
|
||||||
"baseUrl": "http://czydojade.localhost:8080"
|
"baseUrl": "http://czydojade.localhost:8080/dummy/",
|
||||||
|
"modifyObstructiveCode": false
|
||||||
}
|
}
|
@ -1,10 +1,26 @@
|
|||||||
describe("The Start Page", () => {
|
describe("Get departures for one stop", () => {
|
||||||
it("Sucessfully Loads", () => {
|
it("Sucessfully Loads", () => {
|
||||||
cy.visit('/dummy');
|
cy.visit('/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Allows to open favourites window", () => {
|
it("Allows to search", () => {
|
||||||
cy.get('#open_favourites_picker').click();
|
cy.get('.finder input').type("Lipo");
|
||||||
cy.get('#favourites_list').should('exist');
|
|
||||||
})
|
cy.get('.finder__stops ul li:first-child').should('contain.text', 'Lipowa')
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Allows to pick a stop', () => {
|
||||||
|
cy.get('.finder__stops ul li:first-child button[data-action="add"]').click();
|
||||||
|
|
||||||
|
cy.get('#stops li:first-child').should('contain.text', 'Lipowa')
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('Shows departures from picked stop', () => {
|
||||||
|
cy.get('#departures .departures .stop__name').should('contain.text', 'Lipowa');
|
||||||
|
});
|
||||||
|
|
||||||
|
// it("Allows to open favourites window", () => {
|
||||||
|
// cy.get('#open_favourites_picker').click();
|
||||||
|
// cy.get('#favourites_list').should('exist');
|
||||||
|
// })
|
||||||
});
|
});
|
@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul class="stop-group__stops list-underlined">
|
<ul class="stop-group__stops list-underlined">
|
||||||
<li v-for="stop in group" :key="stop.id" class="d-flex">
|
<li v-for="stop in group" :key="stop.id" class="d-flex">
|
||||||
<button @click="select(stop, $event)" class="btn btn-action">
|
<button @click="select(stop, $event)" class="btn btn-action" data-action="add">
|
||||||
<fa :icon="['fal', 'check']" />
|
<fa :icon="['fal', 'check']" />
|
||||||
</button>
|
</button>
|
||||||
<stop :stop="stop" class="flex-grow-1"></stop>
|
<stop :stop="stop" class="flex-grow-1"></stop>
|
||||||
|
@ -20,7 +20,7 @@ class GenericStopRepository extends DatabaseRepository implements StopRepository
|
|||||||
|
|
||||||
public function getAllGroups(): Collection
|
public function getAllGroups(): Collection
|
||||||
{
|
{
|
||||||
return $this->group($this->getAll());
|
return self::group($this->getAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getById($id): ?Stop
|
public function getById($id): ?Stop
|
||||||
@ -49,10 +49,10 @@ class GenericStopRepository extends DatabaseRepository implements StopRepository
|
|||||||
|
|
||||||
$stops = collect($query->execute([':name' => "%$name%"]))->map(f\ref([$this, 'convert']));
|
$stops = collect($query->execute([':name' => "%$name%"]))->map(f\ref([$this, 'convert']));
|
||||||
|
|
||||||
return $this->group($stops);
|
return self::group($stops);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function group(Collection $stops)
|
public static function group(Collection $stops)
|
||||||
{
|
{
|
||||||
return $stops->groupBy(function (Stop $stop) {
|
return $stops->groupBy(function (Stop $stop) {
|
||||||
return $stop->getName();
|
return $stop->getName();
|
||||||
|
@ -3,14 +3,17 @@
|
|||||||
namespace App\Provider\Dummy;
|
namespace App\Provider\Dummy;
|
||||||
|
|
||||||
use App\Model\Stop;
|
use App\Model\Stop;
|
||||||
|
use App\Provider\Database\GenericStopRepository;
|
||||||
use App\Provider\StopRepository;
|
use App\Provider\StopRepository;
|
||||||
use App\Service\Proxy\ReferenceFactory;
|
use App\Service\Proxy\ReferenceFactory;
|
||||||
use Tightenco\Collect\Support\Collection;
|
use Tightenco\Collect\Support\Collection;
|
||||||
use Kadet\Functional as f;
|
use Kadet\Functional as f;
|
||||||
|
use Kadet\Functional\Predicates as p;
|
||||||
|
|
||||||
class DummyStopRepository implements StopRepository
|
class DummyStopRepository implements StopRepository
|
||||||
{
|
{
|
||||||
private $reference;
|
private $reference;
|
||||||
|
private $all;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DummyDepartureProviderRepository constructor.
|
* DummyDepartureProviderRepository constructor.
|
||||||
@ -20,30 +23,42 @@ class DummyStopRepository implements StopRepository
|
|||||||
public function __construct(ReferenceFactory $reference)
|
public function __construct(ReferenceFactory $reference)
|
||||||
{
|
{
|
||||||
$this->reference = $reference;
|
$this->reference = $reference;
|
||||||
|
|
||||||
|
$this->all = collect([
|
||||||
|
Stop::createFromArray(['id' => 1, 'name' => 'Lipowa', 'variant' => '01', 'onDemand' => true, 'latitude' => 0, 'longitude' => 0 ]),
|
||||||
|
Stop::createFromArray(['id' => 2, 'name' => 'Bukowa', 'variant' => '01', 'onDemand' => false ]),
|
||||||
|
Stop::createFromArray(['id' => 3, 'name' => 'Kasztanowa', 'variant' => '01', 'onDemand' => false ]),
|
||||||
|
Stop::createFromArray(['id' => 4, 'name' => 'Brzozowa', 'variant' => '01', 'onDemand' => false ]),
|
||||||
|
Stop::createFromArray(['id' => 5, 'name' => 'Brzozowa', 'variant' => '02', 'onDemand' => false ]),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAll(): Collection
|
public function getAll(): Collection
|
||||||
{
|
{
|
||||||
return collect();
|
return collect($this->all);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllGroups(): Collection
|
public function getAllGroups(): Collection
|
||||||
{
|
{
|
||||||
return collect();
|
return GenericStopRepository::group($this->getAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getById($id): ?Stop
|
public function getById($id): ?Stop
|
||||||
{
|
{
|
||||||
return Stop::createFromArray(['id' => $id, 'name' => 'lorem']);
|
return $this->all->first(p\property('id', p\equals($id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getManyById($ids): Collection
|
public function getManyById($ids): Collection
|
||||||
{
|
{
|
||||||
return collect($ids)->map(f\ref([ $this, 'getById' ]));
|
return $this->all->filter(p\property('id', function ($id) use ($ids) {
|
||||||
|
return in_array($id, $ids);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findGroupsByName(string $name): Collection
|
public function findGroupsByName(string $name): Collection
|
||||||
{
|
{
|
||||||
return collect();
|
return GenericStopRepository::group($this->all->filter(p\property('name', function ($stopName) use ($name) {
|
||||||
|
return stripos($stopName, $name) !== false;
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,7 +40,7 @@
|
|||||||
</fold>
|
</fold>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section">
|
<section class="section" id="departures">
|
||||||
<header class="section__title flex">
|
<header class="section__title flex">
|
||||||
<h2>
|
<h2>
|
||||||
<fa :icon="['fal', 'clock']" fixed-width></fa>
|
<fa :icon="['fal', 'clock']" fixed-width></fa>
|
||||||
@ -100,7 +100,7 @@
|
|||||||
</popper>
|
</popper>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<ul class="picker__stops list-underlined">
|
<ul class="picker__stops list-underlined" id="stops">
|
||||||
<li v-for="stop in stops" :key="stop.id" class="d-flex align-items-center">
|
<li v-for="stop in stops" :key="stop.id" class="d-flex align-items-center">
|
||||||
<button @click="remove(stop)" class="btn btn-action">
|
<button @click="remove(stop)" class="btn btn-action">
|
||||||
<fa :icon="['fal', 'times']"></fa>
|
<fa :icon="['fal', 'times']"></fa>
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"downlevelIteration": true
|
"downlevelIteration": true
|
||||||
},
|
},
|
||||||
"files": ["resources/ts/app.ts"]
|
"files": ["resources/ts/app.ts"],
|
||||||
|
"include": ["resources/ts/**/*.ts"]
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user