test element pdf path
This commit is contained in:
parent
2c79ab64ad
commit
6c6b3ad257
6 changed files with 72 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ class ElementsEndpointTest extends TestCase
|
|||
title: 'Baderech HaAvodah',
|
||||
description: 'A structured path for growth',
|
||||
richText: '<p>A structured path for growth</p>',
|
||||
pdfPath: '/assets/pdfs/baderech.pdf',
|
||||
parentElement: null,
|
||||
));
|
||||
$firstChildElement = $elementRepository->create(new CreateElementDto(
|
||||
|
|
@ -34,6 +35,7 @@ class ElementsEndpointTest extends TestCase
|
|||
title: 'Avodah Foundations',
|
||||
description: 'Foundations for steady avodah',
|
||||
richText: '<p>Foundations rich text</p>',
|
||||
pdfPath: '/assets/pdfs/foundations.pdf',
|
||||
parentElement: $element,
|
||||
));
|
||||
$secondChildElement = $elementRepository->create(new CreateElementDto(
|
||||
|
|
@ -41,6 +43,7 @@ class ElementsEndpointTest extends TestCase
|
|||
title: 'Daily Practice',
|
||||
description: 'Daily practices for growth',
|
||||
richText: '<p>Daily practice rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElement: $element,
|
||||
));
|
||||
|
||||
|
|
@ -65,6 +68,7 @@ class ElementsEndpointTest extends TestCase
|
|||
'title' => 'Baderech HaAvodah',
|
||||
'description' => 'A structured path for growth',
|
||||
'richText' => '<p>A structured path for growth</p>',
|
||||
'pdfPath' => '/assets/pdfs/baderech.pdf',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class ElementControllerTest extends TestCase
|
|||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
'<p>A structured path for growth</p>',
|
||||
'/assets/pdfs/baderech.pdf',
|
||||
null,
|
||||
);
|
||||
$firstChildElement = $this->createElement(
|
||||
|
|
@ -38,6 +39,7 @@ class ElementControllerTest extends TestCase
|
|||
'Avodah Foundations',
|
||||
'Foundations for steady avodah',
|
||||
'<p>Foundations rich text</p>',
|
||||
'/assets/pdfs/foundations.pdf',
|
||||
$element,
|
||||
);
|
||||
$secondChildElement = $this->createElement(
|
||||
|
|
@ -45,6 +47,7 @@ class ElementControllerTest extends TestCase
|
|||
'Daily Practice',
|
||||
'Daily practices for growth',
|
||||
'<p>Daily practice rich text</p>',
|
||||
null,
|
||||
$element,
|
||||
);
|
||||
|
||||
|
|
@ -62,6 +65,10 @@ class ElementControllerTest extends TestCase
|
|||
'<p>A structured path for growth</p>',
|
||||
$body['element']['richText'],
|
||||
);
|
||||
$this->assertSame(
|
||||
'/assets/pdfs/baderech.pdf',
|
||||
$body['element']['pdfPath'],
|
||||
);
|
||||
$this->assertSame([
|
||||
[
|
||||
'id' => $firstChildElement->getId(),
|
||||
|
|
@ -113,6 +120,7 @@ class ElementControllerTest extends TestCase
|
|||
string $title,
|
||||
string $description,
|
||||
string $richText,
|
||||
?string $pdfPath,
|
||||
?Element $parentElement,
|
||||
): Element {
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
|
|
@ -120,6 +128,7 @@ class ElementControllerTest extends TestCase
|
|||
title: $title,
|
||||
description: $description,
|
||||
richText: $richText,
|
||||
pdfPath: $pdfPath,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class ElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: null,
|
||||
set: $set,
|
||||
parentElement: null,
|
||||
);
|
||||
|
|
@ -29,6 +30,7 @@ class ElementTest extends TestCase
|
|||
title: 'Child',
|
||||
description: 'Child description',
|
||||
richText: '<p>Child rich text</p>',
|
||||
pdfPath: '/assets/pdfs/child.pdf',
|
||||
set: $set,
|
||||
parentElement: $rootElement,
|
||||
);
|
||||
|
|
@ -43,8 +45,13 @@ class ElementTest extends TestCase
|
|||
'<p>Child rich text</p>',
|
||||
$childElement->getRichText(),
|
||||
);
|
||||
$this->assertSame(
|
||||
'/assets/pdfs/child.pdf',
|
||||
$childElement->getPdfPath(),
|
||||
);
|
||||
$this->assertSame($set, $childElement->getSet());
|
||||
$this->assertSame($rootElement, $childElement->getParentElement());
|
||||
$this->assertNull($rootElement->getPdfPath());
|
||||
$this->assertNull($rootElement->getParentElement());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: '/assets/pdfs/root.pdf',
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ class CreateElementTest extends TestCase
|
|||
$this->assertSame('Root', $element->getTitle());
|
||||
$this->assertSame('Root description', $element->getDescription());
|
||||
$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->assertNull($element->getParentElement());
|
||||
}
|
||||
|
|
@ -69,6 +71,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
)
|
||||
);
|
||||
|
|
@ -79,6 +82,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Child',
|
||||
description: 'Child description',
|
||||
richText: '<p>Child rich text</p>',
|
||||
pdfPath: '/assets/pdfs/child.pdf',
|
||||
parentElementId: $rootElement->getId(),
|
||||
)
|
||||
);
|
||||
|
|
@ -92,6 +96,10 @@ class CreateElementTest extends TestCase
|
|||
'<p>Child rich text</p>',
|
||||
$childElement->getRichText(),
|
||||
);
|
||||
$this->assertSame(
|
||||
'/assets/pdfs/child.pdf',
|
||||
$childElement->getPdfPath(),
|
||||
);
|
||||
$this->assertSame(
|
||||
$rootElement->getId(),
|
||||
$childElement->getParentElement()->getId(),
|
||||
|
|
@ -107,11 +115,29 @@ class CreateElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: null,
|
||||
richText: null,
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
$this->assertSame('', $element->getDescription());
|
||||
$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
|
||||
|
|
@ -124,6 +150,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -138,6 +165,7 @@ class CreateElementTest extends TestCase
|
|||
title: null,
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -152,6 +180,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -170,6 +199,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Child',
|
||||
description: 'Child description',
|
||||
richText: '<p>Child rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: 99,
|
||||
));
|
||||
}
|
||||
|
|
@ -182,6 +212,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Root',
|
||||
description: 'Root description',
|
||||
richText: '<p>Root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
|
|
@ -195,6 +226,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Another root',
|
||||
description: 'Another root description',
|
||||
richText: '<p>Another root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -209,6 +241,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Parent root',
|
||||
description: 'Parent root description',
|
||||
richText: '<p>Parent root rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: null,
|
||||
)
|
||||
);
|
||||
|
|
@ -223,6 +256,7 @@ class CreateElementTest extends TestCase
|
|||
title: 'Invalid child',
|
||||
description: 'Invalid child description',
|
||||
richText: '<p>Invalid child rich text</p>',
|
||||
pdfPath: null,
|
||||
parentElementId: $parentElement->getId(),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class GetElementTest extends TestCase
|
|||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
'<p>A structured path for growth</p>',
|
||||
'/assets/pdfs/baderech.pdf',
|
||||
null,
|
||||
);
|
||||
|
||||
|
|
@ -51,6 +52,10 @@ class GetElementTest extends TestCase
|
|||
'<p>A structured path for growth</p>',
|
||||
$foundElement->getRichText(),
|
||||
);
|
||||
$this->assertSame(
|
||||
'/assets/pdfs/baderech.pdf',
|
||||
$foundElement->getPdfPath(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnsDirectChildElements(): void
|
||||
|
|
@ -61,6 +66,7 @@ class GetElementTest extends TestCase
|
|||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
'<p>A structured path for growth</p>',
|
||||
'/assets/pdfs/baderech.pdf',
|
||||
null,
|
||||
);
|
||||
$firstChildElement = $this->createElement(
|
||||
|
|
@ -68,6 +74,7 @@ class GetElementTest extends TestCase
|
|||
'Avodah Foundations',
|
||||
'Foundations for steady avodah',
|
||||
'<p>Foundations rich text</p>',
|
||||
'/assets/pdfs/foundations.pdf',
|
||||
$parentElement,
|
||||
);
|
||||
$secondChildElement = $this->createElement(
|
||||
|
|
@ -75,6 +82,7 @@ class GetElementTest extends TestCase
|
|||
'Daily Practice',
|
||||
'Daily practices for growth',
|
||||
'<p>Daily practice rich text</p>',
|
||||
null,
|
||||
$parentElement,
|
||||
);
|
||||
$this->createElement(
|
||||
|
|
@ -82,6 +90,7 @@ class GetElementTest extends TestCase
|
|||
'Nested Practice',
|
||||
'Nested description',
|
||||
'<p>Nested rich text</p>',
|
||||
null,
|
||||
$firstChildElement,
|
||||
);
|
||||
$otherSet = $this->createSet(2, 'Daily Learning');
|
||||
|
|
@ -91,12 +100,14 @@ class GetElementTest extends TestCase
|
|||
'Other parent description',
|
||||
'<p>Other parent rich text</p>',
|
||||
null,
|
||||
null,
|
||||
);
|
||||
$this->createElement(
|
||||
$otherSet,
|
||||
'Other Child',
|
||||
'Other child description',
|
||||
'<p>Other child rich text</p>',
|
||||
null,
|
||||
$otherParentElement,
|
||||
);
|
||||
|
||||
|
|
@ -157,6 +168,7 @@ class GetElementTest extends TestCase
|
|||
string $title,
|
||||
string $description,
|
||||
string $richText,
|
||||
?string $pdfPath,
|
||||
?Element $parentElement,
|
||||
): Element {
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
|
|
@ -164,6 +176,7 @@ class GetElementTest extends TestCase
|
|||
title: $title,
|
||||
description: $description,
|
||||
richText: $richText,
|
||||
pdfPath: $pdfPath,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ describe('media page sets', () => {
|
|||
.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(
|
||||
|
|
@ -78,5 +82,6 @@ describe('media page sets', () => {
|
|||
'contain.text',
|
||||
'Avodah foundations begin with honest awareness',
|
||||
)
|
||||
cy.get('[data-cy="element-pdf-link"]').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue