From 09b906a00fadd19710e94c829f45dbc15c3f3778 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Thu, 23 Apr 2026 10:01:29 +0300 Subject: [PATCH 1/5] test home page displays texts --- cypress/e2e/home.cy.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cypress/e2e/home.cy.js diff --git a/cypress/e2e/home.cy.js b/cypress/e2e/home.cy.js new file mode 100644 index 0000000..d0ba1fe --- /dev/null +++ b/cypress/e2e/home.cy.js @@ -0,0 +1,20 @@ +describe('The home page', () => { + beforeEach(() => { + cy.exec('npm run db:seed') + }) + afterEach(() => { + cy.exec('npm run db:wipe') + }) + + it('displays heading', () => { + cy.visit('/home') + cy.get('h1').should('contain', 'Home') + }) + + it('displays texts from api', () => { + cy.intercept('GET', '/api/texts').as('getTexts') + cy.visit('/home') + cy.wait('@getTexts') + cy.get('#texts-list').should('contain', 'Tanach') + }) +}) From 95ea38acfac2f5213178021b8d242123b9341205 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Thu, 23 Apr 2026 10:01:45 +0300 Subject: [PATCH 2/5] add home template --- views/templates/home.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 views/templates/home.php diff --git a/views/templates/home.php b/views/templates/home.php new file mode 100644 index 0000000..a386efe --- /dev/null +++ b/views/templates/home.php @@ -0,0 +1,12 @@ + + + + Daily Goals - Home + + +

Home

+ + + + From 1c2ca21f44e4cf5acc9f94122ba6eb7756fead28 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Thu, 23 Apr 2026 10:01:56 +0300 Subject: [PATCH 3/5] add home javascript --- public/js/home.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 public/js/home.js diff --git a/public/js/home.js b/public/js/home.js new file mode 100644 index 0000000..3e7cde8 --- /dev/null +++ b/public/js/home.js @@ -0,0 +1,13 @@ +document.addEventListener('DOMContentLoaded', () => { + const textsList = document.getElementById('texts-list'); + + async function loadTexts() { + const response = await fetch('/api/texts'); + const texts = await response.json(); + textsList.innerHTML = texts + .map(text => '
  • ' + text.name + '
  • ') + .join(''); + } + + loadTexts(); +}); From 29db3aec553a2f5634449c59ebfd155973495373 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Thu, 23 Apr 2026 10:02:10 +0300 Subject: [PATCH 4/5] add home controller method --- app/View/ViewController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/View/ViewController.php b/app/View/ViewController.php index 742b4be..c131683 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -29,4 +29,12 @@ class ViewController return $response; } + + public function home(Response $response): Response + { + $html = file_get_contents(__DIR__ . '/../../views/templates/home.php', true); + $response->getBody()->write($html); + + return $response; + } } From ff3e0b26f7915a713a95cdea66134ac4970d4841 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Thu, 23 Apr 2026 10:02:22 +0300 Subject: [PATCH 5/5] add home route --- bootstrap/app.php | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap/app.php b/bootstrap/app.php index 6dfce21..db0dd63 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -13,6 +13,7 @@ $app = Bridge::create($container); // change first param to false for production $app->addErrorMiddleware(true, true, true); +$app->get('/home', [ViewController::class, 'home']); $app->get('/admin', [ViewController::class, 'admin']); $app->get('/admin/texts', [ViewController::class, 'texts']); $app->get('/admin/texts/{textId}', [ViewController::class, 'text']);