fix: route production IM API correctly
Deploy im-webapp production / deploy (push) Successful in 42s

This commit is contained in:
Your Name
2026-10-19 11:05:50 +08:00
parent d2b4cb0440
commit d7bfd2f417
5 changed files with 31 additions and 1 deletions
+17
View File
@@ -3,12 +3,16 @@ import unittest
WORKFLOW = Path(__file__).resolve().parents[1] / ".gitea/workflows/deploy.yml"
DOCKERFILE = Path(__file__).resolve().parents[1] / "Dockerfile"
API_CLIENT = Path(__file__).resolve().parents[1] / "web/src/lib/api/client.ts"
class DeployWorkflowContractTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.workflow = WORKFLOW.read_text(encoding="utf-8")
cls.dockerfile = DOCKERFILE.read_text(encoding="utf-8")
cls.api_client = API_CLIENT.read_text(encoding="utf-8")
def test_targets_pro_branch_and_single_runner(self):
self.assertIn("push:", self.workflow)
@@ -35,8 +39,21 @@ class DeployWorkflowContractTest(unittest.TestCase):
self.assertNotIn("git.118im.com", self.workflow)
def test_uses_production_im_endpoint(self):
self.assertIn('TINODE_API_BASE="https://im-api.yuexuan.shop/v1/im"', self.workflow)
self.assertIn('TINODE_FILE_BASE="https://im-api.yuexuan.shop/v0/file"', self.workflow)
def test_build_exposes_configured_api_base_to_vite(self):
self.assertIn("ARG TINODE_API_BASE=", self.dockerfile)
self.assertIn("ENV VITE_TINODE_API_BASE=$TINODE_API_BASE", self.dockerfile)
def test_strips_accidentally_quoted_api_key_before_build(self):
self.assertIn('TINODE_API_KEY="${TINODE_API_KEY#\\\'}"', self.workflow)
self.assertIn('TINODE_API_KEY="${TINODE_API_KEY%\\\'}"', self.workflow)
def test_api_client_prefers_the_configured_production_origin(self):
self.assertIn("import.meta.env.VITE_TINODE_API_BASE?.trim()", self.api_client)
self.assertIn("CONFIGURED_API_BASE || endpoints?.api || DEFAULT_API_BASE", self.api_client)
if __name__ == "__main__":
unittest.main()