Skip to content

Commit bb2575c

Browse files
GeekTrainerCopilot
andcommitted
Address Copilot code review feedback
- Remove redundant db.create_all() in seed_test_database.py (init_db already handles it) - Set reuseExistingServer: false for Flask to ensure test data is always seeded - Replace POSIX shell commands with cross-platform alternatives: - Add start-test-server.js Node script for Flask server launch - Use cross-env for Astro dev server env vars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f304509 commit bb2575c

File tree

5 files changed

+122
-6
lines changed

5 files changed

+122
-6
lines changed

app/client/package-lock.json

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"devDependencies": {
2424
"@playwright/test": "^1.59.1",
2525
"@types/node": "^25.6.0",
26+
"cross-env": "^10.1.0",
2627
"tailwindcss": "^4.2.2"
2728
}
2829
}

app/client/playwright.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export default defineConfig({
2727
],
2828
webServer: [
2929
{
30-
command: `cd ${serverDir} && python3 utils/seed_test_database.py && DATABASE_PATH=${testDbPath} python3 app.py`,
30+
command: `node start-test-server.js`,
3131
url: `http://localhost:${flaskPort}/api/dogs`,
32-
reuseExistingServer: !process.env.CI,
32+
reuseExistingServer: false,
3333
timeout: 30_000,
3434
},
3535
{
36-
command: `API_SERVER_URL=http://localhost:${flaskPort} npm run dev -- --no-clearScreen`,
36+
command: `npx cross-env API_SERVER_URL=http://localhost:${flaskPort} npm run dev -- --no-clearScreen`,
3737
url: `http://localhost:${astroDevPort}`,
3838
reuseExistingServer: !process.env.CI,
3939
timeout: 30_000,

app/client/start-test-server.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Cross-platform script to seed the test database and start the Flask server
2+
const { execSync, spawn } = require('child_process');
3+
const path = require('path');
4+
5+
const serverDir = path.resolve(__dirname, '..', 'server');
6+
const testDbPath = path.join(serverDir, 'e2e_test_dogshelter.db');
7+
8+
// Seed the test database
9+
execSync('python3 utils/seed_test_database.py', {
10+
cwd: serverDir,
11+
stdio: 'inherit',
12+
});
13+
14+
// Start Flask with the test database
15+
const server = spawn('python3', ['app.py'], {
16+
cwd: serverDir,
17+
env: { ...process.env, DATABASE_PATH: testDbPath },
18+
stdio: 'inherit',
19+
});
20+
21+
server.on('close', (code) => process.exit(code ?? 1));

app/server/utils/seed_test_database.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ def seed_test_database():
125125
init_db(app)
126126

127127
with app.app_context():
128-
# Create all tables
129-
db.create_all()
130-
131128
# Seed breeds
132129
breed_map = {}
133130
for breed_data in TEST_BREEDS:

0 commit comments

Comments
 (0)