aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-14 18:21:54 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-14 18:21:54 -0800
commitf9b22750dced97a974005593909077d09b1129b9 (patch)
tree63e0630ec23cab5f7b25d61ff5751d6e4d6230f0
parent1413eca1f1dfea2fe125a5dc9bde293058cc3e03 (diff)
downloadneko-f9b22750dced97a974005593909077d09b1129b9.tar.gz
neko-f9b22750dced97a974005593909077d09b1129b9.tar.bz2
neko-f9b22750dced97a974005593909077d09b1129b9.zip
test: mock RSS feeds in E2E tests
-rw-r--r--.gitignore1
-rw-r--r--.thicket/tickets.jsonl4
-rw-r--r--cmd/neko/main.go8
-rw-r--r--frontend/tests/e2e.spec.ts2
-rwxr-xr-xscripts/clean_test_env.sh3
-rw-r--r--scripts/mock_feed.xml22
-rwxr-xr-xscripts/run_e2e_safe.sh19
7 files changed, 55 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 798191b..7735a6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ frontend/playwright-report/
frontend/test-results/
frontend/coverage/
readme.html
+mock_server.log
diff --git a/.thicket/tickets.jsonl b/.thicket/tickets.jsonl
index d9386a0..6ef1606 100644
--- a/.thicket/tickets.jsonl
+++ b/.thicket/tickets.jsonl
@@ -38,6 +38,7 @@
{"id":"NK-bsdwqz","title":"terminal UI","description":"once there is good test coverage and a clean backend API, work on a nice efficient TUI with https://github.com/charmbracelet/bubbletea","type":"task","status":"closed","priority":1,"labels":null,"assignee":"","created":"2026-02-13T01:54:02.285738454Z","updated":"2026-02-13T04:42:09.824268427Z"}
{"id":"NK-ca9t70","title":"Vanilla JS: Add Feed UI","description":"Add UI to add a new feed by URL in vanilla JS prototype.","type":"feature","status":"closed","priority":2,"labels":null,"assignee":"","created":"2026-02-14T04:47:41.764330544Z","updated":"2026-02-14T04:47:41.764330544Z"}
{"id":"NK-chns2b","title":"reach parity between vanilla js and react v2 ui","description":"Continue implementing the vanilla js one with minimal overhad/depdnencies to be fast and lean. Make sure there are tests and rely on the v2 ui and legacy version as references.","type":"epic","status":"closed","priority":1,"labels":null,"assignee":"","created":"2026-02-14T04:45:06.813453353Z","updated":"2026-02-14T04:45:06.813453353Z"}
+{"id":"NK-ck4co9","title":"Refactor E2E tests to use page objects","description":"The E2E tests are getting complex. Refactor them to use the Page Object Model pattern for better maintainability.","type":"task","status":"open","priority":2,"labels":null,"assignee":"","created":"2026-02-15T02:21:34.96843041Z","updated":"2026-02-15T02:21:34.96843041Z"}
{"id":"NK-d4c8jv","title":"Vanilla JS Parity: Read/Star/Filter","description":"Implement read/unread toggle, star/unstar, and special filters (All, Unread, Starred) in vanilla JS prototype.","type":"feature","status":"closed","priority":1,"labels":null,"assignee":"","created":"2026-02-14T04:46:32.113504545Z","updated":"2026-02-14T04:47:46.412290355Z"}
{"id":"NK-dbcl6t","title":"Create Python Compliance Suite","description":"","type":"task","status":"closed","priority":2,"labels":null,"assignee":"","created":"2026-02-15T00:21:53.997204693Z","updated":"2026-02-15T00:44:41.52830766Z"}
{"id":"NK-doss0v","title":"v2 ui: change title fonts to Helvetica Neue","description":"to match style in legacy change font to match Helventic Neue where applicable","type":"bug","status":"closed","priority":0,"labels":null,"assignee":"","created":"2026-02-14T06:27:57.270935467Z","updated":"2026-02-14T06:31:42.798620609Z"}
@@ -72,7 +73,7 @@
{"id":"NK-m8bya7","title":"Fix and Re-enable Playwright E2E Tests","description":"E2E tests were crashing the VM and timing out. Disabled them in package.json. Need to investigate resource usage and re-enable.","type":"bug","status":"closed","priority":2,"labels":null,"assignee":"","created":"2026-02-14T03:08:18.501189975Z","updated":"2026-02-14T04:00:03.995357386Z"}
{"id":"NK-mbuw7q","title":"v2 ui bug - panel open by default","description":"Panel is closed by default, it should be open by default on desktop.","type":"bug","status":"closed","priority":0,"labels":null,"assignee":"","created":"2026-02-14T02:46:56.870671639Z","updated":"2026-02-14T03:08:17.322841854Z"}
{"id":"NK-mgmn5m","title":"serve \"legacy\" version UI at /v1/ instead of /","description":"Let's \"softly\" start to deprecated the legacy version by moving it to /v1/ -- ideally this won't require any changes but there may be some relative/absolute URLs to adjust in the static files there or in rouoting","type":"task","status":"closed","priority":0,"labels":null,"assignee":"","created":"2026-02-14T16:41:04.710679944Z","updated":"2026-02-14T17:38:25.35292336Z"}
-{"id":"NK-mpb1e1","title":"Mock RSS feeds in E2E tests","description":"Currently E2E tests fetch real feeds like CNN, which makes them slow (10s+) and potentially flaky depending on network. Use a local mock server or file-based mocks.","type":"task","status":"open","priority":1,"labels":null,"assignee":"","created":"2026-02-14T23:43:56.494457169Z","updated":"2026-02-14T23:43:56.494457169Z"}
+{"id":"NK-mpb1e1","title":"Mock RSS feeds in E2E tests","description":"Currently E2E tests fetch real feeds like CNN, which makes them slow (10s+) and potentially flaky depending on network. Use a local mock server or file-based mocks.","type":"task","status":"closed","priority":1,"labels":null,"assignee":"","created":"2026-02-14T23:43:56.494457169Z","updated":"2026-02-15T02:17:12.5439427Z"}
{"id":"NK-mwf9q2","title":"Implement Tag View","description":"Create frontend view for browsing items by tag/category. Use /tag/:id endpoint.","type":"","status":"closed","priority":2,"labels":null,"assignee":"","created":"2026-02-13T15:04:12.441165286Z","updated":"2026-02-13T18:04:38.644796168Z"}
{"id":"NK-n7nuyy","title":"Fix TypeScript Lint Errors in Tests","description":"There are lint errors in test files regarding jest-dom matchers (toBeInTheDocument, etc). Ensure proper types are included.","type":"bug","status":"closed","priority":3,"labels":null,"assignee":"","created":"2026-02-13T21:50:15.140702806Z","updated":"2026-02-13T21:50:15.140702806Z"}
{"id":"NK-nx8dhw","title":"fix github ci","description":"seems to be broken, are the right things still in there given all the refactorings","type":"bug","status":"closed","priority":1,"labels":null,"assignee":"","created":"2026-02-14T18:02:19.485418738Z","updated":"2026-02-14T18:08:16.790742187Z"}
@@ -130,6 +131,7 @@
{"id":"NK-dgbrb79","from_ticket_id":"NK-9hx0y7","to_ticket_id":"NK-t0nmbj","type":"created_from","created":"2026-02-13T05:44:01.556027956Z"}
{"id":"NK-dgfppki","from_ticket_id":"NK-gqkh96","to_ticket_id":"NK-x924bu","type":"created_from","created":"2026-02-13T03:54:30.303602703Z"}
{"id":"NK-dgu0o9d","from_ticket_id":"NK-ca9t70","to_ticket_id":"NK-d4c8jv","type":"created_from","created":"2026-02-14T04:47:41.786634182Z"}
+{"id":"NK-dikvat5","from_ticket_id":"NK-ck4co9","to_ticket_id":"NK-mpb1e1","type":"created_from","created":"2026-02-15T02:21:35.000829694Z"}
{"id":"NK-dj3r998","from_ticket_id":"NK-thq2oq","to_ticket_id":"NK-9pgjph","type":"created_from","created":"2026-02-14T03:30:58.76860979Z"}
{"id":"NK-dk4vq5o","from_ticket_id":"NK-uy90he","to_ticket_id":"NK-mwf9q2","type":"created_from","created":"2026-02-13T18:05:17.305248863Z"}
{"id":"NK-dkhu8ov","from_ticket_id":"NK-mwf9q2","to_ticket_id":"NK-0ppv3f","type":"created_from","created":"2026-02-13T15:04:12.449401674Z"}
diff --git a/cmd/neko/main.go b/cmd/neko/main.go
index 106a22e..333e5ce 100644
--- a/cmd/neko/main.go
+++ b/cmd/neko/main.go
@@ -13,6 +13,7 @@ import (
"flag"
+ "adammathes.com/neko/internal/safehttp"
"adammathes.com/neko/internal/vlog"
"adammathes.com/neko/web"
)
@@ -71,6 +72,9 @@ func Run(args []string) error {
f.StringVar(&password, "password", "", "password for web interface")
f.StringVar(&password, "p", "", "password for web interface (short)")
+ var allowLocal bool
+ f.BoolVar(&allowLocal, "allow-local", false, "allow connections to local network addresses")
+
f.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
f.PrintDefaults()
@@ -85,6 +89,10 @@ func Run(args []string) error {
f.Usage()
return nil
}
+
+ if allowLocal {
+ safehttp.AllowLocal = true
+ }
// reads config if present and sets defaults
if err := config.Init(configFile); err != nil {
return fmt.Errorf("config error: %v", err)
diff --git a/frontend/tests/e2e.spec.ts b/frontend/tests/e2e.spec.ts
index 1fa10ce..2bdf478 100644
--- a/frontend/tests/e2e.spec.ts
+++ b/frontend/tests/e2e.spec.ts
@@ -25,7 +25,7 @@ test.describe('Neko Reader E2E', () => {
await expect(page).toHaveURL(/.*\/v2\/settings/);
// Add a feed
- const feedUrl = 'http://rss.cnn.com/rss/cnn_topstories.rss';
+ const feedUrl = 'http://localhost:9090/mock_feed.xml';
await page.fill('input[type="url"]', feedUrl);
await page.click('text=Add Feed');
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 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<rss version="2.0">
+<channel>
+ <title>Mock Feed</title>
+ <link>http://localhost:9000/mock_feed.xml</link>
+ <description>A mock feed for testing purposes</description>
+ <item>
+ <title>Mock Item 1</title>
+ <link>http://localhost:9000/item1</link>
+ <description>This is the first mock item.</description>
+ <pubDate>Mon, 06 Sep 2024 16:45:00 +0000</pubDate>
+ <guid>http://localhost:9000/item1</guid>
+ </item>
+ <item>
+ <title>Mock Item 2</title>
+ <link>http://localhost:9000/item2</link>
+ <description>This is the second mock item.</description>
+ <pubDate>Mon, 06 Sep 2024 16:40:00 +0000</pubDate>
+ <guid>http://localhost:9000/item2</guid>
+ </item>
+</channel>
+</rss>
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