rename route for nodes and adjust calls to route

This commit is contained in:
Yisroel Baum 2026-04-18 20:57:40 +03:00
parent adc72961d0
commit f5a8b8447f
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 6 additions and 5 deletions

View file

@ -13,7 +13,7 @@ class NodeController
private TextRepository $textRepository, private TextRepository $textRepository,
) {} ) {}
public function getNodes(Response $response, int $textId): Response public function getNodesOfText(Response $response, int $textId): Response
{ {
$text = $this->textRepository->find($textId); $text = $this->textRepository->find($textId);

View file

@ -19,7 +19,8 @@ $app->get('/admin/texts/{textId}', [ViewController::class, 'text']);
$app->get('/api/texts', [TextController::class, 'getTexts']); $app->get('/api/texts', [TextController::class, 'getTexts']);
$app->get('/api/texts/{textId}', [TextController::class, 'getText']); $app->get('/api/texts/{textId}', [TextController::class, 'getText']);
$app->get('/api/texts/{textId}/nodes', [NodeController::class, 'getNodes']);
$app->post('/api/texts', [TextController::class, 'createText']); $app->post('/api/texts', [TextController::class, 'createText']);
$app->get('/api/nodes/{textId}', [NodeController::class, 'getNodesOfText']);
return $app; return $app;

View file

@ -28,7 +28,7 @@ describe('The admin page', () => {
it('shows one root node and child node on the seeded text page', () => { it('shows one root node and child node on the seeded text page', () => {
cy.visit('/admin/texts/0') cy.visit('/admin/texts/0')
cy.intercept('GET', '/api/texts/0/nodes').as('getNodes') cy.intercept('GET', '/api/nodes/0').as('getNodes')
cy.wait('@getNodes') cy.wait('@getNodes')
cy.get('#text-detail > ul > li > ul > li').should('have.length', 1) cy.get('#text-detail > ul > li > ul > li').should('have.length', 1)
}) })
@ -37,7 +37,7 @@ describe('The admin page', () => {
cy.visit('/admin/texts') cy.visit('/admin/texts')
cy.get('#newTextName').type('My Node Text') cy.get('#newTextName').type('My Node Text')
cy.get('#submit').click() cy.get('#submit').click()
cy.intercept('GET', '/api/texts/1/nodes').as('getNodes') cy.intercept('GET', '/api/nodes/1').as('getNodes')
cy.get('a').contains('My Node Text').click() cy.get('a').contains('My Node Text').click()
cy.wait('@getNodes') cy.wait('@getNodes')
cy.get('#text-detail > ul').should('have.length', 1) cy.get('#text-detail > ul').should('have.length', 1)

View file

@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
h1.textContent = text.name; h1.textContent = text.name;
document.getElementById('text-detail').appendChild(h1); document.getElementById('text-detail').appendChild(h1);
return fetch('/api/texts/' + textId + '/nodes'); return fetch('/api/nodes/' + textId );
}) })
.then(res => res.json()) .then(res => res.json())
.then(nodes => { .then(nodes => {