From f9b22750dced97a974005593909077d09b1129b9 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 18:21:54 -0800 Subject: test: mock RSS feeds in E2E tests --- scripts/clean_test_env.sh | 3 ++- scripts/mock_feed.xml | 22 ++++++++++++++++++++++ scripts/run_e2e_safe.sh | 19 ++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 scripts/mock_feed.xml (limited to 'scripts') diff --git a/scripts/clean_test_env.sh b/scripts/clean_test_env.sh index 6edef41..f6b6867 100755 --- a/scripts/clean_test_env.sh +++ b/scripts/clean_test_env.sh @@ -10,9 +10,10 @@ pkill -x "neko_server" || true pkill -f "vite" || true pkill -f "playwright" || true -# Kill anything on ports 4994 and 5173 +# Kill anything on ports 4994 and 5173 and 9090 fuser -k 4994/tcp || true fuser -k 5173/tcp || true +fuser -k 9090/tcp || true # Remove test databases rm -f neko_test.db .data/test.db diff --git a/scripts/mock_feed.xml b/scripts/mock_feed.xml new file mode 100644 index 0000000..6bbe1c3 --- /dev/null +++ b/scripts/mock_feed.xml @@ -0,0 +1,22 @@ + + + + Mock Feed + http://localhost:9000/mock_feed.xml + A mock feed for testing purposes + + Mock Item 1 + http://localhost:9000/item1 + This is the first mock item. + Mon, 06 Sep 2024 16:45:00 +0000 + http://localhost:9000/item1 + + + Mock Item 2 + http://localhost:9000/item2 + This is the second mock item. + Mon, 06 Sep 2024 16:40:00 +0000 + http://localhost:9000/item2 + + + diff --git a/scripts/run_e2e_safe.sh b/scripts/run_e2e_safe.sh index a68e7be..a24455c 100755 --- a/scripts/run_e2e_safe.sh +++ b/scripts/run_e2e_safe.sh @@ -10,8 +10,22 @@ go build -o neko_server ./cmd/neko echo "Creating data directory..." mkdir -p .data +echo "Starting mock feed server on port 9090..." +python3 -m http.server 9090 --directory scripts > mock_server.log 2>&1 & +MOCK_PID=$! +echo "Mock Server PID: $MOCK_PID" + +# Verify mock server +sleep 2 +if ! curl -s --head http://localhost:9090/mock_feed.xml > /dev/null; then + echo "Mock server failed to start!" + cat mock_server.log + exit 1 +fi +echo "Mock server is up." + echo "Starting backend on port 4994..." -./neko_server --http=4994 --database=.data/test.db > backend.log 2>&1 & +./neko_server --verbose --allow-local --http=4994 --database=.data/test.db > backend.log 2>&1 & SERVER_PID=$! echo "Backend PID: $SERVER_PID" @@ -41,12 +55,15 @@ if npm run test:e2e; then EXIT_CODE=0 else echo "Tests failed!" + echo "Backend Logs:" + cat ../backend.log EXIT_CODE=1 fi cd .. echo "Cleaning up..." kill $SERVER_PID || true +kill $MOCK_PID || true scripts/clean_test_env.sh exit $EXIT_CODE -- cgit v1.2.3