Merge branch 'adjust-demo-seed-data'

This commit is contained in:
Yisroel Baum 2026-05-27 22:15:09 +03:00
commit c7659b45ee
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
3 changed files with 403 additions and 68 deletions

View file

@ -6,6 +6,7 @@ use App\Element\CreateElementDto;
use App\Element\ElementRepository;
use App\Set\SetRepository;
use Illuminate\Database\Seeder;
use RuntimeException;
class ElementSeeder extends Seeder
{
@ -19,36 +20,156 @@ class ElementSeeder extends Seeder
title: $baderechSet->getName(),
description: $baderechSet->getDescription(),
iconImageUrl: '/assets/baderech-haavodah-icon.png',
richText: '<p>Begin with a clear map for avodah growth.</p>'
. '<p><strong>Move steadily</strong> from awareness '
. 'to practice.</p>',
pdfPath: '/assets/pdfs/baderech.pdf',
youtubeUrl: 'https://www.youtube.com/watch?v='
. 'yHx-r4p6hHU&t=1s',
richText: '',
pdfPath: null,
youtubeUrl: null,
parentElement: null,
));
$baderechChildElements = [
[
'title' => '1. Introduction',
'description' => 'Your beliefs influence your thinking, '
. 'and your thinking drives your choices. When you '
. 'nurture healthy beliefs - about yourself, about '
. 'the Creator, and about the meaning of life - you '
. 'unlock the ability to live with strength, confidence, '
. 'and hope.',
'richText' => $this->introductionRichText(),
'pdfPath' => '/assets/pdfs/baderech.pdf',
],
[
'title' => '2. Foundations',
'description' => 'Focal points for thriving in a chaotic '
. 'world. In this fast, complex era, you flourish when '
. 'you develop clarity, well-being, resilience, and the '
. 'ability to uplift the physical world with spiritual '
. 'intention.',
'richText' => '',
'pdfPath' => null,
],
[
'title' => '3. Divine Plan',
'description' => 'Understanding the unique greatness of our '
. 'generation and the call to remain hopeful, '
. 'optimistic, and resilient.',
'richText' => '',
'pdfPath' => null,
],
[
'title' => '4. Architecture of the Soul',
'description' => "Becoming a Baal Da'at - A Master of "
. 'Inner Awareness',
'richText' => '',
'pdfPath' => null,
],
[
'title' => '5. Arba Yesodot',
'description' => 'A structured approach to balanced living: '
. 'Physical & Financial Health, Relationships, Wisdom '
. 'and Guidance.',
'richText' => '',
'pdfPath' => null,
],
[
'title' => '6. Fluid Integration',
'description' => 'A series of practical exercises to '
. 'engender a shift in mindset, embed healthy routines, '
. 'positive life practices.',
'richText' => '',
'pdfPath' => null,
],
];
$introductionElement = null;
foreach ($baderechChildElements as $baderechChildElement) {
$createdElement = $elementRepository->create(new CreateElementDto(
set: $baderechSet,
title: $baderechChildElement['title'],
description: $baderechChildElement['description'],
iconImageUrl: null,
richText: $baderechChildElement['richText'],
pdfPath: $baderechChildElement['pdfPath'],
youtubeUrl: null,
parentElement: $rootElement,
));
if ($baderechChildElement['title'] === '1. Introduction') {
$introductionElement = $createdElement;
}
}
if ($introductionElement === null) {
throw new RuntimeException('Introduction element was not seeded');
}
$elementRepository->create(new CreateElementDto(
set: $baderechSet,
title: 'Avodah Foundations',
description: 'Core foundations for building a steady '
. 'avodah practice.',
title: 'Fundamentals # 1: Living Our Way to a Wholesome '
. 'Fulfilled Life (Audio)',
description: '',
iconImageUrl: null,
richText: '<p>Avodah foundations begin with honest awareness '
. 'and small repeatable steps.</p>',
richText: '',
pdfPath: null,
youtubeUrl: null,
parentElement: $rootElement,
));
$elementRepository->create(new CreateElementDto(
set: $baderechSet,
title: 'Daily Practice',
description: 'Practical steps for consistent daily growth.',
iconImageUrl: null,
richText: '<p>Daily practice turns inspiration into a '
. 'dependable rhythm.</p>',
pdfPath: null,
youtubeUrl: null,
parentElement: $rootElement,
youtubeUrl: 'https://www.youtube.com/watch?v='
. 'yHx-r4p6hHU&t=1s',
parentElement: $introductionElement,
));
}
private function introductionRichText(): string
{
return '<h2 style="text-align: center;">'
. 'What is Baderech HaAvoda?</h2>'
. '<h3>Why We Need a Path of Spiritual Practice</h3>'
. "<p>A 'Baderech HaAvoda' is a way of living - a structured "
. 'path for inner and outer growth, spiritual refinement, and '
. 'personal development. It is the art and discipline of knowing '
. 'where to place your attention, how to engage your inner and '
. 'outer world, and how to live the kind of life Hashem designed '
. 'for human beings: a life of wholeness, integration, clarity, '
. 'and joy.</p>'
. '<p>Throughout Jewish history, our sages taught that no person '
. 'can reach their potential without a derech - a framework that '
. 'provides:</p>'
. '<ul><li>Direction</li><li>Focus</li><li>Discernment</li>'
. '<li>Continuity</li><li>Practical Steps</li></ul>'
. '<p>Baderech HaAvoda answers core human questions:</p>'
. '<ul><li>How do I grow?</li><li>How do I align my inner world '
. 'with my values?</li><li>How do I relate to challenges?</li>'
. '<li>Where should I place my mind, heart, and actions each '
. 'day?</li><li>How do I live as the person Hashem intended me '
. 'to be?</li></ul>'
. '<p>Without a derech, people react to life instead of '
. 'responding with wisdom.</p>'
. '<p>Without a derech, inspiration fades as quickly as it '
. 'comes.</p>'
. '<p>Without a derech, a person cannot integrate what they '
. 'learn into who they become.</p>'
. '<p>A Baderech HaAvoda is therefore not a luxury - it is a '
. 'necessity for anyone who wants to live consciously, '
. 'purposefully, and in alignment with their Creator.</p>'
. '<h3>The Challenge of Our Generation</h3>'
. '<p>We live in a time overflowing with information and '
. 'stimulation, yet starving for depth.</p>'
. '<p>Our generation faces challenges that previous generations '
. 'rarely confronted:</p>'
. '<ul><li>Constant Distraction</li><li>Fragmented Attention</li>'
. '<li>Emotional Overwhelm</li><li>Lack of clarity about '
. 'identity and purpose</li><li>Minimal guidance in inner '
. 'development</li><li>Being told what to think rather than how '
. 'to think</li><li>So many are Hashkafikly homeless</li></ul>'
. '<p>People today are not taught:</p>'
. '<ul><li>How to understand themselves</li><li>How to regulate '
. 'their minds</li><li>How to cultivate awareness</li><li>How to '
. 'build a healthy inner life</li><li>How to live as integrated '
. 'human beings</li><li>The few important areas in life to focus '
. 'on</li></ul>'
. '<p>We have incredible access to knowledge, yet many feel lost '
. '- not for lack of information, but for lack of direction.</p>'
. '<p>A Baderech HaAvoda gives structure to the soul, it creates '
. 'inner order, and it transforms scattered potential into '
. 'living wisdom. It is a map for living a wholesome, healthy, '
. 'and spiritually aligned life - the life we were created for.'
. '</p>';
}
}

