Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

add command to run supabase and app in e2e mode

ThieryMichel94246053ff11
diff --git a/.env.e2e b/.env.e2e
new file mode 100644
index 00000000..f659be34
--- /dev/null
+++ b/.env.e2e
@@ -0,0 +1,5 @@
+SKIP_PREFLIGHT_CHECK=true
+
+VITE_SUPABASE_URL=http://127.0.0.1:54341
+VITE_SB_PUBLISHABLE_KEY=sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH
+VITE_IS_DEMO=false
diff --git a/.gitignore b/.gitignore
index 218571ba..6094d0cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@ yarn-debug.log*
yarn-error.log*
supabase/.branches
supabase/.temp
+.supabase-e2e/
dist/
/lib/
diff --git a/e2e/example.spec.ts b/e2e/example.spec.ts
deleted file mode 100644
index 54a906a4..00000000
--- a/e2e/example.spec.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { test, expect } from '@playwright/test';
-
-test('has title', async ({ page }) => {
- await page.goto('https://playwright.dev/');
-
- // Expect a title "to contain" a substring.
- await expect(page).toHaveTitle(/Playwright/);
-});
-
-test('get started link', async ({ page }) => {
- await page.goto('https://playwright.dev/');
-
- // Click the get started link.
- await page.getByRole('link', { name: 'Get started' }).click();
-
- // Expects page to have a heading with the name of Installation.
- await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
-});
diff --git a/e2e/onboarding.spec.ts b/e2e/onboarding.spec.ts
new file mode 100644
index 00000000..1529bede
--- /dev/null
+++ b/e2e/onboarding.spec.ts
@@ -0,0 +1,8 @@
+import { test, expect } from "@playwright/test";
+
+test("user onboarding", async ({ page }) => {
+ await page.goto("http://localhost:5175/");
+
+ // Expect a title "to contain" a substring.
+ await expect(page).toHaveTitle(/Atomic CRM/);
+});
diff --git a/makefile b/makefile
index cffb5216..fbce808d 100644
--- a/makefile
+++ b/makefile
@@ -21,6 +21,12 @@ supabase-reset-database: ## reset (and clear!) the database
start-app: ## start the app locally
npm run dev
+start-app-e2e: ## start the app pointing to the e2e supabase instance
+ npx vite --force --mode e2e &
+
+stop-app-e2e:
+ kill $$(lsof -t -i:5175)
+
start: start-supabase start-app ## start the stack locally
start-demo: ## start the app locally in demo mode
@@ -31,6 +37,25 @@ stop-supabase: ## stop local supabase
stop: stop-supabase ## stop the stack locally
+start-supabase-e2e: ## start a separate supabase instance for e2e (fresh DB every run)
+ npx supabase stop --workdir .supabase-e2e --no-backup 2>/dev/null || true
+ rm -rf .supabase-e2e/supabase
+ mkdir -p .supabase-e2e/supabase
+ cp supabase/config.e2e.toml .supabase-e2e/supabase/config.toml
+ cp -r supabase/migrations .supabase-e2e/supabase/migrations
+ cp -r supabase/functions .supabase-e2e/supabase/functions
+ cp -r supabase/templates .supabase-e2e/supabase/templates
+ cp supabase/seed.sql .supabase-e2e/supabase/seed.sql
+ cp supabase/signing_keys.json .supabase-e2e/supabase/signing_keys.json
+ npx supabase start --workdir .supabase-e2e
+
+stop-supabase-e2e: ## stop the e2e supabase instance
+ npx supabase stop --workdir .supabase-e2e --no-backup
+
+start-e2e: start-supabase-e2e start-app-e2e ## start the stack in e2e mode (fresh supabase instance + app pointing to it)
+
+stop-e2e: stop-supabase-e2e stop-app-e2e ## stop the stack in e2e mode
+
build: ## build the app
npm run build
@@ -60,12 +85,9 @@ test-functions:
test-integration:
npm run test:integration
-test-e2e:
+test-e2e: start-e2e
npx playwright test --ui
-test-e2e-ci:
- CI=1 npx playwright test
-
lint:
npm run lint
npm run prettier
diff --git a/supabase/config.e2e.toml b/supabase/config.e2e.toml
new file mode 100644
index 00000000..3aee3a1b
--- /dev/null
+++ b/supabase/config.e2e.toml
@@ -0,0 +1,142 @@
+# Separate Supabase instance for e2e testing.
+# Uses a different project_id (separate Docker containers) and a shifted port
+# range (+20) so it can run in parallel with the regular dev instance.
+project_id = "atomic-crm-e2e"
+
+[api]
+enabled = true
+# Port to use for the API URL.
+port = 54341
+# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
+# endpoints. public and storage are always included.
+schemas = ["public", "storage", "graphql_public"]
+# Extra schemas to add to the search_path of every request. public is always included.
+extra_search_path = ["public", "extensions"]
+# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
+# for accidental or malicious requests.
+max_rows = 1000
+
+[db]
+# Port to use for the local database URL.
+port = 54342
+# Port used by db diff command to initialize the shadow database.
+shadow_port = 54340
+# The database major version to use. This has to be the same as your remote database's. Run `SHOW
+# server_version;` on the remote database to check.
+major_version = 15
+
+[db.pooler]
+enabled = false
+# Port to use for the local connection pooler.
+port = 54349
+# Specifies when a server connection can be reused by other clients.
+# Configure one of the supported pooler modes: `transaction`, `session`.
+pool_mode = "transaction"
+# How many server connections to allow per user/database pair.
+default_pool_size = 20
+# Maximum number of client connections allowed.
+max_client_conn = 100
+
+[realtime]
+enabled = true
+
+[studio]
+enabled = true
+# Port to use for Supabase Studio.
+port = 54343
+# External URL of the API server that frontend connects to.
+api_url = "http://127.0.0.1"
+
+[inbucket]
+enabled = true
+# Port to use for the email testing server web interface.
+port = 54344
+
+[storage]
+enabled = true
+# The maximum file size allowed (e.g. "5MB", "500KB").
+file_size_limit = "50MiB"
+
+[auth]
+enabled = true
+# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
+# in emails.
+site_url = "http://localhost:5173"
+# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
+additional_redirect_urls = ["https://localhost:5173/auth-callback.html"]
+# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).
+jwt_expiry = 3600
+# If disabled, the refresh token will never expire.
+enable_refresh_token_rotation = true
+# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds.
+# Requires enable_refresh_token_rotation = true.
+refresh_token_reuse_interval = 10
+# Allow/disallow new user signups to your project.
+enable_signup = true
+# Development signing keys
+signing_keys_path = "./signing_keys.json"
+
+[auth.email]
+# Allow/disallow new user signups via email to your project.
+enable_signup = true
+# If enabled, a user will be required to confirm any email change on both the old, and new email
+# addresses. If disabled, only the new email is required to confirm.
+double_confirm_changes = true
+# If enabled, users need to confirm their email address before signing in.
+enable_confirmations = false
+
+[auth.email.template.invite]
+subject = "You've been invited to Atomic CRM"
+content_path = "./supabase/templates/invite.html"
+
+[auth.email.template.recovery]
+subject = "Reset your Atomic CRM Password"
+content_path = "./supabase/templates/recovery.html"
+
+[auth.sms]
+# Allow/disallow new user signups via SMS to your project.
+enable_signup = true
+# If enabled, users need to confirm their phone number before signing in.
+enable_confirmations = false
+# Template for sending OTP to users
+template = "Your code is {{ .Code }} ."
+
+[auth.sms.test_otp]
+# 4152127777 = "123456"
+
+[auth.sms.twilio]
+enabled = false
+account_sid = ""
+message_service_sid = ""
+auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)"
+
+[auth.external.apple]
+enabled = false
+client_id = ""
+secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)"
+redirect_uri = ""
+url = ""
+
+[analytics]
+enabled = false
+port = 54347
+vector_port = 54348
+backend = "postgres"
+
+[experimental]
+orioledb_version = ""
+s3_host = "env(S3_HOST)"
+s3_region = "env(S3_REGION)"
+s3_access_key = "env(S3_ACCESS_KEY)"
+s3_secret_key = "env(S3_SECRET_KEY)"
+
+[functions.merge_contacts]
+verify_jwt = false
+[functions.delete_note_attachments]
+verify_jwt = false
+[functions.postmark]
+verify_jwt = false
+[functions.update_password]
+verify_jwt = false
+[functions.users]
+verify_jwt = false