Skip to content

Commit b040b6c

Browse files
committed
Add missing page filtering/ordering tests (closes #113)
- Add thereIsAPageWithOptions() Behat step supporting reference, createdAt, title, uiComponent, and isTemplate - Add 7 Behat scenarios in page.feature: order by reference desc, order by createdAt asc/desc, search by reference/title/uiComponent, filter by isTemplate - Mirrors the filtering coverage already present in layout.feature All remaining checklist items in #113 were already covered: - /me username lookup: features/main/security.feature:190 - Page data normalisation (path header, admin bypass, unknown path): features/main/dynamic_page.feature - OpenAPI factory: features/main/openapi_compatibility.feature + tests/OpenApi/OpenApiFactoryTest.php
1 parent 4783174 commit b040b6c

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

features/bootstrap/DoctrineContext.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,27 @@ public function thereIsAPage(string $reference = 'page'): Page
568568
return $page;
569569
}
570570

571+
/**
572+
* @Given /^there is a(?: (template))? Page with the reference "([^"]+)"(?: and with createdAt "([^"]+)")?(?: and with the title "([^"]+)")?(?: and with the uiComponent "([^"]+)")?$/
573+
*/
574+
public function thereIsAPageWithOptions(?string $isTemplate, string $reference, ?string $createdAt = null, ?string $title = null, ?string $uiComponent = null): Page
575+
{
576+
$page = new Page();
577+
$page->isTemplate = 'template' === $isTemplate;
578+
$page->reference = $reference;
579+
$page->setTitle($title);
580+
$page->uiComponent = $uiComponent;
581+
if (null !== $createdAt) {
582+
$page->setCreatedAt(new \DateTimeImmutable($createdAt));
583+
}
584+
$this->timestampedHelper->persistTimestampedFields($page, null === $createdAt);
585+
$this->manager->persist($page);
586+
$this->manager->flush();
587+
$this->restContext->resources[$reference] = $this->iriConverter->getIriFromResource($page);
588+
589+
return $page;
590+
}
591+
571592
/**
572593
* @Given there is a child Page with a Layout
573594
*/

features/main/page.feature

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,72 @@ Feature: Page resources
155155
Then the response status code should be 200
156156
And the JSON node "member[0].parentPage" should be equal to the IRI of the resource "page"
157157

158+
@loginAdmin
159+
Scenario: The page resources can be ordered descending by reference
160+
Given there is a Page with the reference "1"
161+
And there is a Page with the reference "2"
162+
When I send a "GET" request to "/_/pages?order[reference]=desc"
163+
Then the response status code should be 200
164+
And the JSON node "member" should have "2" elements
165+
And the JSON node "member[0].reference" should be equal to "2"
166+
And the JSON node "member[1].reference" should be equal to "1"
167+
168+
@loginAdmin
169+
Scenario: The page resources can be ordered ascending by createdAt
170+
Given there is a Page with the reference "page_1" and with createdAt "now"
171+
And there is a Page with the reference "page_2" and with createdAt "+10 seconds"
172+
When I send a "GET" request to "/_/pages?order[createdAt]=asc"
173+
Then the response status code should be 200
174+
And the JSON node "member" should have "2" elements
175+
And the JSON node "member[0].reference" should be equal to "page_1"
176+
And the JSON node "member[1].reference" should be equal to "page_2"
177+
178+
@loginAdmin
179+
Scenario: The page resources can be ordered descending by createdAt
180+
Given there is a Page with the reference "page_1" and with createdAt "now"
181+
And there is a Page with the reference "page_2" and with createdAt "+10 seconds"
182+
When I send a "GET" request to "/_/pages?order[createdAt]=desc"
183+
Then the response status code should be 200
184+
And the JSON node "member" should have "2" elements
185+
And the JSON node "member[0].reference" should be equal to "page_2"
186+
And the JSON node "member[1].reference" should be equal to "page_1"
187+
188+
@loginAdmin
189+
Scenario: The page resources can be searched by reference
190+
Given there is a Page with the reference "primary"
191+
And there is a Page with the reference "secondary"
192+
When I send a "GET" request to "/_/pages?reference=primary"
193+
Then the response status code should be 200
194+
And the JSON node "member" should have "1" element
195+
And the JSON node "member[0].reference" should be equal to "primary"
196+
197+
@loginAdmin
198+
Scenario: The page resources can be searched by title
199+
Given there is a Page with the reference "conf" and with the title "My Conference"
200+
And there is a Page with the reference "contact" and with the title "Contact Us"
201+
When I send a "GET" request to "/_/pages?title=Conference"
202+
Then the response status code should be 200
203+
And the JSON node "member" should have "1" element
204+
And the JSON node "member[0].reference" should be equal to "conf"
205+
206+
@loginAdmin
207+
Scenario: The page resources can be searched by uiComponent
208+
Given there is a Page with the reference "primary" and with the uiComponent "PrimaryPage"
209+
And there is a Page with the reference "secondary" and with the uiComponent "SecondaryPage"
210+
When I send a "GET" request to "/_/pages?uiComponent=PrimaryPage"
211+
Then the response status code should be 200
212+
And the JSON node "member" should have "1" element
213+
And the JSON node "member[0].reference" should be equal to "primary"
214+
215+
@loginAdmin
216+
Scenario: The page resources can be filtered to show only templates
217+
Given there is a template Page with the reference "my-template"
218+
And there is a Page with the reference "not-a-template"
219+
When I send a "GET" request to "/_/pages?isTemplate=1"
220+
Then the response status code should be 200
221+
And the JSON node "member" should have "1" element
222+
And the JSON node "member[0].reference" should be equal to "my-template"
223+
158224
@loginAdmin
159225
Scenario: I can get a resource manifest for a nested Page by UUID
160226
Given there is a Page resource with the route path "/conference/programme" nested within the route "/conference"

0 commit comments

Comments
 (0)