View file

@ -0,0 +1,172 @@
<?php
namespace Tests\Feature;
use App\Element\ElementRepository;
use App\Set\SetRepository;
use Database\Seeders\DatabaseSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class DemoSeedDataTest extends TestCase
{
use RefreshDatabase;
public function testBaderechRootElementHasDemoChildren(): void
{
$this->seed(DatabaseSeeder::class);
$setRepository = app(SetRepository::class);
$elementRepository = app(ElementRepository::class);
$baderechSet = $setRepository->find(1);
$rootElement = $elementRepository->findRootBySet($baderechSet);
$childElements = $elementRepository->findByParentElement($rootElement);
$this->assertSame('', $rootElement->getRichText());
$this->assertNull($rootElement->getPdfPath());
$this->assertNull($rootElement->getYoutubeUrl());
$this->assertCount(6, $childElements);
$this->assertSame(
[
[
'title' => '1. Introduction',
'description' => 'Your beliefs influence your thinking, '
. 'and your thinking drives your choices. When you '
. 'nurture healthy beliefs - about yourself, about '
. 'the Creator, and about the meaning of life - you '
. 'unlock the ability to live with strength, '
. 'confidence, and hope.',
],
[
'title' => '2. Foundations',
'description' => 'Focal points for thriving in a chaotic '
. 'world. In this fast, complex era, you flourish '
. 'when you develop clarity, well-being, resilience, '
. 'and the ability to uplift the physical world with '
. 'spiritual intention.',
],
[
'title' => '3. Divine Plan',
'description' => 'Understanding the unique greatness of '
. 'our generation and the call to remain hopeful, '
. 'optimistic, and resilient.',
],
[
'title' => '4. Architecture of the Soul',
'description' => "Becoming a Baal Da'at - A Master of "
. 'Inner Awareness',
],
[
'title' => '5. Arba Yesodot',
'description' => 'A structured approach to balanced '
. 'living: Physical & Financial Health, '
. 'Relationships, Wisdom and Guidance.',
],
[
'title' => '6. Fluid Integration',
'description' => 'A series of practical exercises to '
. 'engender a shift in mindset, embed healthy '
. 'routines, positive life practices.',
],
],
$this->serializeChildElements($childElements),
);
$this->assertSame(
$this->expectedIntroductionRichText(),
$childElements[0]->getRichText(),
);
$this->assertSame(
'/assets/pdfs/baderech.pdf',
$childElements[0]->getPdfPath(),
);
$introductionChildElements = $elementRepository->findByParentElement(
$childElements[0],
);
$this->assertCount(1, $introductionChildElements);
$introductionAudioElement = $introductionChildElements[0];
$this->assertSame(
'Fundamentals # 1: Living Our Way to a Wholesome Fulfilled Life '
. '(Audio)',
$introductionAudioElement->getTitle(),
);
$this->assertSame('', $introductionAudioElement->getDescription());
$this->assertNull($introductionAudioElement->getIconImageUrl());
$this->assertSame('', $introductionAudioElement->getRichText());
$this->assertNull($introductionAudioElement->getPdfPath());
$this->assertSame(
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
$introductionAudioElement->getYoutubeUrl(),
);
}
private function serializeChildElements(array $childElements): array
{
$serializedChildElements = [];
foreach ($childElements as $childElement) {
$serializedChildElements[] = [
'title' => $childElement->getTitle(),
'description' => $childElement->getDescription(),
];
}
return $serializedChildElements;
}
private function expectedIntroductionRichText(): string
{
return '<h2 style="text-align: center;">'
. 'What is Baderech HaAvoda?</h2>'
. '<h3>Why We Need a Path of Spiritual Practice</h3>'
. "<p>A 'Baderech HaAvoda' is a way of living - a structured "
. 'path for inner and outer growth, spiritual refinement, and '
. 'personal development. It is the art and discipline of knowing '
. 'where to place your attention, how to engage your inner and '
. 'outer world, and how to live the kind of life Hashem designed '
. 'for human beings: a life of wholeness, integration, clarity, '
. 'and joy.</p>'
. '<p>Throughout Jewish history, our sages taught that no person '
. 'can reach their potential without a derech - a framework that '
. 'provides:</p>'
. '<ul><li>Direction</li><li>Focus</li><li>Discernment</li>'
. '<li>Continuity</li><li>Practical Steps</li></ul>'
. '<p>Baderech HaAvoda answers core human questions:</p>'
. '<ul><li>How do I grow?</li><li>How do I align my inner world '
. 'with my values?</li><li>How do I relate to challenges?</li>'
. '<li>Where should I place my mind, heart, and actions each '
. 'day?</li><li>How do I live as the person Hashem intended me '
. 'to be?</li></ul>'
. '<p>Without a derech, people react to life instead of '
. 'responding with wisdom.</p>'
. '<p>Without a derech, inspiration fades as quickly as it '
. 'comes.</p>'
. '<p>Without a derech, a person cannot integrate what they '
. 'learn into who they become.</p>'
. '<p>A Baderech HaAvoda is therefore not a luxury - it is a '
. 'necessity for anyone who wants to live consciously, '
. 'purposefully, and in alignment with their Creator.</p>'
. '<h3>The Challenge of Our Generation</h3>'
. '<p>We live in a time overflowing with information and '
. 'stimulation, yet starving for depth.</p>'
. '<p>Our generation faces challenges that previous generations '
. 'rarely confronted:</p>'
. '<ul><li>Constant Distraction</li><li>Fragmented Attention</li>'
. '<li>Emotional Overwhelm</li><li>Lack of clarity about '
. 'identity and purpose</li><li>Minimal guidance in inner '
. 'development</li><li>Being told what to think rather than how '
. 'to think</li><li>So many are Hashkafikly homeless</li></ul>'
. '<p>People today are not taught:</p>'
. '<ul><li>How to understand themselves</li><li>How to regulate '
. 'their minds</li><li>How to cultivate awareness</li><li>How to '
. 'build a healthy inner life</li><li>How to live as integrated '
. 'human beings</li><li>The few important areas in life to focus '
. 'on</li></ul>'
. '<p>We have incredible access to knowledge, yet many feel lost '
. '- not for lack of information, but for lack of direction.</p>'
. '<p>A Baderech HaAvoda gives structure to the soul, it creates '
. 'inner order, and it transforms scattered potential into '
. 'living wisdom. It is a map for living a wholesome, healthy, '
. 'and spiritually aligned life - the life we were created for.'
. '</p>';
}
}

