Repository navigation
test(ci): add Swift CoreTests, Node reader/sanitizer tests, and strict CI checks - #5
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds zero-dependency Swift and Node.js unit test suites, a unified
./scripts/test.shtest runner, and strict Swift concurrency checks in GitHub Actions CI.Changes
tests/CoreTests.swift(new): Standalone Swift test executable compiled directly againstCore.swiftwith-swift-version 5 -warn-concurrency -warnings-as-errors(140 assertions):normalizeURL: validhttp/https, bare domains, punycode TLDs,localhost+ port, IPv4/IPv6 literals, and rejection of typos, whitespace, invalid ports/IPs, and non-HTTP schemes (javascript:,file:,data:,mailto:,ftp:).parseLaunchURL: skips macOS defaults flag pairs (-AppleLanguages en,-NSDocumentRevisionsDebugMode YES,-psn_*,-k=v), handles--, and extracts valid URLs.isAllowedExternalURL: permitshttp/https/mailtoand blocksfile:,shortcuts:,smb:,ssh:,javascript:,data:,tel:, and empty-host/specifier URLs.matchesExpectedReaderURL: validatesabout:blank, exact/root-path/case-insensitive/fragment matches, and rejects mismatched scheme/host/port/path/query.readwiseEndpointURL,readwiseUpdateURL,readwiseReaderBaseURL: safe query encoding, percent-encodeddocID, and traversal/delimiter rejection (/,\\,..,?,#).slimDoc: preserves readable top-levelarticle/email/rssfields, dropsNSNulland extra fields, and rejects child docs and non-readable categories.jsonLiteral: escapes</script>, quotes/backslashes, and\u2028/\u2029line separators with round-trip verification.themeWindowAppearance: Paper (#fbf9f4), Sepia (#f3ead6), Dark (#161616), case-insensitivity, andnil/unknown fallback.tests/reader.test.mjs(new): Zero-dependencynode:test+node:assert/strictsuite (7 tests):vm.Script) forResources/extract.js,Resources/Readability.js, and the inline<script>inResources/reader.html.Resources/Readability.js@mozilla/readability v0.6.0header and executes_getJSONLDagainst a@graphJSON-LD document to verify the arrow-functionthis.REGEXPSfix.>= 4.5:1forfg,muted,link,errvs--bgand input surface;>= 3.0:1forborder).Resources/reader.htmlstructural & a11y invariants (overflow: clip,<main>,<article>,role="tablist",role="dialog",aria-live="polite",prefers-reduced-motion,twoup-end,window.twoupZoom,D.focusUrl,D.dir).sanitize()implementation fromResources/reader.htmlagainst XSS/clobbering/URL-smuggling vectors (<script>,#end/#statusIDs,<base>,<svg><a xlink:href>, control-charjavascript:,data:image/svg+xml,srcset) and verifies safehttps:,mailto:,#hash, resolved relative URLs, anddata:image/pngpreservation.Resources/extract.js(__twoupExtract) verifying#hashanchor preservation (both configurable and non-configurabledocumentURI), lazy<picture><source data-srcset>promotion + placeholder<img>fallback, anddir: "rtl"passthrough.scripts/test.sh(new, executable): Runsbash -n,shellcheck -S error(when installed),plutil -lint Info.plist, strict-warn-concurrency -warnings-as-errorstypechecks onCore.swift main.swiftandmake_icon.swift, compiles & runstests/CoreTests.swiftin amktempbinary cleaned up on exit, and runsnode --test tests/reader.test.mjs..github/workflows/ci.yml(updated): Runs./scripts/test.sh,./build.sh --build-only,codesign --verify --deep --strict build/TwoUp.app, and verifiesTwoUp.icns.No production files were modified.
Verification
./scripts/test.sh: passed (CoreTests: 140 passed, 0 failed;reader.test.mjs: 7 passed, 0 failed;shellcheck,plutil, strict Swift concurrency typechecks all clean)./build.sh --build-only && codesign --verify --deep --strict build/TwoUp.app && test -s build/TwoUp.app/Contents/Resources/TwoUp.icns: passed