Compare commits
No commits in common. "ef54aa97aab07156b9b76b3ad167414822ac86a8" and "a317f24976229118fe8c268e778e775bf966777b" have entirely different histories.
ef54aa97aa
...
a317f24976
20 changed files with 2 additions and 150 deletions
|
|
@ -35,15 +35,6 @@ intentionally omitted here - update this section as entities land.
|
|||
`new Set(...)`) instead of creating them through their fake
|
||||
repositories
|
||||
|
||||
## Migrations
|
||||
|
||||
- This project is not in production. By default, schema changes should update
|
||||
the relevant create-table migration so migrations describe the current desired
|
||||
schema from scratch.
|
||||
- Do not add alter-table or data-backfill migrations unless the user explicitly
|
||||
asks for production-style migration safety.
|
||||
- Put seed data in seeders, not migrations.
|
||||
|
||||
## PHP rules
|
||||
|
||||
- Imports: always put `use` statements at the top of the file, never use
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class ElementController
|
|||
$childElements[] = [
|
||||
'id' => $childElement->getId(),
|
||||
'title' => $childElement->getTitle(),
|
||||
'description' => $childElement->getDescription(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +44,6 @@ class ElementController
|
|||
'element' => [
|
||||
'id' => $element->getId(),
|
||||
'title' => $element->getTitle(),
|
||||
'description' => $element->getDescription(),
|
||||
],
|
||||
], 200);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class CreateElementDto
|
|||
public function __construct(
|
||||
public Set $set,
|
||||
public string $title,
|
||||
public string $description,
|
||||
public ?Element $parentElement,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class Element
|
|||
public function __construct(
|
||||
private int $id,
|
||||
private string $title,
|
||||
private string $description,
|
||||
private Set $set,
|
||||
private ?Element $parentElement,
|
||||
) {
|
||||
|
|
@ -25,11 +24,6 @@ class Element
|
|||
return $this->title;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getSet(): Set
|
||||
{
|
||||
return $this->set;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int $id
|
||||
* @property int $set_id
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
* @property int|null $parent_element_id
|
||||
*
|
||||
* @method static Builder<static>|ElementModel newModelQuery()
|
||||
|
|
@ -19,7 +18,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static Builder<static>|ElementModel whereParentElementId($value)
|
||||
* @method static Builder<static>|ElementModel whereSetId($value)
|
||||
* @method static Builder<static>|ElementModel whereTitle($value)
|
||||
* @method static Builder<static>|ElementModel whereDescription($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
|
@ -32,7 +30,6 @@ class ElementModel extends Model
|
|||
protected $fillable = [
|
||||
'set_id',
|
||||
'title',
|
||||
'description',
|
||||
'parent_element_id',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,12 @@ class EloquentElementRepository implements ElementRepository
|
|||
$model = ElementModel::create([
|
||||
'set_id' => $dto->set->getId(),
|
||||
'title' => $dto->title,
|
||||
'description' => $dto->description,
|
||||
'parent_element_id' => $dto->parentElement?->getId(),
|
||||
]);
|
||||
|
||||
return new Element(
|
||||
id: $model->id,
|
||||
title: $dto->title,
|
||||
description: $dto->description,
|
||||
set: $dto->set,
|
||||
parentElement: $dto->parentElement,
|
||||
);
|
||||
|
|
@ -104,7 +102,6 @@ class EloquentElementRepository implements ElementRepository
|
|||
return new Element(
|
||||
id: $model->id,
|
||||
title: $model->title,
|
||||
description: $model->description,
|
||||
set: $set,
|
||||
parentElement: $parentElement,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class CreateElement
|
|||
if ($request->title === null || $request->title === '') {
|
||||
throw new BadRequestException('title is required');
|
||||
}
|
||||
$description = $request->description ?? '';
|
||||
|
||||
$set = $this->setRepo->find($request->setId);
|
||||
if ($set === null) {
|
||||
|
|
@ -45,7 +44,6 @@ class CreateElement
|
|||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: $request->title,
|
||||
description: $description,
|
||||
parentElement: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -67,7 +65,6 @@ class CreateElement
|
|||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: $request->title,
|
||||
description: $description,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ class CreateElementRequest
|
|||
public function __construct(
|
||||
public ?int $setId,
|
||||
public ?string $title,
|
||||
public ?string $description,
|
||||
public ?int $parentElementId,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->foreignId('set_id')->constrained('sets');
|
||||
$table->string('title');
|
||||
$table->text('description')->default('');
|
||||
$table->foreignId('parent_element_id')
|
||||
->nullable()
|
||||
->constrained('elements');
|
||||
|
|
|
|||
|
|
@ -17,20 +17,16 @@ class ElementSeeder extends Seeder
|
|||
$rootElement = $elementRepository->create(new CreateElementDto(
|
||||
set: $baderechSet,
|
||||
title: $baderechSet->getName(),
|
||||
description: $baderechSet->getDescription(),
|
||||
parentElement: null,
|
||||
));
|
||||
$elementRepository->create(new CreateElementDto(
|
||||
set: $baderechSet,
|
||||
title: 'Avodah Foundations',
|
||||
description: 'Core foundations for building a steady '
|
||||
. 'avodah practice.',
|
||||
parentElement: $rootElement,
|
||||
));
|
||||
$elementRepository->create(new CreateElementDto(
|
||||
set: $baderechSet,
|
||||
title: 'Daily Practice',
|
||||
description: 'Practical steps for consistent daily growth.',
|
||||
parentElement: $rootElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ class FakeElementRepository implements ElementRepository
|
|||
$element = new Element(
|
||||
id: $id,
|
||||
title: $dto->title,
|
||||
description: $dto->description,
|
||||
set: $dto->set,
|
||||
parentElement: $dto->parentElement,
|
||||
);
|
||||
|
|
@ -96,7 +95,6 @@ class FakeElementRepository implements ElementRepository
|
|||
return new Element(
|
||||
id: $element->getId(),
|
||||
title: $element->getTitle(),
|
||||
description: $element->getDescription(),
|
||||
set: $element->getSet(),
|
||||
parentElement: $parentElement,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,19 +25,16 @@ class ElementsEndpointTest extends TestCase
|
|||
$element = $elementRepository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: 'Baderech HaAvodah',
|
||||
description: 'A structured path for growth',
|
||||
parentElement: null,
|
||||
));
|
||||
$firstChildElement = $elementRepository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: 'Avodah Foundations',
|
||||
description: 'Foundations for steady avodah',
|
||||
parentElement: $element,
|
||||
));
|
||||
$secondChildElement = $elementRepository->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: 'Daily Practice',
|
||||
description: 'Daily practices for growth',
|
||||
parentElement: $element,
|
||||
));
|
||||
|
||||
|
|
@ -49,18 +46,15 @@ class ElementsEndpointTest extends TestCase
|
|||
[
|
||||
'id' => $firstChildElement->getId(),
|
||||
'title' => 'Avodah Foundations',
|
||||
'description' => 'Foundations for steady avodah',
|
||||
],
|
||||
[
|
||||
'id' => $secondChildElement->getId(),
|
||||
'title' => 'Daily Practice',
|
||||
'description' => 'Daily practices for growth',
|
||||
],
|
||||
],
|
||||
'element' => [
|
||||
'id' => $element->getId(),
|
||||
'title' => 'Baderech HaAvodah',
|
||||
'description' => 'A structured path for growth',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class SetsEndpointTest extends TestCase
|
|||
new CreateElementDto(
|
||||
set: $baderechSet,
|
||||
title: $baderechSet->getName(),
|
||||
description: $baderechSet->getDescription(),
|
||||
parentElement: null,
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -26,22 +26,15 @@ class ElementControllerTest extends TestCase
|
|||
public function testShowReturnsElementPayload(): void
|
||||
{
|
||||
$set = $this->createSet(1, 'Baderech');
|
||||
$element = $this->createElement(
|
||||
$set,
|
||||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
null,
|
||||
);
|
||||
$element = $this->createElement($set, 'Baderech HaAvodah', null);
|
||||
$firstChildElement = $this->createElement(
|
||||
$set,
|
||||
'Avodah Foundations',
|
||||
'Foundations for steady avodah',
|
||||
$element,
|
||||
);
|
||||
$secondChildElement = $this->createElement(
|
||||
$set,
|
||||
'Daily Practice',
|
||||
'Daily practices for growth',
|
||||
$element,
|
||||
);
|
||||
|
||||
|
|
@ -51,20 +44,14 @@ class ElementControllerTest extends TestCase
|
|||
$body = json_decode($response->getContent(), true);
|
||||
$this->assertSame($element->getId(), $body['element']['id']);
|
||||
$this->assertSame('Baderech HaAvodah', $body['element']['title']);
|
||||
$this->assertSame(
|
||||
'A structured path for growth',
|
||||
$body['element']['description'],
|
||||
);
|
||||
$this->assertSame([
|
||||
[
|
||||
'id' => $firstChildElement->getId(),
|
||||
'title' => 'Avodah Foundations',
|
||||
'description' => 'Foundations for steady avodah',
|
||||
],
|
||||
[
|
||||
'id' => $secondChildElement->getId(),
|
||||
'title' => 'Daily Practice',
|
||||
'description' => 'Daily practices for growth',
|
||||
],
|
||||
], $body['childElements']);
|
||||
}
|
||||
|
|
@ -104,13 +91,11 @@ class ElementControllerTest extends TestCase
|
|||
private function createElement(
|
||||
DomainSet $set,
|
||||
string $title,
|
||||
string $description,
|
||||
?Element $parentElement,
|
||||
): Element {
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: $title,
|
||||
description: $description,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,24 +19,18 @@ class ElementTest extends TestCase
|
|||
$rootElement = new Element(
|
||||
id: 1,
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
set: $set,
|
||||
parentElement: null,
|
||||
);
|
||||
$childElement = new Element(
|
||||
id: 2,
|
||||
title: 'Child',
|
||||
description: 'Child description',
|
||||
set: $set,
|
||||
parentElement: $rootElement,
|
||||
);
|
||||
|
||||
$this->assertSame(2, $childElement->getId());
|
||||
$this->assertSame('Child', $childElement->getTitle());
|
||||
$this->assertSame(
|
||||
'Child description',
|
||||
$childElement->getDescription(),
|
||||
);
|
||||
$this->assertSame($set, $childElement->getSet());
|
||||
$this->assertSame($rootElement, $childElement->getParentElement());
|
||||
$this->assertNull($rootElement->getParentElement());
|
||||
|
|
|
|||
|
|
@ -47,13 +47,11 @@ class CreateElementTest extends TestCase
|
|||
$element = $this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
$this->assertInstanceOf(Element::class, $element);
|
||||
$this->assertSame('Root', $element->getTitle());
|
||||
$this->assertSame('Root description', $element->getDescription());
|
||||
$this->assertSame($set->getId(), $element->getSet()->getId());
|
||||
$this->assertNull($element->getParentElement());
|
||||
}
|
||||
|
|
@ -65,7 +63,6 @@ class CreateElementTest extends TestCase
|
|||
new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
)
|
||||
);
|
||||
|
|
@ -74,36 +71,17 @@ class CreateElementTest extends TestCase
|
|||
new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Child',
|
||||
description: 'Child description',
|
||||
parentElementId: $rootElement->getId(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame('Child', $childElement->getTitle());
|
||||
$this->assertSame(
|
||||
'Child description',
|
||||
$childElement->getDescription(),
|
||||
);
|
||||
$this->assertSame(
|
||||
$rootElement->getId(),
|
||||
$childElement->getParentElement()->getId(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testCreatesElementWithBlankDescriptionWhenMissing(): void
|
||||
{
|
||||
$set = $this->createSet('Daily learning');
|
||||
|
||||
$element = $this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: null,
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
$this->assertSame('', $element->getDescription());
|
||||
}
|
||||
|
||||
public function testThrowsWhenSetIdMissing(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
|
@ -112,7 +90,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: null,
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -125,7 +102,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: 1,
|
||||
title: null,
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -138,7 +114,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: 99,
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -155,7 +130,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Child',
|
||||
description: 'Child description',
|
||||
parentElementId: 99,
|
||||
));
|
||||
}
|
||||
|
|
@ -166,7 +140,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Root',
|
||||
description: 'Root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
|
||||
|
|
@ -178,7 +151,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $set->getId(),
|
||||
title: 'Another root',
|
||||
description: 'Another root description',
|
||||
parentElementId: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -191,7 +163,6 @@ class CreateElementTest extends TestCase
|
|||
new CreateElementRequest(
|
||||
setId: $parentSet->getId(),
|
||||
title: 'Parent root',
|
||||
description: 'Parent root description',
|
||||
parentElementId: null,
|
||||
)
|
||||
);
|
||||
|
|
@ -204,7 +175,6 @@ class CreateElementTest extends TestCase
|
|||
$this->createElement->execute(new CreateElementRequest(
|
||||
setId: $childSet->getId(),
|
||||
title: 'Invalid child',
|
||||
description: 'Invalid child description',
|
||||
parentElementId: $parentElement->getId(),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class GetElementTest extends TestCase
|
|||
$element = $this->createElement(
|
||||
$set,
|
||||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
null,
|
||||
);
|
||||
|
||||
|
|
@ -42,10 +41,6 @@ class GetElementTest extends TestCase
|
|||
$this->assertInstanceOf(Element::class, $foundElement);
|
||||
$this->assertSame($element->getId(), $foundElement->getId());
|
||||
$this->assertSame('Baderech HaAvodah', $foundElement->getTitle());
|
||||
$this->assertSame(
|
||||
'A structured path for growth',
|
||||
$foundElement->getDescription(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnsDirectChildElements(): void
|
||||
|
|
@ -54,38 +49,32 @@ class GetElementTest extends TestCase
|
|||
$parentElement = $this->createElement(
|
||||
$set,
|
||||
'Baderech HaAvodah',
|
||||
'A structured path for growth',
|
||||
null,
|
||||
);
|
||||
$firstChildElement = $this->createElement(
|
||||
$set,
|
||||
'Avodah Foundations',
|
||||
'Foundations for steady avodah',
|
||||
$parentElement,
|
||||
);
|
||||
$secondChildElement = $this->createElement(
|
||||
$set,
|
||||
'Daily Practice',
|
||||
'Daily practices for growth',
|
||||
$parentElement,
|
||||
);
|
||||
$this->createElement(
|
||||
$set,
|
||||
'Nested Practice',
|
||||
'Nested description',
|
||||
$firstChildElement,
|
||||
);
|
||||
$otherSet = $this->createSet(2, 'Daily Learning');
|
||||
$otherParentElement = $this->createElement(
|
||||
$otherSet,
|
||||
'Other Parent',
|
||||
'Other parent description',
|
||||
null,
|
||||
);
|
||||
$this->createElement(
|
||||
$otherSet,
|
||||
'Other Child',
|
||||
'Other child description',
|
||||
$otherParentElement,
|
||||
);
|
||||
|
||||
|
|
@ -100,19 +89,11 @@ class GetElementTest extends TestCase
|
|||
$childElements[0]->getId(),
|
||||
);
|
||||
$this->assertSame('Avodah Foundations', $childElements[0]->getTitle());
|
||||
$this->assertSame(
|
||||
'Foundations for steady avodah',
|
||||
$childElements[0]->getDescription(),
|
||||
);
|
||||
$this->assertSame(
|
||||
$secondChildElement->getId(),
|
||||
$childElements[1]->getId(),
|
||||
);
|
||||
$this->assertSame('Daily Practice', $childElements[1]->getTitle());
|
||||
$this->assertSame(
|
||||
'Daily practices for growth',
|
||||
$childElements[1]->getDescription(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testThrowsWhenIdMissing(): void
|
||||
|
|
@ -144,13 +125,11 @@ class GetElementTest extends TestCase
|
|||
private function createElement(
|
||||
DomainSet $set,
|
||||
string $title,
|
||||
string $description,
|
||||
?Element $parentElement,
|
||||
): Element {
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
title: $title,
|
||||
description: $description,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,21 +43,9 @@ describe('media page sets', () => {
|
|||
cy.contains('h1', 'Baderech HaAvodah').should('be.visible')
|
||||
cy.get('[data-cy="child-element-list"]').should('be.visible')
|
||||
cy.contains('[data-cy="child-element-link"]', 'Avodah Foundations')
|
||||
.as('avodahFoundationsLink')
|
||||
.should('have.attr', 'href', '/element/2')
|
||||
cy.get('@avodahFoundationsLink')
|
||||
.should(
|
||||
'contain.text',
|
||||
'Core foundations for building a steady avodah practice.',
|
||||
)
|
||||
cy.contains('[data-cy="child-element-link"]', 'Daily Practice')
|
||||
.as('dailyPracticeLink')
|
||||
.should('have.attr', 'href', '/element/3')
|
||||
cy.get('@dailyPracticeLink')
|
||||
.should(
|
||||
'contain.text',
|
||||
'Practical steps for consistent daily growth.',
|
||||
)
|
||||
|
||||
cy.contains('[data-cy="child-element-link"]', 'Avodah Foundations')
|
||||
.click()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { defineStore } from 'pinia'
|
|||
export interface Element {
|
||||
id: number
|
||||
title: string
|
||||
description: string
|
||||
}
|
||||
|
||||
interface ElementResponse {
|
||||
|
|
|
|||
|
|
@ -65,15 +65,7 @@ watch(
|
|||
class="element-page__child-link"
|
||||
data-cy="child-element-link"
|
||||
>
|
||||
<span class="element-page__child-title">
|
||||
{{ childElement.title }}
|
||||
</span>
|
||||
<span
|
||||
v-if="childElement.description !== ''"
|
||||
class="element-page__child-description"
|
||||
>
|
||||
{{ childElement.description }}
|
||||
</span>
|
||||
{{ childElement.title }}
|
||||
</RouterLink>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -139,19 +131,6 @@ watch(
|
|||
transform 180ms ease;
|
||||
}
|
||||
|
||||
.element-page__child-title {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.element-page__child-description {
|
||||
display: block;
|
||||
margin-top: 0.4rem;
|
||||
color: var(--color-text-muted);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.element-page__child-link:hover,
|
||||
.element-page__child-link:focus-visible {
|
||||
border-color: #d4ad5f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue