From 37a02d6f5a2d0c1cbac598a8d42dfc1578d862bc Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Tue, 21 Apr 2026 07:46:16 -0700 Subject: [PATCH] fix(e2e): derive tenant domain from CP URL (staging vs prod) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous hardcode `$SLUG.moleculesai.app` only matched prod. Staging tenants live at `$SLUG.staging.moleculesai.app`, so the harness hit DNS for a nonexistent host and timed out at section 4 even after provisioning succeeded. Derive from CP URL: api.X → X, staging-api.X → staging.X. Override via MOLECULE_TENANT_DOMAIN for self-hosted setups. Confirmed gap on manual run 2026-04-21T14:40Z: section 2 passed in 2min but section 4 timed out at 3min on the wrong hostname. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/e2e/test_staging_full_saas.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/e2e/test_staging_full_saas.sh b/tests/e2e/test_staging_full_saas.sh index 77b6f915..619e9839 100755 --- a/tests/e2e/test_staging_full_saas.sh +++ b/tests/e2e/test_staging_full_saas.sh @@ -168,7 +168,18 @@ print('') done ok "Tenant provisioning complete" -TENANT_URL="https://$SLUG.moleculesai.app" +# Derive tenant domain from CP hostname so the same harness works in +# both prod (api.moleculesai.app → moleculesai.app) and staging +# (staging-api.moleculesai.app → staging.moleculesai.app). Override +# via MOLECULE_TENANT_DOMAIN for local/self-hosted. +CP_HOST=$(echo "$CP_URL" | sed -E 's#^https?://##; s#/.*$##') +case "$CP_HOST" in + api.*) DERIVED_DOMAIN="${CP_HOST#api.}" ;; + staging-api.*) DERIVED_DOMAIN="staging.${CP_HOST#staging-api.}" ;; + *) DERIVED_DOMAIN="$CP_HOST" ;; +esac +TENANT_DOMAIN="${MOLECULE_TENANT_DOMAIN:-$DERIVED_DOMAIN}" +TENANT_URL="https://$SLUG.$TENANT_DOMAIN" log " TENANT_URL=$TENANT_URL" # ─── 3. Retrieve per-tenant admin token ────────────────────────────────