fix: 校验独立站公开快照并补充自托管说明

This commit is contained in:
Jack
2026-08-17 21:21:06 +08:00
parent 7af253f081
commit 92ddb84246
13 changed files with 323 additions and 11 deletions
+2 -2
View File
@@ -10,9 +10,9 @@ test("独立首页只展示家纺情报并加载独立入口", async () => {
const dongguanCss = await text("public/assets/fonts/dongguan-bold/result.css");
assert.match(html, /三笙AI情报局/);
assert.match(html, /assets\/js\/app\.js/);
assert.match(html, /assets\/js\/app\.js\?v=20260815a/);
assert.match(html, /assets\/js\/app\.js\?v=20260817a/);
assert.match(html, /assets\/css\/base\.css\?v=20260814h/);
assert.match(html, /assets\/css\/intelligence\.css\?v=20260815a/);
assert.match(html, /assets\/css\/intelligence\.css\?v=20260817a/);
assert.match(html, /<details[^>]+class="intelligence-metrics"/);
assert.match(html, /<summary[^>]+class="intelligence-utility-row"/);
assert.doesNotMatch(html, /id="intelligenceShareBtn"/);
+31
View File
@@ -0,0 +1,31 @@
import json
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch
from scripts.verify_public_snapshot import check_url
class VerifyPublicSnapshotTests(unittest.TestCase):
def test_public_snapshot_must_match_generated_at_and_as_of_date(self):
with tempfile.TemporaryDirectory() as tmp:
path = Path(tmp) / "textile-intelligence.json"
path.write_text(json.dumps({"generated_at": "2026-08-17T12:30:21Z", "as_of_date": "2026-08-17"}), encoding="utf-8")
class Response:
def __enter__(self):
return self
def __exit__(self, *args):
return False
def read(self):
return b'{"generated_at":"2026-08-17T12:30:21Z","as_of_date":"2026-08-17"}'
with patch("scripts.verify_public_snapshot.urlopen", return_value=Response()):
self.assertEqual(check_url("https://example.test", "/data/textile-intelligence.json", path), ("2026-08-17T12:30:21Z", "2026-08-17"))
if __name__ == "__main__":
unittest.main()