Compare commits
No commits in common. "2c79ab64ade080892e26fed111aa7e96ebe76b15" and "ef54aa97aab07156b9b76b3ad167414822ac86a8" have entirely different histories.
2c79ab64ad
...
ef54aa97aa
19 changed files with 4 additions and 130 deletions
|
|
@ -46,7 +46,6 @@ class ElementController
|
||||||
'id' => $element->getId(),
|
'id' => $element->getId(),
|
||||||
'title' => $element->getTitle(),
|
'title' => $element->getTitle(),
|
||||||
'description' => $element->getDescription(),
|
'description' => $element->getDescription(),
|
||||||
'richText' => $element->getRichText(),
|
|
||||||
],
|
],
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ class CreateElementDto
|
||||||
public Set $set,
|
public Set $set,
|
||||||
public string $title,
|
public string $title,
|
||||||
public string $description,
|
public string $description,
|
||||||
public string $richText,
|
|
||||||
public ?Element $parentElement,
|
public ?Element $parentElement,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ class Element
|
||||||
private int $id,
|
private int $id,
|
||||||
private string $title,
|
private string $title,
|
||||||
private string $description,
|
private string $description,
|
||||||
private string $richText,
|
|
||||||
private Set $set,
|
private Set $set,
|
||||||
private ?Element $parentElement,
|
private ?Element $parentElement,
|
||||||
) {
|
) {
|
||||||
|
|
@ -31,11 +30,6 @@ class Element
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRichText(): string
|
|
||||||
{
|
|
||||||
return $this->richText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSet(): Set
|
public function getSet(): Set
|
||||||
{
|
{
|
||||||
return $this->set;
|
return $this->set;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property int $set_id
|
* @property int $set_id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $description
|
* @property string $description
|
||||||
* @property string $rich_text
|
|
||||||
* @property int|null $parent_element_id
|
* @property int|null $parent_element_id
|
||||||
*
|
*
|
||||||
* @method static Builder<static>|ElementModel newModelQuery()
|
* @method static Builder<static>|ElementModel newModelQuery()
|
||||||
|
|
@ -21,7 +20,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @method static Builder<static>|ElementModel whereSetId($value)
|
* @method static Builder<static>|ElementModel whereSetId($value)
|
||||||
* @method static Builder<static>|ElementModel whereTitle($value)
|
* @method static Builder<static>|ElementModel whereTitle($value)
|
||||||
* @method static Builder<static>|ElementModel whereDescription($value)
|
* @method static Builder<static>|ElementModel whereDescription($value)
|
||||||
* @method static Builder<static>|ElementModel whereRichText($value)
|
|
||||||
*
|
*
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
|
|
@ -35,7 +33,6 @@ class ElementModel extends Model
|
||||||
'set_id',
|
'set_id',
|
||||||
'title',
|
'title',
|
||||||
'description',
|
'description',
|
||||||
'rich_text',
|
|
||||||
'parent_element_id',
|
'parent_element_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ class EloquentElementRepository implements ElementRepository
|
||||||
'set_id' => $dto->set->getId(),
|
'set_id' => $dto->set->getId(),
|
||||||
'title' => $dto->title,
|
'title' => $dto->title,
|
||||||
'description' => $dto->description,
|
'description' => $dto->description,
|
||||||
'rich_text' => $dto->richText,
|
|
||||||
'parent_element_id' => $dto->parentElement?->getId(),
|
'parent_element_id' => $dto->parentElement?->getId(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -26,7 +25,6 @@ class EloquentElementRepository implements ElementRepository
|
||||||
id: $model->id,
|
id: $model->id,
|
||||||
title: $dto->title,
|
title: $dto->title,
|
||||||
description: $dto->description,
|
description: $dto->description,
|
||||||
richText: $dto->richText,
|
|
||||||
set: $dto->set,
|
set: $dto->set,
|
||||||
parentElement: $dto->parentElement,
|
parentElement: $dto->parentElement,
|
||||||
);
|
);
|
||||||
|
|
@ -107,7 +105,6 @@ class EloquentElementRepository implements ElementRepository
|
||||||
id: $model->id,
|
id: $model->id,
|
||||||
title: $model->title,
|
title: $model->title,
|
||||||
description: $model->description,
|
description: $model->description,
|
||||||
richText: $model->rich_text,
|
|
||||||
set: $set,
|
set: $set,
|
||||||
parentElement: $parentElement,
|
parentElement: $parentElement,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ class CreateElement
|
||||||
throw new BadRequestException('title is required');
|
throw new BadRequestException('title is required');
|
||||||
}
|
}
|
||||||
$description = $request->description ?? '';
|
$description = $request->description ?? '';
|
||||||
$richText = $request->richText ?? '';
|
|
||||||
|
|
||||||
$set = $this->setRepo->find($request->setId);
|
$set = $this->setRepo->find($request->setId);
|
||||||
if ($set === null) {
|
if ($set === null) {
|
||||||
|
|
@ -47,7 +46,6 @@ class CreateElement
|
||||||
set: $set,
|
set: $set,
|
||||||
title: $request->title,
|
title: $request->title,
|
||||||
description: $description,
|
description: $description,
|
||||||
richText: $richText,
|
|
||||||
parentElement: null,
|
parentElement: null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +68,6 @@ class CreateElement
|
||||||
set: $set,
|
set: $set,
|
||||||
title: $request->title,
|
title: $request->title,
|
||||||
description: $description,
|
description: $description,
|
||||||
richText: $richText,
|
|
||||||
parentElement: $parentElement,
|
parentElement: $parentElement,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ class CreateElementRequest
|
||||||
public ?int $setId,
|
public ?int $setId,
|
||||||
public ?string $title,
|
public ?string $title,
|
||||||
public ?string $description,
|
public ?string $description,
|
||||||
public ?string $richText,
|
|
||||||
public ?int $parentElementId,
|
public ?int $parentElementId,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ return new class extends Migration
|
||||||
$table->foreignId('set_id')->constrained('sets');
|
$table->foreignId('set_id')->constrained('sets');
|
||||||
$table->string('title');
|
$table->string('title');
|
||||||
$table->text('description')->default('');
|
$table->text('description')->default('');
|
||||||
$table->text('rich_text')->default('');
|
|
||||||
$table->foreignId('parent_element_id')
|
$table->foreignId('parent_element_id')
|
||||||
->nullable()
|
->nullable()
|
||||||
->constrained('elements');
|
->constrained('elements');
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,6 @@ class ElementSeeder extends Seeder
|
||||||
set: $baderechSet,
|
set: $baderechSet,
|
||||||
title: $baderechSet->getName(),
|
title: $baderechSet->getName(),
|
||||||
description: $baderechSet->getDescription(),
|
description: $baderechSet->getDescription(),
|
||||||
richText: '<p>Begin with a clear map for avodah growth.</p>'
|
|
||||||
. '<p><strong>Move steadily</strong> from awareness '
|
|
||||||
. 'to practice.</p>',
|
|
||||||
parentElement: null,
|
parentElement: null,
|
||||||
));
|
));
|
||||||
$elementRepository->create(new CreateElementDto(
|
$elementRepository->create(new CreateElementDto(
|
||||||
|
|
@ -28,16 +25,12 @@ class ElementSeeder extends Seeder
|
||||||
title: 'Avodah Foundations',
|
title: 'Avodah Foundations',
|
||||||
description: 'Core foundations for building a steady '
|
description: 'Core foundations for building a steady '
|
||||||
. 'avodah practice.',
|
. 'avodah practice.',
|
||||||
richText: '<p>Avodah foundations begin with honest awareness '
|
|
||||||
. 'and small repeatable steps.</p>',
|
|
||||||
parentElement: $rootElement,
|
parentElement: $rootElement,
|
||||||
));
|
));
|
||||||
$elementRepository->create(new CreateElementDto(
|
$elementRepository->create(new CreateElementDto(
|
||||||
set: $baderechSet,
|
set: $baderechSet,
|
||||||
title: 'Daily Practice',
|
title: 'Daily Practice',
|
||||||
description: 'Practical steps for consistent daily growth.',
|
description: 'Practical steps for consistent daily growth.',
|
||||||
richText: '<p>Daily practice turns inspiration into a '
|
|
||||||
. 'dependable rhythm.</p>',
|
|
||||||
parentElement: $rootElement,
|
parentElement: $rootElement,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ class FakeElementRepository implements ElementRepository
|
||||||
id: $id,
|
id: $id,
|
||||||
title: $dto->title,
|
title: $dto->title,
|
||||||
description: $dto->description,
|
description: $dto->description,
|
||||||
richText: $dto->richText,
|
|
||||||
set: $dto->set,
|
set: $dto->set,
|
||||||
parentElement: $dto->parentElement,
|
parentElement: $dto->parentElement,
|
||||||
);
|
);
|
||||||
|
|
@ -98,7 +97,6 @@ class FakeElementRepository implements ElementRepository
|
||||||
id: $element->getId(),
|
id: $element->getId(),
|
||||||
title: $element->getTitle(),
|
title: $element->getTitle(),
|
||||||
description: $element->getDescription(),
|
description: $element->getDescription(),
|
||||||
richText: $element->getRichText(),
|
|
||||||
set: $element->getSet(),
|
set: $element->getSet(),
|
||||||
parentElement: $parentElement,
|
parentElement: $parentElement,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -26,21 +26,18 @@ class ElementsEndpointTest extends TestCase
|
||||||
set: $set,
|
set: $set,
|
||||||
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>',
|
|
||||||
parentElement: null,
|
parentElement: null,
|
||||||
));
|
));
|
||||||
$firstChildElement = $elementRepository->create(new CreateElementDto(
|
$firstChildElement = $elementRepository->create(new CreateElementDto(
|
||||||
set: $set,
|
set: $set,
|
||||||
title: 'Avodah Foundations',
|
title: 'Avodah Foundations',
|
||||||
description: 'Foundations for steady avodah',
|
description: 'Foundations for steady avodah',
|
||||||
richText: '<p>Foundations rich text</p>',
|
|
||||||
parentElement: $element,
|
parentElement: $element,
|
||||||
));
|
));
|
||||||
$secondChildElement = $elementRepository->create(new CreateElementDto(
|
$secondChildElement = $elementRepository->create(new CreateElementDto(
|
||||||
set: $set,
|
set: $set,
|
||||||
title: 'Daily Practice',
|
title: 'Daily Practice',
|
||||||
description: 'Daily practices for growth',
|
description: 'Daily practices for growth',
|
||||||
richText: '<p>Daily practice rich text</p>',
|
|
||||||
parentElement: $element,
|
parentElement: $element,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -64,7 +61,6 @@ class ElementsEndpointTest extends TestCase
|
||||||
'id' => $element->getId(),
|
'id' => $element->getId(),
|
||||||
'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>',
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ class SetsEndpointTest extends TestCase
|
||||||
set: $baderechSet,
|
set: $baderechSet,
|
||||||
title: $baderechSet->getName(),
|
title: $baderechSet->getName(),
|
||||||
description: $baderechSet->getDescription(),
|
description: $baderechSet->getDescription(),
|
||||||
richText: '',
|
|
||||||
parentElement: null,
|
parentElement: null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -30,21 +30,18 @@ class ElementControllerTest extends TestCase
|
||||||
$set,
|
$set,
|
||||||
'Baderech HaAvodah',
|
'Baderech HaAvodah',
|
||||||
'A structured path for growth',
|
'A structured path for growth',
|
||||||
'<p>A structured path for growth</p>',
|
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
$firstChildElement = $this->createElement(
|
$firstChildElement = $this->createElement(
|
||||||
$set,
|
$set,
|
||||||
'Avodah Foundations',
|
'Avodah Foundations',
|
||||||
'Foundations for steady avodah',
|
'Foundations for steady avodah',
|
||||||
'<p>Foundations rich text</p>',
|
|
||||||
$element,
|
$element,
|
||||||
);
|
);
|
||||||
$secondChildElement = $this->createElement(
|
$secondChildElement = $this->createElement(
|
||||||
$set,
|
$set,
|
||||||
'Daily Practice',
|
'Daily Practice',
|
||||||
'Daily practices for growth',
|
'Daily practices for growth',
|
||||||
'<p>Daily practice rich text</p>',
|
|
||||||
$element,
|
$element,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -58,10 +55,6 @@ class ElementControllerTest extends TestCase
|
||||||
'A structured path for growth',
|
'A structured path for growth',
|
||||||
$body['element']['description'],
|
$body['element']['description'],
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
|
||||||
'<p>A structured path for growth</p>',
|
|
||||||
$body['element']['richText'],
|
|
||||||
);
|
|
||||||
$this->assertSame([
|
$this->assertSame([
|
||||||
[
|
[
|
||||||
'id' => $firstChildElement->getId(),
|
'id' => $firstChildElement->getId(),
|
||||||
|
|
@ -112,14 +105,12 @@ class ElementControllerTest extends TestCase
|
||||||
DomainSet $set,
|
DomainSet $set,
|
||||||
string $title,
|
string $title,
|
||||||
string $description,
|
string $description,
|
||||||
string $richText,
|
|
||||||
?Element $parentElement,
|
?Element $parentElement,
|
||||||
): Element {
|
): Element {
|
||||||
return $this->elementRepo->create(new CreateElementDto(
|
return $this->elementRepo->create(new CreateElementDto(
|
||||||
set: $set,
|
set: $set,
|
||||||
title: $title,
|
title: $title,
|
||||||
description: $description,
|
description: $description,
|
||||||
richText: $richText,
|
|
||||||
parentElement: $parentElement,
|
parentElement: $parentElement,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ class ElementTest extends TestCase
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
set: $set,
|
set: $set,
|
||||||
parentElement: null,
|
parentElement: null,
|
||||||
);
|
);
|
||||||
|
|
@ -28,7 +27,6 @@ class ElementTest extends TestCase
|
||||||
id: 2,
|
id: 2,
|
||||||
title: 'Child',
|
title: 'Child',
|
||||||
description: 'Child description',
|
description: 'Child description',
|
||||||
richText: '<p>Child rich text</p>',
|
|
||||||
set: $set,
|
set: $set,
|
||||||
parentElement: $rootElement,
|
parentElement: $rootElement,
|
||||||
);
|
);
|
||||||
|
|
@ -39,10 +37,6 @@ class ElementTest extends TestCase
|
||||||
'Child description',
|
'Child description',
|
||||||
$childElement->getDescription(),
|
$childElement->getDescription(),
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
|
||||||
'<p>Child rich text</p>',
|
|
||||||
$childElement->getRichText(),
|
|
||||||
);
|
|
||||||
$this->assertSame($set, $childElement->getSet());
|
$this->assertSame($set, $childElement->getSet());
|
||||||
$this->assertSame($rootElement, $childElement->getParentElement());
|
$this->assertSame($rootElement, $childElement->getParentElement());
|
||||||
$this->assertNull($rootElement->getParentElement());
|
$this->assertNull($rootElement->getParentElement());
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,12 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertInstanceOf(Element::class, $element);
|
$this->assertInstanceOf(Element::class, $element);
|
||||||
$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($set->getId(), $element->getSet()->getId());
|
$this->assertSame($set->getId(), $element->getSet()->getId());
|
||||||
$this->assertNull($element->getParentElement());
|
$this->assertNull($element->getParentElement());
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +66,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -78,7 +75,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Child',
|
title: 'Child',
|
||||||
description: 'Child description',
|
description: 'Child description',
|
||||||
richText: '<p>Child rich text</p>',
|
|
||||||
parentElementId: $rootElement->getId(),
|
parentElementId: $rootElement->getId(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -88,17 +84,13 @@ class CreateElementTest extends TestCase
|
||||||
'Child description',
|
'Child description',
|
||||||
$childElement->getDescription(),
|
$childElement->getDescription(),
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
|
||||||
'<p>Child rich text</p>',
|
|
||||||
$childElement->getRichText(),
|
|
||||||
);
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$rootElement->getId(),
|
$rootElement->getId(),
|
||||||
$childElement->getParentElement()->getId(),
|
$childElement->getParentElement()->getId(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreatesElementWithBlankContentWhenMissing(): void
|
public function testCreatesElementWithBlankDescriptionWhenMissing(): void
|
||||||
{
|
{
|
||||||
$set = $this->createSet('Daily learning');
|
$set = $this->createSet('Daily learning');
|
||||||
|
|
||||||
|
|
@ -106,12 +98,10 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: null,
|
description: null,
|
||||||
richText: null,
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertSame('', $element->getDescription());
|
$this->assertSame('', $element->getDescription());
|
||||||
$this->assertSame('', $element->getRichText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testThrowsWhenSetIdMissing(): void
|
public function testThrowsWhenSetIdMissing(): void
|
||||||
|
|
@ -123,7 +113,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: null,
|
setId: null,
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +126,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: 1,
|
setId: 1,
|
||||||
title: null,
|
title: null,
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +139,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: 99,
|
setId: 99,
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +156,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Child',
|
title: 'Child',
|
||||||
description: 'Child description',
|
description: 'Child description',
|
||||||
richText: '<p>Child rich text</p>',
|
|
||||||
parentElementId: 99,
|
parentElementId: 99,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -181,7 +167,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
description: 'Root description',
|
description: 'Root description',
|
||||||
richText: '<p>Root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -194,7 +179,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $set->getId(),
|
setId: $set->getId(),
|
||||||
title: 'Another root',
|
title: 'Another root',
|
||||||
description: 'Another root description',
|
description: 'Another root description',
|
||||||
richText: '<p>Another root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +192,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $parentSet->getId(),
|
setId: $parentSet->getId(),
|
||||||
title: 'Parent root',
|
title: 'Parent root',
|
||||||
description: 'Parent root description',
|
description: 'Parent root description',
|
||||||
richText: '<p>Parent root rich text</p>',
|
|
||||||
parentElementId: null,
|
parentElementId: null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -222,7 +205,6 @@ class CreateElementTest extends TestCase
|
||||||
setId: $childSet->getId(),
|
setId: $childSet->getId(),
|
||||||
title: 'Invalid child',
|
title: 'Invalid child',
|
||||||
description: 'Invalid child description',
|
description: 'Invalid child description',
|
||||||
richText: '<p>Invalid child rich text</p>',
|
|
||||||
parentElementId: $parentElement->getId(),
|
parentElementId: $parentElement->getId(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ class GetElementTest extends TestCase
|
||||||
$set,
|
$set,
|
||||||
'Baderech HaAvodah',
|
'Baderech HaAvodah',
|
||||||
'A structured path for growth',
|
'A structured path for growth',
|
||||||
'<p>A structured path for growth</p>',
|
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -47,10 +46,6 @@ class GetElementTest extends TestCase
|
||||||
'A structured path for growth',
|
'A structured path for growth',
|
||||||
$foundElement->getDescription(),
|
$foundElement->getDescription(),
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
|
||||||
'<p>A structured path for growth</p>',
|
|
||||||
$foundElement->getRichText(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReturnsDirectChildElements(): void
|
public function testReturnsDirectChildElements(): void
|
||||||
|
|
@ -60,28 +55,24 @@ class GetElementTest extends TestCase
|
||||||
$set,
|
$set,
|
||||||
'Baderech HaAvodah',
|
'Baderech HaAvodah',
|
||||||
'A structured path for growth',
|
'A structured path for growth',
|
||||||
'<p>A structured path for growth</p>',
|
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
$firstChildElement = $this->createElement(
|
$firstChildElement = $this->createElement(
|
||||||
$set,
|
$set,
|
||||||
'Avodah Foundations',
|
'Avodah Foundations',
|
||||||
'Foundations for steady avodah',
|
'Foundations for steady avodah',
|
||||||
'<p>Foundations rich text</p>',
|
|
||||||
$parentElement,
|
$parentElement,
|
||||||
);
|
);
|
||||||
$secondChildElement = $this->createElement(
|
$secondChildElement = $this->createElement(
|
||||||
$set,
|
$set,
|
||||||
'Daily Practice',
|
'Daily Practice',
|
||||||
'Daily practices for growth',
|
'Daily practices for growth',
|
||||||
'<p>Daily practice rich text</p>',
|
|
||||||
$parentElement,
|
$parentElement,
|
||||||
);
|
);
|
||||||
$this->createElement(
|
$this->createElement(
|
||||||
$set,
|
$set,
|
||||||
'Nested Practice',
|
'Nested Practice',
|
||||||
'Nested description',
|
'Nested description',
|
||||||
'<p>Nested rich text</p>',
|
|
||||||
$firstChildElement,
|
$firstChildElement,
|
||||||
);
|
);
|
||||||
$otherSet = $this->createSet(2, 'Daily Learning');
|
$otherSet = $this->createSet(2, 'Daily Learning');
|
||||||
|
|
@ -89,14 +80,12 @@ class GetElementTest extends TestCase
|
||||||
$otherSet,
|
$otherSet,
|
||||||
'Other Parent',
|
'Other Parent',
|
||||||
'Other parent description',
|
'Other parent description',
|
||||||
'<p>Other parent rich text</p>',
|
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
$this->createElement(
|
$this->createElement(
|
||||||
$otherSet,
|
$otherSet,
|
||||||
'Other Child',
|
'Other Child',
|
||||||
'Other child description',
|
'Other child description',
|
||||||
'<p>Other child rich text</p>',
|
|
||||||
$otherParentElement,
|
$otherParentElement,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -156,14 +145,12 @@ class GetElementTest extends TestCase
|
||||||
DomainSet $set,
|
DomainSet $set,
|
||||||
string $title,
|
string $title,
|
||||||
string $description,
|
string $description,
|
||||||
string $richText,
|
|
||||||
?Element $parentElement,
|
?Element $parentElement,
|
||||||
): Element {
|
): Element {
|
||||||
return $this->elementRepo->create(new CreateElementDto(
|
return $this->elementRepo->create(new CreateElementDto(
|
||||||
set: $set,
|
set: $set,
|
||||||
title: $title,
|
title: $title,
|
||||||
description: $description,
|
description: $description,
|
||||||
richText: $richText,
|
|
||||||
parentElement: $parentElement,
|
parentElement: $parentElement,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,17 +41,7 @@ describe('media page sets', () => {
|
||||||
cy.location('pathname').should('eq', '/element/1')
|
cy.location('pathname').should('eq', '/element/1')
|
||||||
cy.get('[data-cy="element-page"]').should('be.visible')
|
cy.get('[data-cy="element-page"]').should('be.visible')
|
||||||
cy.contains('h1', 'Baderech HaAvodah').should('be.visible')
|
cy.contains('h1', 'Baderech HaAvodah').should('be.visible')
|
||||||
cy.get('[data-cy="element-rich-text"]').within(() => {
|
|
||||||
cy.contains('Begin with a clear map for avodah growth.')
|
|
||||||
.should('be.visible')
|
|
||||||
cy.contains('strong', 'Move steadily').should('be.visible')
|
|
||||||
})
|
|
||||||
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"]')
|
|
||||||
.should(
|
|
||||||
'not.contain.text',
|
|
||||||
'Avodah foundations begin with honest awareness',
|
|
||||||
)
|
|
||||||
cy.contains('[data-cy="child-element-link"]', 'Avodah Foundations')
|
cy.contains('[data-cy="child-element-link"]', 'Avodah Foundations')
|
||||||
.as('avodahFoundationsLink')
|
.as('avodahFoundationsLink')
|
||||||
.should('have.attr', 'href', '/element/2')
|
.should('have.attr', 'href', '/element/2')
|
||||||
|
|
@ -73,10 +63,5 @@ describe('media page sets', () => {
|
||||||
.click()
|
.click()
|
||||||
cy.location('pathname').should('eq', '/element/2')
|
cy.location('pathname').should('eq', '/element/2')
|
||||||
cy.contains('h1', 'Avodah Foundations').should('be.visible')
|
cy.contains('h1', 'Avodah Foundations').should('be.visible')
|
||||||
cy.get('[data-cy="element-rich-text"]')
|
|
||||||
.should(
|
|
||||||
'contain.text',
|
|
||||||
'Avodah foundations begin with honest awareness',
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,22 @@
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
export interface ChildElement {
|
export interface Element {
|
||||||
id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Element extends ChildElement {
|
|
||||||
richText: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ElementResponse {
|
interface ElementResponse {
|
||||||
element: Element
|
element: Element
|
||||||
childElements: ChildElement[]
|
childElements: Element[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL as string
|
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL as string
|
||||||
|
|
||||||
export const useElementsStore = defineStore('elements', () => {
|
export const useElementsStore = defineStore('elements', () => {
|
||||||
const element = ref<Element | null>(null)
|
const element = ref<Element | null>(null)
|
||||||
const childElements = ref<ChildElement[]>([])
|
const childElements = ref<Element[]>([])
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const error = ref<string | null>(null)
|
const error = ref<string | null>(null)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,6 @@ watch(
|
||||||
{{ element.title }}
|
{{ element.title }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="element.richText !== ''"
|
|
||||||
class="element-page__rich-text"
|
|
||||||
data-cy="element-rich-text"
|
|
||||||
v-html="element.richText"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
v-if="childElements.length > 0"
|
v-if="childElements.length > 0"
|
||||||
class="element-page__children"
|
class="element-page__children"
|
||||||
|
|
@ -116,27 +109,6 @@ watch(
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.element-page__rich-text {
|
|
||||||
margin-top: 1.75rem;
|
|
||||||
color: #333333;
|
|
||||||
font-family: var(--font-sans);
|
|
||||||
font-size: 1.05rem;
|
|
||||||
line-height: 1.75;
|
|
||||||
}
|
|
||||||
|
|
||||||
.element-page__rich-text :deep(p) {
|
|
||||||
margin: 0 0 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.element-page__rich-text :deep(p:last-child) {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.element-page__rich-text :deep(strong) {
|
|
||||||
color: #2c2c2c;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.element-page__children {
|
.element-page__children {
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue