From 7e674af40a26d745b0a803c90a11c4d91783fb99 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Wed, 15 Apr 2026 21:08:54 +0300 Subject: [PATCH 1/2] add seed and wipe commands for e2e tests --- cypress/e2e/admin.cy.js | 4 ++++ package.json | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) 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/package.json b/package.json index 352443a..b203020 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,9 @@ { "scripts": { "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": { "cypress": "^15.12.0" From 7ee4bac3fad3eecb34bda651645c78a488aab10f Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Wed, 15 Apr 2026 21:10:07 +0300 Subject: [PATCH 2/2] only ignore json files in data dir, tracking seed and wipe scripts --- .gitignore | 2 +- data/seedDb.php | 17 +++++++++++++++++ data/wipeDb.php | 11 +++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 data/seedDb.php create mode 100644 data/wipeDb.php 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/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 @@ +