You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A friendly playground for building and validating Supabase Row-Level Security (RLS) using LaunchQL. It includes real-world examples, migrations, and a comprehensive test suite you can run locally.
14
15
15
-
A friendly playground for building and validating Supabase Row‑Level Security (RLS) using LaunchQL. It includes real‑world examples, migrations, and a comprehensive test suite you can run locally.
16
-
17
-
Built with [supabase-test](https://www.npmjs.com/package/supabase-test) — a Supabase‑optimized version of `pgsql-test` for instant, isolated Postgres test databases with automatic rollbacks and Supabase defaults. See the package for install and features.
16
+
Built with [supabase-test](https://www.npmjs.com/package/supabase-test) — a Supabase-optimized version of `pgsql-test` for instant, isolated Postgres test databases with automatic rollbacks and Supabase defaults.
18
17
19
18
## Features
20
19
21
-
- 🔐 RLS policy‑driven example tests with example product database using Supabase users
22
-
- 🧪 Comprehensive end‑to‑end test suite against native Supabase schemas/tables (auth, storage, functions, realtime, and more)
23
-
- 🐘 Supabase CLI local stack for zero‑setup Postgres
24
-
-🧪 Jest‑based tests that exercise RLS behavior end‑to‑end
25
-
- 🚀 GitHub Actions workflows to run integration/e2e tests in CI/CD
26
-
- 🧩 Modular schema packages you can reuse and extend
20
+
- 🔐 **RLS Policy Testing** - Real-world examples with users and products tables
21
+
- 🧪 **Comprehensive Test Suite** - End-to-end tests against native Supabase schemas
22
+
- 🐘 **Zero-Setup Postgres** - Supabase CLI local stack for instant development
23
+
-⚡ **Jest Integration** - Fast, isolated tests with automatic rollbacks
2. initialize supabase and confirm services are healthy
49
-
3. configure pg env vars if your shell needs them
50
-
4. run migrations or package deploys as needed
51
-
5. run tests (full suite and targeted)
52
-
6. inspect policies and iterate
53
-
54
-
for the expanded guide with screenshots and copy‑paste commands, see `docs/img/USAGE.md` (coming soon).
42
+
## Repository Structure
55
43
56
-
## repository layout
44
+
This is a LaunchQL workspace combining `pnpm` and `lql` for modular Postgres packages:
57
45
58
-
The repository is a launchql workspace, which is a hybrid `pnpm`/`lql` workspace, which allows for modular postgres packages, that can be easily tested via `pgsql-test`, or in the case of this repository, `supabase-test`. Here are the packages of interest:
46
+
-**`packages/supabase`** - Supabase-focused SQL, tests, and helpers
47
+
-**`packages/rls-demo`** - Demo extension showcasing RLS with users/products
59
48
60
-
-`packages/supabase`: supabase‑focused sql, tests, and helpers
61
-
-`packages/rls-demo`: demo extension showcasing rls with users/products
49
+
## Testing
62
50
63
-
## testing
64
-
65
-
If you want to see how to run tests in each of the relevant packages, here are handy snippets you may want to learn:
51
+
Run tests in different modes:
66
52
67
53
```bash
68
-
# rls-demo: run tests in watch mode
54
+
# Run all tests from root
55
+
pnpm test
56
+
57
+
# Watch mode for specific package
69
58
cd packages/rls-demo
70
59
pnpm test:watch
71
60
72
-
# edit tests in packages/rls-demo/__tests__/... and Jest will re-run
73
-
```
74
-
75
-
```bash
76
-
# supabase: run tests in watch mode
61
+
# Run Supabase package tests
77
62
cd packages/supabase
78
63
pnpm test:watch
79
64
```
80
65
81
-
```bash
82
-
# run all packages’ tests from the repo root
83
-
pnpm test
84
-
```
85
-
86
-
## Adding a package using `lql`
87
-
88
-
-[ ] TODO
89
-
90
66
## Requirements
91
67
92
68
- Node.js 20+
93
69
- pnpm 10+
94
70
- Supabase CLI 2+
95
71
96
-
## troubleshooting
72
+
## Troubleshooting
97
73
98
-
- if your environment needs explicit pg variables, export and retry:
74
+
If you encounter connection issues, set your environment variables:
99
75
100
76
```bash
101
77
export PGPORT=54322
@@ -104,9 +80,10 @@ export PGUSER=postgres
104
80
export PGPASSWORD=postgres
105
81
```
106
82
107
-
- if `pnpm test` can’t reach postgres, confirm supabase services are running and the `PG*` env vars match the port printed by `npx supabase start`
108
-
- if ports are busy, stop old containers or pass a different port to supabase
109
-
- node version mismatches can cause odd errors; use node 20+
83
+
Common issues:
84
+
- Ensure Supabase services are running (`npx supabase status`)
85
+
- Check that ports match those shown by `npx supabase start`
86
+
- Use Node.js 20+ to avoid compatibility issues
110
87
111
88
## Related LaunchQL Tooling
112
89
@@ -117,4 +94,4 @@ export PGPASSWORD=postgres
117
94
118
95
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
119
96
120
-
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
97
+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
-**user_profiles** table with RLS policies for user data access
26
+
-**products** table with RLS policies for product ownership
27
+
- Proper foreign key constraints and indexes
29
28
30
-
### Using SQL File
31
-
```bash
32
-
psql -d your_database -f seed-data.sql
33
-
```
29
+
## Quick Start
34
30
35
-
### Using Node.js Script
36
31
```bash
37
-
node insert-data.js
32
+
# Run tests
33
+
pnpm test
34
+
35
+
# Watch mode for development
36
+
pnpm test:watch
38
37
```
39
38
40
-
### Using pgsql-test
41
-
The test suite includes comprehensive data insertion and RLS testing examples.
39
+
## Disclaimer
40
+
41
+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
42
+
43
+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
0 commit comments