diff --git a/.gitignore b/.gitignore index fac6c7e..68bd285 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ vendor/ node_modules/ -data/ +data/*.json .direnv/ \ No newline at end of file diff --git a/cypress/e2e/admin.cy.js b/cypress/e2e/admin.cy.js index c06aece..5dca670 100644 --- a/cypress/e2e/admin.cy.js +++ b/cypress/e2e/admin.cy.js @@ -1,7 +1,11 @@ describe('The admin page', () => { beforeEach(() => { + cy.exec('npm run db:seed') cy.visit('/admin') }) + afterEach(() => { + cy.exec('npm run db:wipe') + }) it('navigates to texts page', () => { cy.get('#texts').click() diff --git a/data/seedDb.php b/data/seedDb.php new file mode 100644 index 0000000..d8d3698 --- /dev/null +++ b/data/seedDb.php @@ -0,0 +1,17 @@ + 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)); +} diff --git a/data/wipeDb.php b/data/wipeDb.php new file mode 100644 index 0000000..b180c35 --- /dev/null +++ b/data/wipeDb.php @@ -0,0 +1,11 @@ +