test element pdf path

This commit is contained in:
Yisroel Baum 2026-05-27 20:15:51 +03:00
parent 2c79ab64ad
commit 6c6b3ad257
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
6 changed files with 72 additions and 0 deletions

View file

@ -27,6 +27,7 @@ class ElementsEndpointTest extends TestCase
title: 'Baderech HaAvodah', title: 'Baderech HaAvodah',
description: 'A structured path for growth', description: 'A structured path for growth',
richText: '<p>A structured path for growth</p>', richText: '<p>A structured path for growth</p>',
pdfPath: '/assets/pdfs/baderech.pdf',
parentElement: null, parentElement: null,
)); ));
$firstChildElement = $elementRepository->create(new CreateElementDto( $firstChildElement = $elementRepository->create(new CreateElementDto(
@ -34,6 +35,7 @@ class ElementsEndpointTest extends TestCase
title: 'Avodah Foundations', title: 'Avodah Foundations',
description: 'Foundations for steady avodah', description: 'Foundations for steady avodah',
richText: '<p>Foundations rich text</p>', richText: '<p>Foundations rich text</p>',
pdfPath: '/assets/pdfs/foundations.pdf',
parentElement: $element, parentElement: $element,
)); ));
$secondChildElement = $elementRepository->create(new CreateElementDto( $secondChildElement = $elementRepository->create(new CreateElementDto(
@ -41,6 +43,7 @@ class ElementsEndpointTest extends TestCase
title: 'Daily Practice', title: 'Daily Practice',
description: 'Daily practices for growth', description: 'Daily practices for growth',
richText: '<p>Daily practice rich text</p>', richText: '<p>Daily practice rich text</p>',
pdfPath: null,
parentElement: $element, parentElement: $element,
)); ));
@ -65,6 +68,7 @@ class ElementsEndpointTest extends TestCase
'title' => 'Baderech HaAvodah', 'title' => 'Baderech HaAvodah',
'description' => 'A structured path for growth', 'description' => 'A structured path for growth',
'richText' => '<p>A structured path for growth</p>', 'richText' => '<p>A structured path for growth</p>',
'pdfPath' => '/assets/pdfs/baderech.pdf',
], ],
]); ]);
} }

View file

@ -31,6 +31,7 @@ class ElementControllerTest extends TestCase
'Baderech HaAvodah', 'Baderech HaAvodah',
'A structured path for growth', 'A structured path for growth',
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
'/assets/pdfs/baderech.pdf',
null, null,
); );
$firstChildElement = $this->createElement( $firstChildElement = $this->createElement(
@ -38,6 +39,7 @@ class ElementControllerTest extends TestCase
'Avodah Foundations', 'Avodah Foundations',
'Foundations for steady avodah', 'Foundations for steady avodah',
'<p>Foundations rich text</p>', '<p>Foundations rich text</p>',
'/assets/pdfs/foundations.pdf',
$element, $element,
); );
$secondChildElement = $this->createElement( $secondChildElement = $this->createElement(
@ -45,6 +47,7 @@ class ElementControllerTest extends TestCase
'Daily Practice', 'Daily Practice',
'Daily practices for growth', 'Daily practices for growth',
'<p>Daily practice rich text</p>', '<p>Daily practice rich text</p>',
null,
$element, $element,
); );
@ -62,6 +65,10 @@ class ElementControllerTest extends TestCase
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
$body['element']['richText'], $body['element']['richText'],
); );
$this->assertSame(
'/assets/pdfs/baderech.pdf',
$body['element']['pdfPath'],
);
$this->assertSame([ $this->assertSame([
[ [
'id' => $firstChildElement->getId(), 'id' => $firstChildElement->getId(),
@ -113,6 +120,7 @@ class ElementControllerTest extends TestCase
string $title, string $title,
string $description, string $description,
string $richText, string $richText,
?string $pdfPath,
?Element $parentElement, ?Element $parentElement,
): Element { ): Element {
return $this->elementRepo->create(new CreateElementDto( return $this->elementRepo->create(new CreateElementDto(
@ -120,6 +128,7 @@ class ElementControllerTest extends TestCase
title: $title, title: $title,
description: $description, description: $description,
richText: $richText, richText: $richText,
pdfPath: $pdfPath,
parentElement: $parentElement, parentElement: $parentElement,
)); ));
} }

View file

@ -21,6 +21,7 @@ class ElementTest extends TestCase
title: 'Root', title: 'Root',
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null,
set: $set, set: $set,
parentElement: null, parentElement: null,
); );
@ -29,6 +30,7 @@ class ElementTest extends TestCase
title: 'Child', title: 'Child',
description: 'Child description', description: 'Child description',
richText: '<p>Child rich text</p>', richText: '<p>Child rich text</p>',
pdfPath: '/assets/pdfs/child.pdf',
set: $set, set: $set,
parentElement: $rootElement, parentElement: $rootElement,
); );
@ -43,8 +45,13 @@ class ElementTest extends TestCase
'<p>Child rich text</p>', '<p>Child rich text</p>',
$childElement->getRichText(), $childElement->getRichText(),
); );
$this->assertSame(
'/assets/pdfs/child.pdf',
$childElement->getPdfPath(),
);
$this->assertSame($set, $childElement->getSet()); $this->assertSame($set, $childElement->getSet());
$this->assertSame($rootElement, $childElement->getParentElement()); $this->assertSame($rootElement, $childElement->getParentElement());
$this->assertNull($rootElement->getPdfPath());
$this->assertNull($rootElement->getParentElement()); $this->assertNull($rootElement->getParentElement());
} }
} }

