From 701e0e8e919d2929ecc98b555e468bd29bf606cf Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 15:44:02 -0800 Subject: Cleanup root directory by moving scripts to scripts/ and fix CSRF cookie policy for dev env --- scripts/clean_test_env.sh | 20 +++++++++++++ scripts/run_e2e.sh | 47 +++++++++++++++++++++++++++++++ scripts/run_e2e_safe.sh | 52 ++++++++++++++++++++++++++++++++++ scripts/sqlite.init.sql | 46 ++++++++++++++++++++++++++++++ scripts/test_feeds.txt | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 237 insertions(+) create mode 100755 scripts/clean_test_env.sh create mode 100755 scripts/run_e2e.sh create mode 100755 scripts/run_e2e_safe.sh create mode 100644 scripts/sqlite.init.sql create mode 100644 scripts/test_feeds.txt (limited to 'scripts') diff --git a/scripts/clean_test_env.sh b/scripts/clean_test_env.sh new file mode 100755 index 0000000..6edef41 --- /dev/null +++ b/scripts/clean_test_env.sh @@ -0,0 +1,20 @@ +#!/bin/bash +echo "Cleaning up test environment..." + +# Kill neko backend binary if running +pkill -x "neko" || true +pkill -x "neko_server" || true + +# Kill specific node processes related to vite/playwright +# We avoid pkill -f node to not kill the agent connection +pkill -f "vite" || true +pkill -f "playwright" || true + +# Kill anything on ports 4994 and 5173 +fuser -k 4994/tcp || true +fuser -k 5173/tcp || true + +# Remove test databases +rm -f neko_test.db .data/test.db + +echo "Cleanup complete." diff --git a/scripts/run_e2e.sh b/scripts/run_e2e.sh new file mode 100755 index 0000000..12d5f90 --- /dev/null +++ b/scripts/run_e2e.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# Cleanup function to kill the neko process and remove the test db +cleanup() { + echo "Cleaning up..." + if [ -n "$NEKO_PID" ]; then + kill $NEKO_PID 2>/dev/null || true + fi + rm -f neko_test.db +} + +# Register cleanup to run on exit +trap cleanup EXIT + +echo "Building neko..." +go build -o neko ./cmd/neko + +echo "Starting neko backend on port 4994..." +./neko -d neko_test.db -s 4994 > /dev/null 2>&1 & +NEKO_PID=$! + +echo "Waiting for backend to start..." +# simple wait loop +for i in {1..10}; do + if nc -z localhost 4994; then + echo "Backend is up!" + break + fi + sleep 1 +done + +echo "Running Playwright tests..." +cd frontend +# Ensure we use the correct credentials/config if needed by the tests +# The tests currently hardcode /v2/login but don't seem to have the password hardcoded in the fill step yet? +# Looking at e2e.spec.ts: await page.fill('#password', ''); - it fills empty string? +# usage of 'secret' matches nothing in the test. +# Let's check e2e.spec.ts again to match expectations exactly. +# In e2e.spec.ts: await page.fill('#password', ''); +# It implies it expects no password or ignores it? +# Or maybe the previous test run failed because of this too. +# I will set a simple password 'secret' and we might need to update the test to use it. +# Actually, let's look at the test content again. + +npm run test:e2e +cd .. diff --git a/scripts/run_e2e_safe.sh b/scripts/run_e2e_safe.sh new file mode 100755 index 0000000..a68e7be --- /dev/null +++ b/scripts/run_e2e_safe.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -e + +# Cleanup first +scripts/clean_test_env.sh + +echo "Building backend..." +go build -o neko_server ./cmd/neko + +echo "Creating data directory..." +mkdir -p .data + +echo "Starting backend on port 4994..." +./neko_server --http=4994 --database=.data/test.db > backend.log 2>&1 & +SERVER_PID=$! + +echo "Backend PID: $SERVER_PID" + +# Wait for server to be ready +echo "Waiting for backend to start..." +for i in {1..30}; do + if nc -z localhost 4994; then + echo "Backend is up!" + break + fi + echo "Waiting..." + sleep 1 +done + +if ! nc -z localhost 4994; then + echo "Backend failed to start. Check backend.log" + cat backend.log + kill $SERVER_PID || true + exit 1 +fi + +echo "Running E2E tests..." +cd frontend +if npm run test:e2e; then + echo "Tests passed!" + EXIT_CODE=0 +else + echo "Tests failed!" + EXIT_CODE=1 +fi +cd .. + +echo "Cleaning up..." +kill $SERVER_PID || true +scripts/clean_test_env.sh + +exit $EXIT_CODE diff --git a/scripts/sqlite.init.sql b/scripts/sqlite.init.sql new file mode 100644 index 0000000..8992483 --- /dev/null +++ b/scripts/sqlite.init.sql @@ -0,0 +1,46 @@ +CREATE TABLE feed ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + url varchar(100) NOT NULL UNIQUE, + web_url varchar(255) NOT NULL DEFAULT '', + title varchar(255) NOT NULL DEFAULT '', + last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + category varchar(255) NOT NULL DEFAULT 'uncategorized' +); +CREATE INDEX feed_url ON feed (url); +CREATE INDEX feed_category ON feed (category); + +CREATE TABLE item ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + feed_id int(11) NOT NULL, + title text NOT NULL DEFAULT '', + url varchar(255) NOT NULL UNIQUE, + description text NOT NULL DEFAULT '', + publish_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + read_state tinyint(1) NOT NULL DEFAULT '0', + starred tinyint(1) NOT NULL DEFAULT '0', + full_content text NOT NULL DEFAULT '', + header_image text NOT NULL DEFAULT '', + CONSTRAINT item_ibfk_1 FOREIGN KEY (feed_id) REFERENCES feed(id) ON DELETE CASCADE +); +CREATE INDEX item_url ON item (url); +CREATE INDEX item_publish_date ON item (publish_date); +CREATE INDEX item_feed_id ON item (feed_id); +CREATE INDEX item_read_state ON item (read_state); + +CREATE VIRTUAL TABLE fts_item using fts4(content="item", title, url, description); + +INSERT INTO fts_item(fts_item) VALUES('rebuild'); + + +CREATE TRIGGER item_bu BEFORE UPDATE ON item BEGIN + DELETE FROM fts_item WHERE docid=old.rowid; +END; +CREATE TRIGGER item_bd BEFORE DELETE ON item BEGIN + DELETE FROM fts_item WHERE docid=old.rowid; +END; +CREATE TRIGGER item_au AFTER UPDATE ON item BEGIN + INSERT INTO fts_item(docid, title, url, description) VALUES(new.rowid, new.title, new.url, new.description); +END; +CREATE TRIGGER item_ai AFTER INSERT ON item BEGIN + INSERT INTO fts_item(docid, title, url, description) VALUES(new.rowid, new.title, new.url, new.description); +END; diff --git a/scripts/test_feeds.txt b/scripts/test_feeds.txt new file mode 100644 index 0000000..942a12c --- /dev/null +++ b/scripts/test_feeds.txt @@ -0,0 +1,72 @@ +ttps://a.wholelottanothing.org/feed/ +http://feeds.feedburner.com/eod_full +https://www.analogue.co/feed/all +http://torrez.org/feed.xml +https://annas-blog.org/rss.xml +http://ascii.textfiles.com/feed/atom +https://begriffs.com/atom.xml +http://ilovebenbrown.com/rss +http://bitcannon.net/index.xml +http://feeds.feedburner.com/bricoleur +https://www.bump.net/feed/ +http://www.bytecellar.com/feed/ +http://www.antipope.org/charlie/blog-static/atom.xml +https://computer.rip/rss.xml +http://www.coryarcangel.com/feed/atom/ +http://forums.court-records.net/news/rss.php +https://craigmod.com/index.xml +https://danluu.com/atom.xml +https://lemire.me/blog/feed/ +http://www.spinellis.gr/blog/dds-blog-rss.xml +http://dreamandfriends.com/feed/ +http://sircmpwn.github.io/feed.xml +http://everybodyslibraries.com/feed/ +https://benbrown.com/feed.xml +http://www.tedunangst.com/flak/rss +https://fronkonstin.com/feed/ +http://www.ftrain.com/xml/feed/rss.xml +http://www.hardcoregaming101.net/feed/ +https://ln.hixie.ch/rss/html +http://www.cringely.com/feed/ +https://writing.markchristian.org/feed.xml +http://idlewords.com/index.xml +http://imperialviolet.org/iv-rss.xml +http://insertcredit.com/feed/ +http://interconnected.org/home/;rss2 +http://www.jessyoko.com/blog/feed/ +http://www.jnd.org/index.xml +http://www.jonas-kyratzes.net/feed/ +https://jcs.org/rss/notaweblog/ +https://www.jwz.org/blog/feed/ +http://feeds.kottke.org/main +http://www.timemachinego.com/linkmachinego/feed/ +http://lostlevels.org/wordpress/?feed=rss2 +http://motd.co/feed/ +https://nadia.xyz/feed.xml +http://nerdlypleasures.blogspot.com/feeds/posts/default +http://www.wadjeteyegames.com/category/news/feed +http://nullprogram.com/feed/ +https://www.tbray.org/ongoing/ongoing.atom +http://undeadly.org/cgi?action=rss +http://blogs.law.harvard.edu/philg/xml/rss.xml +https://ploum.net/atom_en.xml +https://randomfoo.net/feed +https://www.raphkoster.com/feed/ +http://ribbonblack.blogspot.com/rss.xml +https://www.schneier.com/blog/atom.xml +http://joeyh.name/blog/index.rss +http://blog.fogus.me/feed/ +https://simonwillison.net/atom/everything/ +https://www.smoothterminal.com/feed +https://www.sonyaellenmann.com/feed +http://feeds2.feedburner.com/stevelosh +https://www.filfre.net/feed/rss/ +https://obscuritory.com/feed/ +http://dtrace.org/blogs/bmc/feed/rss/ +http://www.trenchant.org/rss.xml +http://chneukirchen.org/trivium/index.atom +https://gamehistory.org/feed/ +https://virtuallyfun.com/feed/ +http://waxy.org/links/index.xml +http://negativesmart.com/wp-rss2.php +https://zed.dev/blog.rss -- cgit v1.2.3