Compare commits

...

2 commits

5 changed files with 36 additions and 2 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
vendor/ vendor/
node_modules/ node_modules/
data/ data/*.json
.direnv/ .direnv/

View file

@ -1,7 +1,11 @@
describe('The admin page', () => { describe('The admin page', () => {
beforeEach(() => { beforeEach(() => {
cy.exec('npm run db:seed')
cy.visit('/admin') cy.visit('/admin')
}) })
afterEach(() => {
cy.exec('npm run db:wipe')
})
it('navigates to texts page', () => { it('navigates to texts page', () => {
cy.get('#texts').click() cy.get('#texts').click()

17
data/seedDb.php Normal file
View file

@ -0,0 +1,17 @@
<?php
$texts = [
[
'id' => 0,
'name' => 'test text'
],
];
$fileDataMap = [
'texts.json' => $texts,
];
foreach ($fileDataMap as $file => $data) {
$path = __DIR__."/$file";
file_put_contents($path, json_encode($data, JSON_PRETTY_PRINT));
}

11
data/wipeDb.php Normal file
View file

@ -0,0 +1,11 @@
<?php
$files = [
'texts.json',
];
foreach ($files as $file) {
echo __DIR__."/$file";
$path = __DIR__."/$file";
file_put_contents($path, json_encode([], JSON_PRETTY_PRINT));
}

View file

@ -1,7 +1,9 @@
{ {
"scripts": { "scripts": {
"cypress:dev": "cypress open", "cypress:dev": "cypress open",
"cypress:run": "cypress run" "cypress:run": "cypress run",
"db:seed": "php data/seedDb.php",
"db:wipe": "php data/wipeDb.php"
}, },
"devDependencies": { "devDependencies": {
"cypress": "^15.12.0" "cypress": "^15.12.0"