View file

@ -49,6 +49,7 @@ class CreateElementTest extends TestCase
title: 'Root', title: 'Root',
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: '/assets/pdfs/root.pdf',
parentElementId: null, parentElementId: null,
)); ));
@ -56,6 +57,7 @@ class CreateElementTest extends TestCase
$this->assertSame('Root', $element->getTitle()); $this->assertSame('Root', $element->getTitle());
$this->assertSame('Root description', $element->getDescription()); $this->assertSame('Root description', $element->getDescription());
$this->assertSame('<p>Root rich text</p>', $element->getRichText()); $this->assertSame('<p>Root rich text</p>', $element->getRichText());
$this->assertSame('/assets/pdfs/root.pdf', $element->getPdfPath());
$this->assertSame($set->getId(), $element->getSet()->getId()); $this->assertSame($set->getId(), $element->getSet()->getId());
$this->assertNull($element->getParentElement()); $this->assertNull($element->getParentElement());
} }
@ -69,6 +71,7 @@ class CreateElementTest extends TestCase
title: 'Root', title: 'Root',
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
) )
); );
@ -79,6 +82,7 @@ class CreateElementTest extends TestCase
title: 'Child', title: 'Child',
description: 'Child description', description: 'Child description',
richText: '<p>Child rich text</p>', richText: '<p>Child rich text</p>',
pdfPath: '/assets/pdfs/child.pdf',
parentElementId: $rootElement->getId(), parentElementId: $rootElement->getId(),
) )
); );
@ -92,6 +96,10 @@ class CreateElementTest extends TestCase
'<p>Child rich text</p>', '<p>Child rich text</p>',
$childElement->getRichText(), $childElement->getRichText(),
); );
$this->assertSame(
'/assets/pdfs/child.pdf',
$childElement->getPdfPath(),
);
$this->assertSame( $this->assertSame(
$rootElement->getId(), $rootElement->getId(),
$childElement->getParentElement()->getId(), $childElement->getParentElement()->getId(),
@ -107,11 +115,29 @@ class CreateElementTest extends TestCase
title: 'Root', title: 'Root',
description: null, description: null,
richText: null, richText: null,
pdfPath: null,
parentElementId: null, parentElementId: null,
)); ));
$this->assertSame('', $element->getDescription()); $this->assertSame('', $element->getDescription());
$this->assertSame('', $element->getRichText()); $this->assertSame('', $element->getRichText());
$this->assertNull($element->getPdfPath());
}
public function testCreatesElementWithNullPdfPathWhenBlank(): void
{
$set = $this->createSet('Daily learning');
$element = $this->createElement->execute(new CreateElementRequest(
setId: $set->getId(),
title: 'Root',
description: 'Root description',
richText: '<p>Root rich text</p>',
pdfPath: '',
parentElementId: null,
));
$this->assertNull($element->getPdfPath());
} }
public function testThrowsWhenSetIdMissing(): void public function testThrowsWhenSetIdMissing(): void
@ -124,6 +150,7 @@ class CreateElementTest extends TestCase
title: 'Root', title: 'Root',
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -138,6 +165,7 @@ class CreateElementTest extends TestCase
title: null, title: null,
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -152,6 +180,7 @@ class CreateElementTest extends TestCase
title: 'Root', title: 'Root',
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -170,6 +199,7 @@ class CreateElementTest extends TestCase
title: 'Child', title: 'Child',
description: 'Child description', description: 'Child description',
richText: '<p>Child rich text</p>', richText: '<p>Child rich text</p>',
pdfPath: null,
parentElementId: 99, parentElementId: 99,
)); ));
} }
@ -182,6 +212,7 @@ class CreateElementTest extends TestCase
title: 'Root', title: 'Root',
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
)); ));
@ -195,6 +226,7 @@ class CreateElementTest extends TestCase
title: 'Another root', title: 'Another root',
description: 'Another root description', description: 'Another root description',
richText: '<p>Another root rich text</p>', richText: '<p>Another root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -209,6 +241,7 @@ class CreateElementTest extends TestCase
title: 'Parent root', title: 'Parent root',
description: 'Parent root description', description: 'Parent root description',
richText: '<p>Parent root rich text</p>', richText: '<p>Parent root rich text</p>',
pdfPath: null,
parentElementId: null, parentElementId: null,
) )
); );
@ -223,6 +256,7 @@ class CreateElementTest extends TestCase
title: 'Invalid child', title: 'Invalid child',
description: 'Invalid child description', description: 'Invalid child description',
richText: '<p>Invalid child rich text</p>', richText: '<p>Invalid child rich text</p>',
pdfPath: null,
parentElementId: $parentElement->getId(), parentElementId: $parentElement->getId(),
)); ));
} }

