Title: test: add automated test suite (Vitest) for the SQL import/render pipeline by albertoarena · Pull Request #8 · stackrender/stackrender · GitHub
Open Graph Title: test: add automated test suite (Vitest) for the SQL import/render pipeline by albertoarena · Pull Request #8 · stackrender/stackrender
X Title: test: add automated test suite (Vitest) for the SQL import/render pipeline by albertoarena · Pull Request #8 · stackrender/stackrender
Description: What Adds the first automated test suite to StackRender. There is currently no test runner, no test script and no CI, so this lands the harness plus a meaningful suite covering the core SQL import/export pipeline across all six dialects. 88 tests, all green (npm test). One commit per phase for easy review. Why The SQL import and render code is pure, dialect-heavy and the most bug-prone part of the app. It is also the cheapest to test (no DOM, no WASM SQLite, no PowerSync). This suite locks in current behavior and gives a safety net for future dialect work. Tooling Vitest 2.x (matches Vite 5), near-zero config. Standalone vitest.config.ts (node environment, vite-tsconfig-paths for the @/ alias). It does not reuse the app Vite config, so the Tailwind/React/WASM plugins are not pulled into pure-logic tests. New scripts: test (vitest run) and test:watch. What is covered Phase 1, pure helpers: getNextSequence / cloneField, the charset/collation and SQLite integer-column reordering plus enum naming in render-uttils.ts, and orderTables including the CircularDependencyError cycle path behind the Foreign Key Cycle Detection feature. Phase 2, SQL import: getImporter().parseSql for MySQL, MariaDB, PostgreSQL, SQLite, Oracle and SQL Server. Representative CREATE TABLE + foreign key + index fixtures assert table/column counts, primary key, NOT NULL, UNIQUE, DEFAULT, type mapping and the captured foreign key. Also parses the bundled PostgreSQL dump and checks malformed input surfaces errors without dropping valid tables. Phase 3, SQL render: getRenderer().renderDDL for all six dialects from a shared DatabaseType fixture, asserting the emitted DDL creates both tables and carries the primary key, unique constraint, dialect-specific auto-increment spelling (AUTO_INCREMENT / SERIAL / AUTOINCREMENT / IDENTITY), length-carrying text type, DEFAULT and the foreign key with ON DELETE CASCADE. Phase 4, round-trip: parse DDL to model, render it back, parse again and assert the two models are equal (normalized on names, resolved types, key/constraint flags and relationships, not raw SQL). This is the strongest integration check of the pipeline. Data-type fixtures are built from the seed arrays via the same transform the app uses in seedDataTypes, so tests run without booting the WASM SQLite database. Notes for reviewers The parser (@guanmingchiu/sqlparser-ts) init() is async and the importer constructor does not await it (correct in the browser, where it resolves before any import). The suite awaits init() once in beforeAll. The round-trip canonicalizes primary keys to non-nullable in its comparison. SQL Server renders the primary key as a table-level constraint, and the importer only forces NOT NULL for inline primary keys, so the flag would otherwise differ on the round trip although the schemas are equivalent. This looks like a small importer asymmetry worth a follow-up. CI (.github/workflows/ci.yml) runs npm ci + npm test on pushes to main and on pull requests. Typecheck and lint are intentionally left out for now: the current codebase does not pass a strict project typecheck or a clean lint, so gating on them would fail CI on pre-existing, unrelated issues. Happy to add them in a separate cleanup PR. Verifying npm install npm test
Open Graph Description: What Adds the first automated test suite to StackRender. There is currently no test runner, no test script and no CI, so this lands the harness plus a meaningful suite covering the core SQL import/...
X Description: What Adds the first automated test suite to StackRender. There is currently no test runner, no test script and no CI, so this lands the harness plus a meaningful suite covering the core SQL import/...
Opengraph URL: https://github.com/stackrender/stackrender/pull/8
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f1931476-8cf4-c016-407f-4db6ed013ab6 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C69E:2ADD62:12A6D5F:17CCCCB:6B02FB31 |
| html-safe-nonce | d0b1687562eba470eb14e5b961b50f175115267197b31c4195f187bdb0ebf8a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjlFOjJBREQ2MjoxMkE2RDVGOjE3Q0NDQ0I6NkIwMkZCMzEiLCJ2aXNpdG9yX2lkIjoiODgxNjA5MDQzMDM4ODIzOTE1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2a36ed91c2786105fa3f0a5d867a8b7424462e77f548993077af3f88024d245a |
| hovercard-subject-tag | pull_request:4209733305 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/stackrender/stackrender/pull/8/files |
| twitter:image | https://avatars.githubusercontent.com/u/1126630?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1126630?s=400&v=4 |
| og:image:alt | What Adds the first automated test suite to StackRender. There is currently no test runner, no test script and no CI, so this lands the harness plus a meaningful suite covering the core SQL import/... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/stackrender/stackrender git https://github.com/stackrender/stackrender.git |
| octolytics-dimension-user_id | 226551349 |
| octolytics-dimension-user_login | stackrender |
| octolytics-dimension-repository_id | 977671574 |
| octolytics-dimension-repository_nwo | stackrender/stackrender |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 977671574 |
| octolytics-dimension-repository_network_root_nwo | stackrender/stackrender |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width