View file

@ -1,5 +1,8 @@
describe('media page sets', () => {
it('fetches and renders seeded set cards', () => {
const introductionAudioTitle =
'Fundamentals # 1: Living Our Way to a Wholesome Fulfilled Life (Audio)'
cy.visit('/media')
cy.get('header.site-header').within(() => {
@ -45,54 +48,93 @@ describe('media page sets', () => {
.should('be.visible')
.and('have.attr', 'src')
.and('include', '/assets/baderech-haavodah-icon.png')
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="element-rich-text"]').should('not.exist')
cy.get('[data-cy="element-youtube-embed"]')
.should('not.exist')
cy.get('[data-cy="element-pdf-link"]').should('not.exist')
cy.get('[data-cy="child-element-list"]').should('be.visible')
cy.get('[data-cy="child-element-list"]')
.should(
'not.contain.text',
'Begin with a clear map for avodah growth.',
)
cy.contains('[data-cy="child-element-link"]', '1. Introduction')
.as('introductionLink')
.should('have.attr', 'href', '/element/2')
cy.get('@introductionLink')
.should(
'contain.text',
'Your beliefs influence your thinking, and your thinking drives',
)
cy.contains('[data-cy="child-element-link"]', '2. Foundations')
.should(
'contain.text',
'Focal points for thriving in a chaotic world.',
)
cy.contains('[data-cy="child-element-link"]', '3. Divine Plan')
.should(
'contain.text',
'Understanding the unique greatness of our generation',
)
cy.contains(
'[data-cy="child-element-link"]',
'4. Architecture of the Soul',
)
.should(
'contain.text',
"Becoming a Baal Da'at - A Master of Inner Awareness",
)
cy.contains('[data-cy="child-element-link"]', '5. Arba Yesodot')
.should('contain.text', 'Physical & Financial Health')
cy.contains('[data-cy="child-element-link"]', '6. Fluid Integration')
.should('contain.text', 'engender a shift in mindset')
.and('have.attr', 'href', '/element/7')
cy.contains('[data-cy="child-element-link"]', '1. Introduction')
.click()
cy.location('pathname').should('eq', '/element/2')
cy.contains('h1', '1. Introduction').should('be.visible')
cy.get('[data-cy="element-icon"]').should('not.exist')
cy.get('[data-cy="element-rich-text"]')
.should('contain.text', 'What is Baderech HaAvoda?')
.and(
'contain.text',
'Why We Need a Path of Spiritual Practice',
)
.and(
'contain.text',
"A 'Baderech HaAvoda' is a way of living",
)
.and('contain.text', 'Direction')
.and('contain.text', 'How do I grow?')
.and('contain.text', 'The Challenge of Our Generation')
.and('contain.text', 'So many are Hashkafikly homeless')
.and('contain.text', 'the life we were created for.')
cy.contains(
'[data-cy="element-rich-text"] h2',
'What is Baderech HaAvoda?',
)
.should('have.css', 'text-align', 'center')
cy.get('[data-cy="element-youtube-embed"]').should('not.exist')
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.contains('[data-cy="child-element-link"]', introductionAudioTitle)
.as('introductionAudioLink')
.should('have.attr', 'href', '/element/8')
cy.get('@introductionAudioLink').click()
cy.location('pathname').should('eq', '/element/8')
cy.contains('h1', introductionAudioTitle).should('be.visible')
cy.get('[data-cy="element-icon"]').should('not.exist')
cy.get('[data-cy="element-rich-text"]').should('not.exist')
cy.get('[data-cy="element-pdf-link"]').should('not.exist')
cy.get('[data-cy="child-element-list"]').should('not.exist')
cy.get('[data-cy="element-youtube-embed"]')
.should('be.visible')
.and('have.attr', 'src')
.and('include', 'https://www.youtube.com/embed/yHx-r4p6hHU')
.and('include', 'start=1')
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(
'not.contain.text',
'Avodah foundations begin with honest awareness',
)
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()
cy.location('pathname').should('eq', '/element/2')
cy.contains('h1', 'Avodah Foundations').should('be.visible')
cy.get('[data-cy="element-icon"]').should('not.exist')
cy.get('[data-cy="element-rich-text"]')
.should(
'contain.text',
'Avodah foundations begin with honest awareness',
)
cy.get('[data-cy="element-youtube-embed"]').should('not.exist')
cy.get('[data-cy="element-pdf-link"]').should('not.exist')
})
})