View file

@ -32,6 +32,7 @@ class GetElementTest extends TestCase
'Baderech HaAvodah', 'Baderech HaAvodah',
'A structured path for growth', 'A structured path for growth',
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
'/assets/pdfs/baderech.pdf',
null, null,
); );
@ -51,6 +52,10 @@ class GetElementTest extends TestCase
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
$foundElement->getRichText(), $foundElement->getRichText(),
); );
$this->assertSame(
'/assets/pdfs/baderech.pdf',
$foundElement->getPdfPath(),
);
} }
public function testReturnsDirectChildElements(): void public function testReturnsDirectChildElements(): void
@ -61,6 +66,7 @@ class GetElementTest extends TestCase
'Baderech HaAvodah', 'Baderech HaAvodah',
'A structured path for growth', 'A structured path for growth',
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
'/assets/pdfs/baderech.pdf',
null, null,
); );
$firstChildElement = $this->createElement( $firstChildElement = $this->createElement(
@ -68,6 +74,7 @@ class GetElementTest extends TestCase
'Avodah Foundations', 'Avodah Foundations',
'Foundations for steady avodah', 'Foundations for steady avodah',
'<p>Foundations rich text</p>', '<p>Foundations rich text</p>',
'/assets/pdfs/foundations.pdf',
$parentElement, $parentElement,
); );
$secondChildElement = $this->createElement( $secondChildElement = $this->createElement(
@ -75,6 +82,7 @@ class GetElementTest extends TestCase
'Daily Practice', 'Daily Practice',
'Daily practices for growth', 'Daily practices for growth',
'<p>Daily practice rich text</p>', '<p>Daily practice rich text</p>',
null,
$parentElement, $parentElement,
); );
$this->createElement( $this->createElement(
@ -82,6 +90,7 @@ class GetElementTest extends TestCase
'Nested Practice', 'Nested Practice',
'Nested description', 'Nested description',
'<p>Nested rich text</p>', '<p>Nested rich text</p>',
null,
$firstChildElement, $firstChildElement,
); );
$otherSet = $this->createSet(2, 'Daily Learning'); $otherSet = $this->createSet(2, 'Daily Learning');
@ -91,12 +100,14 @@ class GetElementTest extends TestCase
'Other parent description', 'Other parent description',
'<p>Other parent rich text</p>', '<p>Other parent rich text</p>',
null, null,
null,
); );
$this->createElement( $this->createElement(
$otherSet, $otherSet,
'Other Child', 'Other Child',
'Other child description', 'Other child description',
'<p>Other child rich text</p>', '<p>Other child rich text</p>',
null,
$otherParentElement, $otherParentElement,
); );
@ -157,6 +168,7 @@ class GetElementTest extends TestCase
string $title, string $title,
string $description, string $description,
string $richText, string $richText,
?string $pdfPath,
?Element $parentElement, ?Element $parentElement,
): Element { ): Element {
return $this->elementRepo->create(new CreateElementDto( return $this->elementRepo->create(new CreateElementDto(
@ -164,6 +176,7 @@ class GetElementTest extends TestCase
title: $title, title: $title,
description: $description, description: $description,
richText: $richText, richText: $richText,
pdfPath: $pdfPath,
parentElement: $parentElement, parentElement: $parentElement,
)); ));
} }

View file

@ -46,6 +46,10 @@ describe('media page sets', () => {
.should('be.visible') .should('be.visible')
cy.contains('strong', 'Move steadily').should('be.visible') cy.contains('strong', 'Move steadily').should('be.visible')
}) })
cy.contains('[data-cy="element-pdf-link"]', 'View PDF')
.should('be.visible')
.and('have.attr', 'href', '/assets/pdfs/baderech.pdf')
.and('have.attr', 'target', '_blank')
cy.get('[data-cy="child-element-list"]').should('be.visible') cy.get('[data-cy="child-element-list"]').should('be.visible')
cy.get('[data-cy="child-element-list"]') cy.get('[data-cy="child-element-list"]')
.should( .should(
@ -78,5 +82,6 @@ describe('media page sets', () => {
'contain.text', 'contain.text',
'Avodah foundations begin with honest awareness', 'Avodah foundations begin with honest awareness',
) )
cy.get('[data-cy="element-pdf-link"]').should('not.exist')
}) })
}) })