diff --git a/app-playwright/playwright.config.ts b/app-playwright/playwright.config.ts index 76e96abe..857bfd3c 100644 --- a/app-playwright/playwright.config.ts +++ b/app-playwright/playwright.config.ts @@ -10,8 +10,8 @@ import { defineConfig, devices } from '@playwright/test' const isCI = Boolean(process.env.CI) const baseURL = isCI - ? 'http://localhost:3023' - : 'https://app.pentive.localhost:3023' + ? 'http://localhost:3043' + : 'https://app.pentive.localhost:3043' /** * See https://playwright.dev/docs/test-configuration. @@ -77,7 +77,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'pnpm run preview --port 3023', + command: 'pnpm previewTest', cwd: '../app', url: baseURL, ignoreHTTPSErrors: true, diff --git a/app/.example.env.test b/app/.example.env.test new file mode 100644 index 00000000..c8a7bf83 --- /dev/null +++ b/app/.example.env.test @@ -0,0 +1,8 @@ +VITE_CWA_URL=$VITE_TEST_CWA_URL +VITE_AUGC_URL=$VITE_TEST_AUGC_URL +VITE_APP_UGC_ORIGIN=$VITE_TEST_APP_UGC_ORIGIN +VITE_PEER_HOST=$VITE_DEVELOPMENT_PEER_HOST +VITE_PEER_PORT=$VITE_DEVELOPMENT_PEER_PORT +VITE_HUB_ORIGIN=$VITE_TEST_HUB_ORIGIN +VITE_AG_GRID_LICENSE=$VITE_DEVELOPMENT_AG_GRID_LICENSE +VITE_PEER_SYNC_PUBLIC_KEY="$developmentPeerSyncPublicKey" diff --git a/app/.gitignore b/app/.gitignore index 00306ac8..0c8ab59c 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,12 +1,14 @@ node_modules dev-dist dist +distTest lib /test-results/ /playwright-report/ /playwright/.cache/ .cert env.sh +.env.test .env.development .env.production src/assets/sql-wasm.wasm diff --git a/app/package.json b/app/package.json index 4517618a..3f020837 100644 --- a/app/package.json +++ b/app/package.json @@ -8,9 +8,11 @@ "dev": "vite", "deploy": "./deploy.sh", "build": "vite build", - "buildDev": "vite build --mode development # Run before `preview`", + "buildDev": "vite build --mode development # Run before `preview`", + "buildTest": "vite build --mode test --outDir distTest # Run before testing", "build-watch": "vite build --watch", - "preview": "vite preview --mode development", + "preview": "vite preview --mode development # This does NOT necessarily run with development env vars; it exists to enable HTTPS as per `vite.config.ts`", + "previewTest": "vite preview --mode test --outDir distTest --port 3043", "postinstall": "./postinstall.sh", "tsc-build": "tsc", "eslint": "eslint . --ignore-path .gitignore --max-warnings 0", diff --git a/app/vite.config.ts b/app/vite.config.ts index cc46dced..07dca77a 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig(({ mode }: UserConfig) => { const keyPath = './.cert/key.pem' const certPath = './.cert/cert.pem' let https - if (mode === 'development' && !isCI) { + if (mode !== 'production' && !isCI) { https = { key: fs.readFileSync(keyPath), cert: fs.readFileSync(certPath), diff --git a/design-decisions/example.pentive.secrets.sh b/design-decisions/example.pentive.secrets.sh index c75bd1a5..89457513 100644 --- a/design-decisions/example.pentive.secrets.sh +++ b/design-decisions/example.pentive.secrets.sh @@ -2,6 +2,7 @@ export developmentAlphaKey= export productionAlphaKey= export cloudflareAccountId= export developmentTursoDbUrl=http://127.0.0.1:3011 +export testTursoDbUrl=http://127.0.0.1:3041 export developmentTursoAuthToken='optional if running locally' export productionTursoDbUrl= export productionTursoAuthToken= @@ -58,6 +59,8 @@ baz export developmentAppOrigin=https://app.pentive.localhost:3013 export developmentHubOrigin=https://pentive.localhost:3014 +export testAppOrigin=https://app.pentive.localhost:3043 +export testHubOrigin=https://pentive.localhost:3044 # If you add any `VITE_PRODUCTION_*` or edit the below, also update `cicd.yml` export productionAppOrigin=https://app.pentive.com @@ -67,18 +70,25 @@ export VITE_PRODUCTION_AG_GRID_LICENSE= export VITE_DEVELOPMENT_HUB_DOMAIN=pentive.localhost export VITE_PRODUCTION_HUB_DOMAIN=hub.yourusernamehere.workers.dev export VITE_DEVELOPMENT_HUB_ORIGIN=https://pentive.localhost:3014 +export VITE_TEST_HUB_ORIGIN=https://pentive.localhost:3044 export VITE_PRODUCTION_HUB_ORIGIN=https://pentive.com export VITE_DEVELOPMENT_CWA_URL=https://cwa.pentive.localhost:3017/ +export VITE_TEST_CWA_URL=https://cwa.pentive.localhost:3047/ export VITE_PRODUCTION_CWA_URL=https://cwa.yourusernamehere.workers.dev/ export VITE_DEVELOPMENT_AUGC_URL=https://user-generated-content-pentive.localhost:3019/ +export VITE_TEST_AUGC_URL=https://user-generated-content-pentive.localhost:3049/ export VITE_PRODUCTION_AUGC_URL=https://user-generated-content-pentive.yourusernamehere.workers.dev/ export VITE_DEVELOPMENT_APP_ORIGIN=https://app.pentive.localhost:3013 +export VITE_TEST_APP_ORIGIN=https://app.pentive.localhost:3043 export VITE_PRODUCTION_APP_ORIGIN=https://app.yourusernamehere.workers.dev export VITE_DEVELOPMENT_HUB_UGC_ORIGIN=https://hub-user-generated-content-pentive.localhost:3016 +export VITE_TEST_HUB_UGC_ORIGIN=https://hub-user-generated-content-pentive.localhost:3046 export VITE_PRODUCTION_HUB_UGC_ORIGIN=https://hub-user-generated-content.yourusernamehere.workers.dev export VITE_DEVELOPMENT_APP_UGC_ORIGIN=https://app-user-generated-content-pentive.localhost:3015 +export VITE_TEST_APP_UGC_ORIGIN=https://app-user-generated-content-pentive.localhost:3045 export VITE_PRODUCTION_APP_UGC_ORIGIN=https://app-user-generated-content.yourusernamehere.workers.dev export VITE_DEVELOPMENT_PEER_HOST=peer.pentive.localhost export VITE_DEVELOPMENT_PEER_PORT="3018" +export VITE_TEST_PEER_PORT="3048" export VITE_PRODUCTION_PEER_HOST="0.peerjs.com" export VITE_PRODUCTION_PEER_PORT="443" diff --git a/mkenv.sh b/mkenv.sh index d49fbbc4..6d3f1b4b 100755 --- a/mkenv.sh +++ b/mkenv.sh @@ -49,5 +49,6 @@ envsubst < ./lrpc/.example.env > ./lrpc/.env envsubst < ./app-ugc/example.env.sh > ./app-ugc/env.sh envsubst < ./hub-ugc/example.env.sh > ./hub-ugc/env.sh envsubst < ./app/example.env.sh > ./app/env.sh +envsubst < ./app/.example.env.test > ./app/.env.test envsubst < ./app/.example.env.development > ./app/.env.development envsubst < ./app/.example.env.production > ./app/.env.production diff --git a/package.json b/package.json index 3b6d9e95..89cc4582 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "wrangler": "^3.81.0" }, "scripts": { - "kill": "kill-port 3011 3012 3013 3014 3015 3016 3017 3018 3019", + "kill": "kill-port 3011 3012 3013 3014 3015 3016 3017 3018 3019 3041 3042 3043 3044 3045 3046 3047 3048 3049", "//": "ugc and dev are distinct because you may frequently wish to restart `dev`, whereas `ugc` rarely changes", "ugc": "concurrently --kill-others -p \"[{name}]\" -n \"app-ugc,hub-ugc\" -c \"bgBlue.bold,bgMagenta.bold\" \"pnpm --filter app-ugc build --mode development && pnpm --filter app-ugc serve\" \"pnpm --filter hub-ugc build --mode development && pnpm --filter hub-ugc serve\"", "dev": "concurrently --kill-others -p \"[{name}]\" -n \"app,hub,cwa,peer,api-ugc\" -c \"bgBlue.bold,bgMagenta.bold,bgGreen.bold,bgWhiteBright.bold,bgCyan.bold\" \"pnpm --filter app dev\" \"pnpm --filter hub dev\" \"pnpm --filter cwa dev\" \"pnpm --filter peer dev\" \"pnpm --filter api-ugc dev\"", diff --git a/turbo.json b/turbo.json index 079ac0c2..707e88db 100644 --- a/turbo.json +++ b/turbo.json @@ -1,76 +1,88 @@ { - "$schema": "https://turbo.build/schema.json", - "tasks": { - "tsc-build": { - "dependsOn": [ - // Don't use "transit nodes"! https://turbo.build/repo/docs/core-concepts/package-and-task-graph#transit-nodes - // tsc-build, build, eslint, and check all require their parents' tsc-build runs to succeed. - "^tsc-build" - ], - "outputs": [ - "lib/**" - ] - }, - "eslint": { - "dependsOn": [ - // "By using typed linting in your config, you incur the performance penalty of asking TypeScript to do a build of your project before ESLint can do its linting" https://typescript-eslint.io/getting-started/typed-linting#how-is-performance - "tsc-build" - ] - }, - "hub#build": { - "dependsOn": [ - // I don't think hub's eslint and build can run concurrently. Without this we get an error in Github Actions like - // Error: ENOENT: no such file or directory, open '/home/runner/work/Pentive/Pentive/hub/app.config.timestamp_1725915755421.js' - "hub#eslint" - ], - "outputs": [ - "dist/**", - ".vinxi/**" - ] - }, - "check": { - "dependsOn": [ - "tsc-build" - ] - }, - "test": { - "cache": false, - "persistent": true - }, - "test:run": {}, - "shared-dom#test:run": { // grep AD3A801F-81D4-4C83-80A3-94ED10F05608 - "dependsOn": [ - "shared-dom#tsc-build" - ] - }, - "app-playwright#test:run": { - "dependsOn": [ - "app#build" - ] - }, - "deploy": { - "dependsOn": [ - "build" - ], - "env": [ - "CLOUDFLARE_ACCOUNT_ID", - "CLOUDFLARE_API_TOKEN" - ] - }, - "build": { - "dependsOn": [ - "tsc-build" - ], - "outputs": [ - "dist/**" - ], - "inputs": [ - "$TURBO_DEFAULT$", - ".env.development", - ".env.production", - ".env.production.local", - ".env" - ] - } - } + "$schema": "https://turbo.build/schema.json", + "tasks": { + "tsc-build": { + "dependsOn": [ + // Don't use "transit nodes"! https://turbo.build/repo/docs/core-concepts/package-and-task-graph#transit-nodes + // tsc-build, build, eslint, and check all require their parents' tsc-build runs to succeed. + "^tsc-build" + ], + "outputs": [ + "lib/**" + ] + }, + "eslint": { + "dependsOn": [ + // "By using typed linting in your config, you incur the performance penalty of asking TypeScript to do a build of your project before ESLint can do its linting" https://typescript-eslint.io/getting-started/typed-linting#how-is-performance + "tsc-build" + ] + }, + "hub#build": { + "dependsOn": [ + // I don't think hub's eslint and build can run concurrently. Without this we get an error in Github Actions like + // Error: ENOENT: no such file or directory, open '/home/runner/work/Pentive/Pentive/hub/app.config.timestamp_1725915755421.js' + "hub#eslint" + ], + "outputs": [ + "dist/**", + ".vinxi/**" + ] + }, + "check": { + "dependsOn": [ + "tsc-build" + ] + }, + "test": { + "cache": false, + "persistent": true + }, + "test:run": {}, + "shared-dom#test:run": { // grep AD3A801F-81D4-4C83-80A3-94ED10F05608 + "dependsOn": [ + "shared-dom#tsc-build" + ] + }, + "app-playwright#test:run": { + "dependsOn": [ + "app#buildTest" + ] + }, + "deploy": { + "dependsOn": [ + "build" + ], + "env": [ + "CLOUDFLARE_ACCOUNT_ID", + "CLOUDFLARE_API_TOKEN" + ] + }, + "build": { + "dependsOn": [ + "tsc-build" + ], + "outputs": [ + "dist/**" + ], + "inputs": [ + "$TURBO_DEFAULT$", + ".env.development", + ".env.production", + ".env.production.local", + ".env" + ] + }, + "buildTest": { + "dependsOn": [ + "tsc-build" + ], + "outputs": [ + "distTest/**" + ], + "inputs": [ + "$TURBO_DEFAULT$", + ".env.test" + ] + } + } } \ No newline at end of file