From 0b4d7238afd49f81e4d420a692e43310a3ad1542 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 26 Apr 2026 20:50:52 +0300 Subject: [PATCH 01/34] add today page cypress spec --- cypress/e2e/today.cy.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cypress/e2e/today.cy.js diff --git a/cypress/e2e/today.cy.js b/cypress/e2e/today.cy.js new file mode 100644 index 0000000..7332662 --- /dev/null +++ b/cypress/e2e/today.cy.js @@ -0,0 +1,32 @@ +describe('The today page', () => { + beforeEach(() => { + cy.exec('npm run db:seed') + }) + + afterEach(() => { + cy.exec('npm run db:wipe') + }) + + it('redirects to login when not authenticated', () => { + cy.visit('/today') + cy.url().should('include', '/login') + }) + + it('displays a Today heading when authenticated', () => { + cy.loginAsUser() + cy.visit('/today') + cy.get('h1').should('contain', 'Today') + }) + + it('has a list element for scheduled nodes', () => { + cy.loginAsUser() + cy.visit('/today') + cy.get('#scheduled-nodes-list').should('exist') + }) + + it('home page links to the today page', () => { + cy.loginAsUser() + cy.visit('/home') + cy.get('a[href="/today"]').should('be.visible') + }) +}) From bfacb5b62c6e9903aa36058a0234acd3619a921a Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 26 Apr 2026 21:24:35 +0300 Subject: [PATCH 02/34] add today view route and template --- .gitignore | 4 +++- app/View/ViewController.php | 10 ++++++++++ bootstrap/app.php | 1 + public/js/today.js | 33 +++++++++++++++++++++++++++++++++ views/templates/today.php | 13 +++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 public/js/today.js create mode 100644 views/templates/today.php diff --git a/.gitignore b/.gitignore index 68bd285..f8b367e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ vendor/ node_modules/ data/*.json -.direnv/ \ No newline at end of file +.direnv/ +cypress/screenshots/ +cypress/videos/ \ No newline at end of file diff --git a/app/View/ViewController.php b/app/View/ViewController.php index 4fd8d84..efe322b 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -38,6 +38,16 @@ class ViewController return $response; } + public function today(Response $response): Response + { + $html = file_get_contents( + __DIR__ . '/../../views/templates/today.php' + ); + $response->getBody()->write($html); + + return $response; + } + public function login(Response $response): Response { $html = file_get_contents( diff --git a/bootstrap/app.php b/bootstrap/app.php index c05dc0f..c2150e0 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -27,6 +27,7 @@ $app->post('/api/auth/register', [AuthController::class, 'register']); // Authenticated routes (any logged-in user) $app->group('', function (RouteCollectorProxy $group) { $group->get('/home', [ViewController::class, 'home']); + $group->get('/today', [ViewController::class, 'today']); $group->post('/api/auth/logout', [AuthController::class, 'logout']); $group->get('/api/auth/me', [AuthController::class, 'me']); diff --git a/public/js/today.js b/public/js/today.js new file mode 100644 index 0000000..6f14627 --- /dev/null +++ b/public/js/today.js @@ -0,0 +1,33 @@ +document.addEventListener('DOMContentLoaded', () => { + const scheduledNodesList = document.getElementById( + 'scheduled-nodes-list' + ); + + function todayDateString() { + const today = new Date(); + const year = today.getFullYear(); + const month = String(today.getMonth() + 1).padStart(2, '0'); + const day = String(today.getDate()).padStart(2, '0'); + return year + '-' + month + '-' + day; + } + + async function loadScheduledNodes() { + const date = todayDateString(); + const response = await fetch( + '/api/scheduled-nodes?date=' + date, + { credentials: 'same-origin' } + ); + if (!response.ok) { + return; + } + const scheduledNodes = await response.json(); + scheduledNodesList.innerHTML = scheduledNodes + .map((scheduledNode) => + '
  • ' + scheduledNode.planName + ': ' + + scheduledNode.nodeTitle + '
  • ' + ) + .join(''); + } + + loadScheduledNodes(); +}); diff --git a/views/templates/today.php b/views/templates/today.php new file mode 100644 index 0000000..6edba97 --- /dev/null +++ b/views/templates/today.php @@ -0,0 +1,13 @@ + + + + Daily Goals - Today + + +

    Today

    + + + + + From 6314f1c38c5bc8cbe77dba01c75a778781f775e9 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 26 Apr 2026 20:53:08 +0300 Subject: [PATCH 03/34] add link to today page on home --- views/templates/home.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/templates/home.php b/views/templates/home.php index 4f7a096..258a404 100644 --- a/views/templates/home.php +++ b/views/templates/home.php @@ -6,6 +6,7 @@

    Home

    + Today's schedule