Merge branch 'home-page'
This commit is contained in:
commit
7084794c67
5 changed files with 54 additions and 0 deletions
|
|
@ -29,4 +29,12 @@ class ViewController
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function home(Response $response): Response
|
||||||
|
{
|
||||||
|
$html = file_get_contents(__DIR__ . '/../../views/templates/home.php', true);
|
||||||
|
$response->getBody()->write($html);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ $app = Bridge::create($container);
|
||||||
// change first param to false for production
|
// change first param to false for production
|
||||||
$app->addErrorMiddleware(true, true, true);
|
$app->addErrorMiddleware(true, true, true);
|
||||||
|
|
||||||
|
$app->get('/home', [ViewController::class, 'home']);
|
||||||
$app->get('/admin', [ViewController::class, 'admin']);
|
$app->get('/admin', [ViewController::class, 'admin']);
|
||||||
$app->get('/admin/texts', [ViewController::class, 'texts']);
|
$app->get('/admin/texts', [ViewController::class, 'texts']);
|
||||||
$app->get('/admin/texts/{textId}', [ViewController::class, 'text']);
|
$app->get('/admin/texts/{textId}', [ViewController::class, 'text']);
|
||||||
|
|
|
||||||
20
cypress/e2e/home.cy.js
Normal file
20
cypress/e2e/home.cy.js
Normal file
|
|
@ -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')
|
||||||
|
})
|
||||||
|
})
|
||||||
13
public/js/home.js
Normal file
13
public/js/home.js
Normal file
|
|
@ -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 => '<li>' + text.name + '</li>')
|
||||||
|
.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTexts();
|
||||||
|
});
|
||||||
12
views/templates/home.php
Normal file
12
views/templates/home.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Daily Goals - Home</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Home</h1>
|
||||||
|
<ul id="texts-list">
|
||||||
|
</ul>
|
||||||
|
<script src="/js/home.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue