bailinghub 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +6 -0
- package/.npmignore +6 -0
- package/CONTRIBUTING.md +4 -0
- package/GOVERNANCE.md +9 -0
- package/README.en.md +8 -6
- package/README.md +8 -6
- package/SECURITY.md +8 -2
- package/THIRD_PARTY_NOTICES.md +17 -17
- package/docker-compose.images.yml +2 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CHANGELOG.en.md +22 -1
- package/docs/CHANGELOG.md +22 -1
- package/docs/COMPATIBILITY.en.md +8 -0
- package/docs/IMPLEMENTATION_STATUS.en.md +73 -0
- package/docs/IMPLEMENTATION_STATUS.md +73 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/KERNEL_HOST_API.en.md +18 -0
- package/docs/KERNEL_HOST_API.md +18 -0
- package/docs/MODEL_BILLING.en.md +123 -0
- package/docs/MODEL_BILLING.md +125 -0
- package/docs/PERIOD_ALLOWANCE_UPGRADE.en.md +31 -0
- package/docs/PERIOD_ALLOWANCE_UPGRADE.md +31 -0
- package/docs/README.en.md +8 -1
- package/docs/README.md +7 -0
- package/docs/RELEASE_NOTES_NEXT.en.md +4 -2
- package/docs/RELEASE_NOTES_NEXT.md +4 -2
- package/docs/RELEASE_NOTES_v0.9.0.en.md +45 -0
- package/docs/RELEASE_NOTES_v0.9.0.md +45 -0
- package/docs/RELEASE_NOTES_v0.9.1.en.md +38 -0
- package/docs/RELEASE_NOTES_v0.9.1.md +38 -0
- package/docs/UPGRADE_v0.9.0.en.md +54 -0
- package/docs/UPGRADE_v0.9.0.md +54 -0
- package/docs/UPGRADE_v0.9.1.en.md +39 -0
- package/docs/UPGRADE_v0.9.1.md +39 -0
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +8 -0
- package/package.json +5 -4
- package/scripts/check-doc-links.mjs +6 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/dependency-audit.mjs +134 -0
- package/scripts/dependency-audit.test.mjs +125 -0
- package/scripts/install.sh +1 -1
- package/scripts/osps-results.py +114 -0
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +2 -0
- package/scripts/sdk-runtime-test.mjs +6 -0
- package/scripts/verify-billing-install-upgrade.mjs +225 -0
- package/scripts/verify-github-repo.mjs +2 -0
- package/sdk/node/README.md +17 -0
- package/sdk/node/examples/billing.mjs +21 -0
- package/sdk/node/package.json +5 -1
- package/sdk/node/src/index.mjs +2 -0
- package/sdk/node/src/usage.d.mts +74 -0
- package/sdk/node/src/usage.mjs +62 -0
- package/sdk/node/tests/usage-types.mts +23 -0
- package/sdk/node/tests/usage.test.mjs +81 -0
- package/sdk/php7/README.md +19 -2
- package/sdk/php7/examples/billing.php +27 -0
- package/sdk/php7/examples/well-known.php +1 -1
- package/sdk/php7/src/ToolSpec.php +1 -1
- package/sdk/php7/src/UsageClient.php +95 -0
- package/sdk/php7/src/UsageClientException.php +22 -0
- package/sdk/php7/tests/billing-core-http.php +59 -0
- package/sdk/php7/tests/usage-client.php +78 -0
- package/security/dependency-audit-exceptions.json +192 -0
- package/sql/063_usage_model_billing.sql +153 -0
- package/sql/064_period_plan_allowance.sql +25 -0
- package/sql/README.en.md +12 -4
- package/sql/README.md +14 -6
- package/src/app/auth.ts +2 -0
- package/src/app/kernel-usage-lifecycle.mysql.test.ts +325 -0
- package/src/app/kernel.ts +10 -0
- package/src/app/oss-edition.ts +1 -0
- package/src/infrastructure/config/configstore.ts +6 -0
- package/src/modules/usage/allowance-reset.mysql.test.ts +122 -0
- package/src/modules/usage/background-work.test.ts +144 -0
- package/src/modules/usage/background-work.ts +50 -0
- package/src/modules/usage/billing-contracts.ts +59 -0
- package/src/modules/usage/billing-decimal.test.ts +22 -0
- package/src/modules/usage/billing-decimal.ts +36 -0
- package/src/modules/usage/billing-external.ts +39 -0
- package/src/modules/usage/billing-gateway.mysql.test.ts +24 -0
- package/src/modules/usage/billing-ledger.test.ts +51 -0
- package/src/modules/usage/billing-ledger.ts +104 -0
- package/src/modules/usage/billing-presentation.mysql.test.ts +95 -0
- package/src/modules/usage/billing-presentation.test.ts +49 -0
- package/src/modules/usage/billing-presentation.ts +34 -0
- package/src/modules/usage/billing-prices.mysql.test.ts +88 -0
- package/src/modules/usage/billing-repository.mysql.test.ts +181 -0
- package/src/modules/usage/billing-repository.ts +465 -0
- package/src/modules/usage/contracts.ts +49 -0
- package/src/modules/usage/dynamic-plan-models.mysql.test.ts +221 -0
- package/src/modules/usage/errors.ts +19 -0
- package/src/modules/usage/http.ts +85 -0
- package/src/modules/usage/identity-revocation.mysql.test.ts +286 -0
- package/src/modules/usage/identity.mysql.test.ts +120 -0
- package/src/modules/usage/identity.ts +303 -0
- package/src/modules/usage/issuer-sdk-billing.mysql.test.ts +92 -0
- package/src/modules/usage/model-gateway.mysql.test.ts +207 -0
- package/src/modules/usage/model-gateway.ts +236 -0
- package/src/modules/usage/model-tool-gateway.mysql.test.ts +137 -0
- package/src/modules/usage/model-tool-provider.test.ts +37 -0
- package/src/modules/usage/model-tool-provider.ts +110 -0
- package/src/modules/usage/model-tools.test.ts +36 -0
- package/src/modules/usage/model-tools.ts +62 -0
- package/src/modules/usage/period-allowance.mysql.test.ts +97 -0
- package/src/modules/usage/period.test.ts +26 -0
- package/src/modules/usage/period.ts +96 -0
- package/src/modules/usage/pricing.test.ts +178 -0
- package/src/modules/usage/pricing.ts +229 -0
- package/src/modules/usage/provider-failure.ts +37 -0
- package/src/modules/usage/provider-stream.test.ts +85 -0
- package/src/modules/usage/provider-stream.ts +77 -0
- package/src/modules/usage/provider.test.ts +67 -0
- package/src/modules/usage/provider.ts +142 -0
- package/src/modules/usage/repository.ts +541 -0
- package/src/modules/usage/service-availability.mysql.test.ts +68 -0
- package/src/modules/usage/service-availability.ts +13 -0
- package/src/modules/usage/service-delete.mysql.test.ts +87 -0
- package/src/modules/usage/stream-http.ts +32 -0
- package/src/modules/usage/test-harness.ts +109 -0
- package/src/modules/usage/usage-deletion.mysql.test.ts +312 -0
- package/src/modules/usage/usage-deletion.ts +119 -0
- package/src/modules/usage/validation.test.ts +18 -0
- package/src/modules/usage/validation.ts +33 -0
- package/src/routes/admin-billing-usage.ts +73 -0
- package/src/routes/admin-usage.ts +147 -0
- package/src/routes/admin.ts +4 -0
- package/src/routes/private.ts +8 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/console/assets/Accounts-Bervi5JU.css +1 -0
- package/web/console/assets/Accounts-DKhw_QLr.js +3 -0
- package/web/console/assets/{AgentClients-Bf7sUUs_.js → AgentClients-CM4_5HaA.js} +1 -1
- package/web/console/assets/AgentTasks-BsG850Il.css +1 -0
- package/web/console/assets/AgentTasks-CkQgZTU5.js +2 -0
- package/web/console/assets/{Approvals-BIbZvInm.js → Approvals-B9O9TkbO.js} +1 -1
- package/web/console/assets/{Audit-KyPSmBdZ.js → Audit-2vDC1SPu.js} +1 -1
- package/web/console/assets/{BrandLockup-Sv5DU2G6.js → BrandLockup-BgASiRSE.js} +1 -1
- package/web/console/assets/{Channels-B9n4fbxg.js → Channels-A-GvkNBt.js} +1 -1
- package/web/console/assets/{ChatEntries-xsOCUXi_.js → ChatEntries-BLxymI67.js} +1 -1
- package/web/console/assets/{Clients-CI3DBDHf.js → Clients-DeNlmvS6.js} +1 -1
- package/web/console/assets/{Cost-JgNXQPlN.js → Cost-CBq_L4Kz.js} +1 -1
- package/web/console/assets/{Credentials-B5UUUdt0.js → Credentials-DmtbctNj.js} +1 -1
- package/web/console/assets/{Diagnostics-BMGciWQb.js → Diagnostics-BbcRDiA-.js} +1 -1
- package/web/console/assets/{Executors-CRbboOCZ.js → Executors-gGgmQrDt.js} +1 -1
- package/web/console/assets/{HelpTip-i-KJhf5s.js → HelpTip-Dtdt2tKR.js} +1 -1
- package/web/console/assets/{Kb-CgLNGjRp.js → Kb-lgY6OXUz.js} +2 -2
- package/web/console/assets/{Login-C52JmXzx.js → Login-DA6BASZd.js} +1 -1
- package/web/console/assets/{Projects-CDOvHPVS.js → Projects-DEbmB_sT.js} +1 -1
- package/web/console/assets/Routes-CyXV4Pba.css +1 -0
- package/web/console/assets/Routes-qS6LLoyS.js +124 -0
- package/web/console/assets/{Runs-DYNDXsqk.js → Runs-DG-VLRSc.js} +1 -1
- package/web/console/assets/{Setup-B91P6i1x.js → Setup-DEpVF5uw.js} +1 -1
- package/web/console/assets/Shell-DgoPgK1E.js +1 -0
- package/web/console/assets/Shell-ykb-tUfo.css +1 -0
- package/web/console/assets/{StorageBuckets-DkuDM0oX.js → StorageBuckets-DJtNN769.js} +1 -1
- package/web/console/assets/{SystemSettings-B7Mqj3k1.js → SystemSettings-0DEUgeTR.js} +1 -1
- package/web/console/assets/{SystemStatus-Db93b6dc.js → SystemStatus-CR1phiPE.js} +1 -1
- package/web/console/assets/{Targets-CuuIYeZO.js → Targets-D65l-IMB.js} +1 -1
- package/web/console/assets/{Tools-CHiqz9XZ.js → Tools-DqtrINrN.js} +1 -1
- package/web/console/assets/Usage-B5njXNjx.js +1 -0
- package/web/console/assets/Usage-CAeDGjrb.css +1 -0
- package/web/console/assets/UsageAccess-CGGaWTuj.css +1 -0
- package/web/console/assets/UsageAccess-ChnB4pjb.js +1 -0
- package/web/console/assets/UsageHelp-BBKIvbQ5.js +1 -0
- package/web/console/assets/UsageHelp-CSM4xO0K.css +1 -0
- package/web/console/assets/{index-QnmD7N7F.js → index-65JiiUr4.js} +1 -1
- package/web/console/assets/{index-Fi9gkGxV.css → index-Cxuc9OCj.css} +1 -1
- package/web/console/assets/index-sLKrJd_p.js +2 -0
- package/web/console/assets/{request-DeGya810.js → request-BpaimqEb.js} +1 -1
- package/web/console/assets/{schema-BqlqLw1R.js → schema-D0Z4kFCZ.js} +1 -1
- package/web/console/assets/{util-4bN2dv7B.js → util-DZYfJ5Zo.js} +1 -1
- package/web/console/assets/{vendor-element-CZoEjZr8.js → vendor-element-8cVcdt5T.js} +2 -2
- package/web/console/assets/{vendor-mammoth-BUEEDX6A.js → vendor-mammoth-CnDA23N0.js} +1 -1
- package/web/console/assets/vendor-vue-Co7x2FW6.js +29 -0
- package/web/console/index.html +4 -4
- package/web-admin/README.md +17 -0
- package/web-admin/package-lock.json +83 -85
- package/web-admin/src/components/UsageDeletionPreview.vue +44 -0
- package/web-admin/src/components/UsageHelp.vue +72 -0
- package/web-admin/src/components/UsageServiceReferences.vue +169 -0
- package/web-admin/src/layout/Shell.vue +22 -5
- package/web-admin/src/pages/Accounts.vue +3 -3
- package/web-admin/src/pages/AgentTasks.vue +2 -2
- package/web-admin/src/pages/Routes.vue +5 -1
- package/web-admin/src/pages/Usage.vue +2470 -0
- package/web-admin/src/pages/UsageAccess.vue +1147 -0
- package/web-admin/src/router.ts +8 -4
- package/web-admin/src/styles/base.css +57 -0
- package/web-admin/src/table-widths.ts +16 -1
- package/web-admin/src/usage-deletion.ts +40 -0
- package/web-admin/src/usage-management.ts +13 -0
- package/web-admin/src/usage-presentation.test.ts +21 -0
- package/web-admin/src/usage-presentation.ts +107 -0
- package/web-admin/src/usage-price-preview.test.ts +60 -0
- package/web-admin/src/usage-price-preview.ts +54 -0
- package/web-admin/tests/token-usage.browser.mjs +773 -0
- package/web-admin/tests/usage-access.browser.mjs +398 -0
- package/web/console/assets/Accounts-B4ePH5jp.css +0 -1
- package/web/console/assets/Accounts-BRCR3O0P.js +0 -3
- package/web/console/assets/AgentTasks--bqL_QKg.js +0 -2
- package/web/console/assets/AgentTasks-C8ox3TyS.css +0 -1
- package/web/console/assets/Routes-DkMIjMQA.css +0 -1
- package/web/console/assets/Routes-X9vHLpKW.js +0 -124
- package/web/console/assets/Shell-Bj6C8Hgo.css +0 -1
- package/web/console/assets/Shell-BsRa7bQQ.js +0 -1
- package/web/console/assets/index-UGvfF3Xr.js +0 -2
- package/web/console/assets/vendor-vue-B2uhHUfE.js +0 -29
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import { chromium } from "playwright";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdir } from "node:fs/promises";
|
|
4
|
+
const url =
|
|
5
|
+
process.env.TOKEN_CONSOLE_URL || "http://127.0.0.1:4437/console/usage";
|
|
6
|
+
const output =
|
|
7
|
+
process.env.TOKEN_CONSOLE_EVIDENCE || "/tmp/bailing-token-console";
|
|
8
|
+
await mkdir(output, { recursive: true });
|
|
9
|
+
const browser = await chromium.launch({ headless: true });
|
|
10
|
+
const context = await browser.newContext({
|
|
11
|
+
viewport: { width: 1440, height: 1100 },
|
|
12
|
+
});
|
|
13
|
+
const page = await context.newPage();
|
|
14
|
+
page.setDefaultTimeout(10000);
|
|
15
|
+
let permissions = ["*"];
|
|
16
|
+
const errors = [],
|
|
17
|
+
unexpected = [],
|
|
18
|
+
posts = [];
|
|
19
|
+
page.on("pageerror", (e) => errors.push(e.message));
|
|
20
|
+
page.on("console", (m) => {
|
|
21
|
+
if (
|
|
22
|
+
m.type() === "warning" &&
|
|
23
|
+
m.text().includes("Failed to resolve component")
|
|
24
|
+
)
|
|
25
|
+
errors.push(m.text());
|
|
26
|
+
});
|
|
27
|
+
const accounts = [
|
|
28
|
+
{
|
|
29
|
+
id: "account-synthetic",
|
|
30
|
+
label: "合成验收账户",
|
|
31
|
+
kind: "personal",
|
|
32
|
+
state: "active",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
const services = [
|
|
36
|
+
{
|
|
37
|
+
id: "general",
|
|
38
|
+
label: "通用模型",
|
|
39
|
+
revision: 1,
|
|
40
|
+
state: "active",
|
|
41
|
+
config: {
|
|
42
|
+
credential: "synthetic-provider",
|
|
43
|
+
model: "synthetic-chat",
|
|
44
|
+
providerScope: "synthetic-provider",
|
|
45
|
+
maxInputBytes: 8388608,
|
|
46
|
+
maxOutputTokens: 8192,
|
|
47
|
+
timeoutMs: 120000,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "reasoning",
|
|
52
|
+
label: "推理模型",
|
|
53
|
+
revision: 1,
|
|
54
|
+
state: "active",
|
|
55
|
+
config: {
|
|
56
|
+
credential: "synthetic-provider",
|
|
57
|
+
model: "synthetic-reasoning",
|
|
58
|
+
providerScope: "synthetic-provider",
|
|
59
|
+
maxInputBytes: 8388608,
|
|
60
|
+
maxOutputTokens: 8192,
|
|
61
|
+
timeoutMs: 120000,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
let plans = [],
|
|
66
|
+
activeGrant = null,
|
|
67
|
+
dropGrantAck = true,
|
|
68
|
+
grantWrites = 0,
|
|
69
|
+
grantKey = null,
|
|
70
|
+
failPlanRead = false;
|
|
71
|
+
let projectionOverride;
|
|
72
|
+
const syntheticPresentation = () =>
|
|
73
|
+
projectionOverride !== undefined
|
|
74
|
+
? projectionOverride
|
|
75
|
+
: !activeGrant
|
|
76
|
+
? {
|
|
77
|
+
schema: "bailing.usage-presentation.v1",
|
|
78
|
+
kind: "none",
|
|
79
|
+
state: "unavailable",
|
|
80
|
+
remaining: null,
|
|
81
|
+
total: null,
|
|
82
|
+
displayValue: null,
|
|
83
|
+
}
|
|
84
|
+
: {
|
|
85
|
+
schema: "bailing.usage-presentation.v1",
|
|
86
|
+
kind:
|
|
87
|
+
activeGrant.config.mode === "periodic" ? "percentage" : "credits",
|
|
88
|
+
state: activeGrant.state === "active" ? "active" : "suspended",
|
|
89
|
+
remaining: activeGrant.state === "active" ? 99.9 : null,
|
|
90
|
+
total: 100,
|
|
91
|
+
displayValue: activeGrant.state === "active" ? "99" : null,
|
|
92
|
+
};
|
|
93
|
+
const summary = () => ({
|
|
94
|
+
presentation: syntheticPresentation(),
|
|
95
|
+
schema: "bailing.token-summary.v1",
|
|
96
|
+
accountId: accounts[0].id,
|
|
97
|
+
grant: activeGrant,
|
|
98
|
+
plan: activeGrant ? (() => { const p=plans.find(p=>p.id===activeGrant.planId); return p ? {id:p.id,label:p.label,revision:p.revision,serviceIds:p.config.serviceIds}:null; })() : null,
|
|
99
|
+
availableTokens: activeGrant ? 999000 : 0,
|
|
100
|
+
consumedTokens: 1000,
|
|
101
|
+
currentPeriodConsumedTokens: 1000,
|
|
102
|
+
overageTokens: 0,
|
|
103
|
+
pendingRequests: 1,
|
|
104
|
+
resetAt:
|
|
105
|
+
activeGrant?.config.mode === "periodic" ? Date.now() + 86400000 : null,
|
|
106
|
+
expiresAt: activeGrant ? Date.now() + 2592000000 : null,
|
|
107
|
+
});
|
|
108
|
+
await page.route("**/branding", (r) => r.fulfill({ json: {} }));
|
|
109
|
+
await page.route("**/health", (r) => r.fulfill({ json: { status: "ok" } }));
|
|
110
|
+
await page.route("**/admin/api/**", async (r) => {
|
|
111
|
+
const p = new URL(r.request().url()).pathname,
|
|
112
|
+
method = r.request().method();
|
|
113
|
+
if (method === "POST")
|
|
114
|
+
posts.push({ path: p, body: r.request().postDataJSON() });
|
|
115
|
+
if (p === "/admin/api/me")
|
|
116
|
+
return r.fulfill({
|
|
117
|
+
json: {
|
|
118
|
+
username: "synthetic-admin",
|
|
119
|
+
role: "admin",
|
|
120
|
+
via: "synthetic",
|
|
121
|
+
perms: permissions,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
if (p === "/admin/api/status") return r.fulfill({ json: { executors: [] } });
|
|
125
|
+
if (p === "/admin/api/demo-dataset/status")
|
|
126
|
+
return r.fulfill({ json: { imported: false } });
|
|
127
|
+
if (p === "/admin/api/usage/services") {
|
|
128
|
+
if (method === "GET") return r.fulfill({ json: { items: services } });
|
|
129
|
+
const b = r.request().postDataJSON();
|
|
130
|
+
const original = services.find((item) => item.id === b.id);
|
|
131
|
+
assert.equal(b.expected_revision, original?.revision || 0);
|
|
132
|
+
const saved = {
|
|
133
|
+
id: b.id,
|
|
134
|
+
label: b.label,
|
|
135
|
+
state: b.state,
|
|
136
|
+
revision: (original?.revision || 0) + 1,
|
|
137
|
+
config: b.config,
|
|
138
|
+
};
|
|
139
|
+
if (original) Object.assign(original, saved);
|
|
140
|
+
else services.push(saved);
|
|
141
|
+
return r.fulfill({ json: saved });
|
|
142
|
+
}
|
|
143
|
+
if (p === "/admin/api/usage/accounts")
|
|
144
|
+
return r.fulfill({ json: { items: accounts, next_cursor: null } });
|
|
145
|
+
if (p === "/admin/api/usage/token/plans") {
|
|
146
|
+
if (method === "GET")
|
|
147
|
+
return failPlanRead
|
|
148
|
+
? r.fulfill({ status: 503, json: { error: "USAGE_TOKEN_UNSUPPORTED" } })
|
|
149
|
+
: r.fulfill({ json: { items: plans } });
|
|
150
|
+
const b = r.request().postDataJSON(),
|
|
151
|
+
old = plans.find((x) => x.id === b.id);
|
|
152
|
+
assert.equal(b.expected_revision, old?.revision || 0);
|
|
153
|
+
const plan = {
|
|
154
|
+
id: b.id,
|
|
155
|
+
label: b.label,
|
|
156
|
+
state: b.state,
|
|
157
|
+
revision: (old?.revision || 0) + 1,
|
|
158
|
+
config: b.config,
|
|
159
|
+
};
|
|
160
|
+
plans = plans.filter((x) => x.id !== b.id).concat(plan);
|
|
161
|
+
return r.fulfill({ json: plan });
|
|
162
|
+
}
|
|
163
|
+
if (p.endsWith("/summary")) return r.fulfill({ json: summary() });
|
|
164
|
+
if (p.endsWith("/requests"))
|
|
165
|
+
return r.fulfill({
|
|
166
|
+
json: {
|
|
167
|
+
items: [
|
|
168
|
+
{
|
|
169
|
+
operation_id: "synthetic-complete",
|
|
170
|
+
service_id: "general",
|
|
171
|
+
result_state: "complete",
|
|
172
|
+
billing_state: "settled",
|
|
173
|
+
charged_tokens: 1000,
|
|
174
|
+
usage: { inputTokens: 800, outputTokens: 200 },
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
operation_id: "synthetic-pending-usage",
|
|
178
|
+
service_id: "reasoning",
|
|
179
|
+
result_state: "complete",
|
|
180
|
+
billing_state: "pending",
|
|
181
|
+
charged_tokens: null,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
next_cursor: null,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
if (p.endsWith("/grant")) {
|
|
188
|
+
const b = r.request().postDataJSON();
|
|
189
|
+
if (!grantKey) {
|
|
190
|
+
grantKey = b.request_key;
|
|
191
|
+
grantWrites++;
|
|
192
|
+
const plan = plans.find((x) => x.id === b.plan_id);
|
|
193
|
+
activeGrant = {
|
|
194
|
+
id: "synthetic-grant",
|
|
195
|
+
label: plan.label,
|
|
196
|
+
planId: plan.id,
|
|
197
|
+
revision: 1,
|
|
198
|
+
state: "active",
|
|
199
|
+
sourceOwner: "hub",
|
|
200
|
+
startsAt: Date.now(),
|
|
201
|
+
config: (({serviceIds,...allowance})=>structuredClone(allowance))(plan.config),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
assert.equal(b.request_key, grantKey);
|
|
205
|
+
assert.equal(b.expected_revision, 0);
|
|
206
|
+
if (dropGrantAck) {
|
|
207
|
+
dropGrantAck = false;
|
|
208
|
+
return r.abort("connectionreset");
|
|
209
|
+
}
|
|
210
|
+
return r.fulfill({ json: activeGrant });
|
|
211
|
+
}
|
|
212
|
+
if (p.endsWith("/control")) {
|
|
213
|
+
const b = r.request().postDataJSON();
|
|
214
|
+
assert.equal(b.expected_revision, activeGrant.revision);
|
|
215
|
+
activeGrant = {
|
|
216
|
+
...activeGrant,
|
|
217
|
+
state: b.state,
|
|
218
|
+
revision: activeGrant.revision + 1,
|
|
219
|
+
};
|
|
220
|
+
return r.fulfill({ json: activeGrant });
|
|
221
|
+
}
|
|
222
|
+
unexpected.push({ p, method });
|
|
223
|
+
return r.fulfill({
|
|
224
|
+
status: 404,
|
|
225
|
+
json: { error: "UNEXPECTED_SYNTHETIC_ENDPOINT" },
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
try {
|
|
229
|
+
await page.goto(url);
|
|
230
|
+
await page.getByRole("button", { name: "新建套餐", exact: true }).click();
|
|
231
|
+
await page.getByLabel("套餐名称", { exact: true }).fill("联调周享套餐");
|
|
232
|
+
await page
|
|
233
|
+
.locator(".model-choices .el-checkbox")
|
|
234
|
+
.filter({ hasText: "通用模型" })
|
|
235
|
+
.click();
|
|
236
|
+
await page
|
|
237
|
+
.locator(".model-choices .el-checkbox")
|
|
238
|
+
.filter({ hasText: "推理模型" })
|
|
239
|
+
.click();
|
|
240
|
+
const planPreview = page.locator(".preview");
|
|
241
|
+
const creditsMode = page.getByRole("radio", {
|
|
242
|
+
name: "额度包 一次获得固定额度,在有效期内按需使用。",
|
|
243
|
+
exact: true,
|
|
244
|
+
});
|
|
245
|
+
const periodicMode = page.getByRole("radio", {
|
|
246
|
+
name: "周期套餐 订阅期间按日、周或月获得新一期额度。",
|
|
247
|
+
exact: true,
|
|
248
|
+
});
|
|
249
|
+
assert.match(
|
|
250
|
+
await planPreview.locator(".preview-amount").innerText(),
|
|
251
|
+
/100%/,
|
|
252
|
+
);
|
|
253
|
+
assert.doesNotMatch(await planPreview.innerText(), /Token|Credits|相当于/i);
|
|
254
|
+
assert.match(await planPreview.innerText(), /本期剩余额度不累积到下一期/);
|
|
255
|
+
await creditsMode.check();
|
|
256
|
+
assert.match(await planPreview.innerText(), /未用积分在套餐有效期内可用/);
|
|
257
|
+
assert.doesNotMatch(await planPreview.innerText(), /不累积到下一期/);
|
|
258
|
+
assert.match(
|
|
259
|
+
await planPreview.locator(".preview-amount").innerText(),
|
|
260
|
+
/1,000积分/,
|
|
261
|
+
);
|
|
262
|
+
await page.getByLabel("总额度", { exact: true }).fill("0.0101");
|
|
263
|
+
await page.getByLabel("每 1 积分对应的 Token", { exact: true }).fill("100");
|
|
264
|
+
await page.getByLabel("套餐名称", { exact: true }).focus();
|
|
265
|
+
assert.match(
|
|
266
|
+
await planPreview.locator(".preview-amount").innerText(),
|
|
267
|
+
/1.01积分/,
|
|
268
|
+
);
|
|
269
|
+
await page.getByLabel("总额度", { exact: true }).fill("0.0001");
|
|
270
|
+
await page.getByLabel("每 1 积分对应的 Token", { exact: true }).fill("1000");
|
|
271
|
+
await page.getByLabel("套餐名称", { exact: true }).focus();
|
|
272
|
+
assert.match(
|
|
273
|
+
await planPreview.locator(".preview-amount").innerText(),
|
|
274
|
+
/<0.01积分/,
|
|
275
|
+
);
|
|
276
|
+
await periodicMode.check();
|
|
277
|
+
assert.match(
|
|
278
|
+
await planPreview.locator(".preview-amount").innerText(),
|
|
279
|
+
/100%/,
|
|
280
|
+
);
|
|
281
|
+
await page.getByLabel("每期额度", { exact: true }).fill("100");
|
|
282
|
+
await page.getByLabel("套餐名称", { exact: true }).focus();
|
|
283
|
+
assert.equal(
|
|
284
|
+
await page.getByText("用户看到的额度单位", { exact: true }).count(),
|
|
285
|
+
0,
|
|
286
|
+
);
|
|
287
|
+
assert.equal(
|
|
288
|
+
await page
|
|
289
|
+
.locator(".plan-form")
|
|
290
|
+
.getByText(/轮次上限|每轮最多|单轮最长/)
|
|
291
|
+
.count(),
|
|
292
|
+
0,
|
|
293
|
+
);
|
|
294
|
+
await page.locator(".main").evaluate((el) => (el.scrollTop = 0));
|
|
295
|
+
await page.screenshot({
|
|
296
|
+
path: `${output}/token-plan-desktop.png`,
|
|
297
|
+
fullPage: true,
|
|
298
|
+
animations: "disabled",
|
|
299
|
+
});
|
|
300
|
+
await page.getByRole("button", { name: "保存套餐", exact: true }).click();
|
|
301
|
+
await page.getByRole("button", { name: "新建套餐", exact: true }).waitFor();
|
|
302
|
+
assert.equal(plans.length, 1);
|
|
303
|
+
assert.equal(plans[0].config.quotaTokens, 1000000);
|
|
304
|
+
assert.deepEqual(plans[0].config.serviceIds, ["general", "reasoning"]);
|
|
305
|
+
assert.equal("displayUnit" in plans[0].config, false);
|
|
306
|
+
assert.deepEqual(
|
|
307
|
+
Object.keys(plans[0].config).sort(),
|
|
308
|
+
[
|
|
309
|
+
"mode",
|
|
310
|
+
"serviceIds",
|
|
311
|
+
"quotaTokens",
|
|
312
|
+
"periodUnit",
|
|
313
|
+
"duration",
|
|
314
|
+
"tokensPerCredit",
|
|
315
|
+
].sort(),
|
|
316
|
+
);
|
|
317
|
+
await page.getByRole("button", { name: "编辑", exact: true }).click();
|
|
318
|
+
await page.getByLabel("套餐名称", { exact: true }).fill("联调周享套餐修订");
|
|
319
|
+
await page.getByRole("button", { name: "保存套餐", exact: true }).click();
|
|
320
|
+
await page.getByRole("button", { name: "新建套餐", exact: true }).waitFor();
|
|
321
|
+
assert.equal(plans[0].revision, 2);
|
|
322
|
+
await page.getByRole("button", { name: "开通给账户", exact: true }).click();
|
|
323
|
+
await page.getByRole("dialog").locator(".el-select").first().click();
|
|
324
|
+
await page.getByRole("option", { name: "合成验收账户", exact: true }).click();
|
|
325
|
+
assert.match(await page.locator(".grant-preview").innerText(), /剩余 100 %/);
|
|
326
|
+
assert.doesNotMatch(
|
|
327
|
+
await page.locator(".grant-preview").innerText(),
|
|
328
|
+
/Token|Credits|相当于/i,
|
|
329
|
+
);
|
|
330
|
+
await page.getByRole("button", { name: "确认开通", exact: true }).click();
|
|
331
|
+
await page
|
|
332
|
+
.getByRole("button", { name: "核对 / 重试原请求", exact: true })
|
|
333
|
+
.waitFor();
|
|
334
|
+
await page.reload();
|
|
335
|
+
await page
|
|
336
|
+
.getByRole("button", { name: "核对 / 重试原请求", exact: true })
|
|
337
|
+
.click();
|
|
338
|
+
await page
|
|
339
|
+
.getByText("上一次保存需要核对", { exact: true })
|
|
340
|
+
.waitFor({ state: "hidden" });
|
|
341
|
+
assert.equal(grantWrites, 1);
|
|
342
|
+
assert.equal(posts.filter((x) => x.path.endsWith("/grant")).length, 2);
|
|
343
|
+
await page.getByRole("tab", { name: "账户用量", exact: true }).click();
|
|
344
|
+
await page.getByRole("button", { name: "查看用量", exact: true }).click();
|
|
345
|
+
await page.getByText("synthetic-complete", { exact: true }).waitFor();
|
|
346
|
+
const detail = page.locator(".account-detail");
|
|
347
|
+
const customerPreview = detail.locator(".customer-preview");
|
|
348
|
+
assert.equal(
|
|
349
|
+
await customerPreview.locator(".preview-amount").innerText(),
|
|
350
|
+
"99%",
|
|
351
|
+
);
|
|
352
|
+
assert.match(await customerPreview.innerText(), /1 笔用量待更新/);
|
|
353
|
+
assert.doesNotMatch(
|
|
354
|
+
await customerPreview.innerText(),
|
|
355
|
+
/Token|Credits|999,000|相当于/i,
|
|
356
|
+
);
|
|
357
|
+
assert.match(
|
|
358
|
+
await detail.locator(".operator-accounting").innerText(),
|
|
359
|
+
/999,000/,
|
|
360
|
+
);
|
|
361
|
+
assert.match(await detail.innerText(), /待计量/);
|
|
362
|
+
assert.match(await detail.innerText(), /输入 800 \/ 输出 200/);
|
|
363
|
+
await detail.getByRole("button", { name: "暂停新请求", exact: true }).click();
|
|
364
|
+
await page.getByRole("button", { name: "确认", exact: true }).click();
|
|
365
|
+
await detail.getByRole("button", { name: "恢复使用", exact: true }).waitFor();
|
|
366
|
+
assert.equal(activeGrant.state, "suspended");
|
|
367
|
+
assert.match(await customerPreview.innerText(), /已暂停/);
|
|
368
|
+
assert.equal(
|
|
369
|
+
await customerPreview.locator(".preview-amount").innerText(),
|
|
370
|
+
"—%",
|
|
371
|
+
);
|
|
372
|
+
await detail.getByRole("button", { name: "恢复使用", exact: true }).click();
|
|
373
|
+
await page.getByRole("button", { name: "确认", exact: true }).click();
|
|
374
|
+
await detail
|
|
375
|
+
.getByRole("button", { name: "暂停新请求", exact: true })
|
|
376
|
+
.waitFor();
|
|
377
|
+
assert.equal(activeGrant.state, "active");
|
|
378
|
+
await page.locator(".el-message-box__wrapper").waitFor({ state: "hidden" });
|
|
379
|
+
await page.locator(".el-message").last().waitFor({ state: "hidden" });
|
|
380
|
+
await page.screenshot({
|
|
381
|
+
path: `${output}/token-account-desktop.png`,
|
|
382
|
+
fullPage: true,
|
|
383
|
+
animations: "disabled",
|
|
384
|
+
});
|
|
385
|
+
const originalGrant = structuredClone(activeGrant);
|
|
386
|
+
const projectionCases = [
|
|
387
|
+
{
|
|
388
|
+
label: "fractional percentage",
|
|
389
|
+
mode: "periodic",
|
|
390
|
+
projection: {
|
|
391
|
+
kind: "percentage",
|
|
392
|
+
state: "active",
|
|
393
|
+
remaining: 0.4,
|
|
394
|
+
total: 100,
|
|
395
|
+
displayValue: "<1",
|
|
396
|
+
},
|
|
397
|
+
amount: "<1%",
|
|
398
|
+
state: "可用",
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
label: "zero percentage",
|
|
402
|
+
mode: "periodic",
|
|
403
|
+
projection: {
|
|
404
|
+
kind: "percentage",
|
|
405
|
+
state: "depleted",
|
|
406
|
+
remaining: 0,
|
|
407
|
+
total: 100,
|
|
408
|
+
displayValue: "0",
|
|
409
|
+
},
|
|
410
|
+
amount: "0%",
|
|
411
|
+
state: "额度已用完",
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
label: "fractional credits",
|
|
415
|
+
mode: "credits",
|
|
416
|
+
projection: {
|
|
417
|
+
kind: "credits",
|
|
418
|
+
state: "active",
|
|
419
|
+
remaining: 1.019,
|
|
420
|
+
total: 100,
|
|
421
|
+
displayValue: "1.01",
|
|
422
|
+
},
|
|
423
|
+
amount: "1.01积分",
|
|
424
|
+
state: "可用",
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
label: "tiny credits",
|
|
428
|
+
mode: "credits",
|
|
429
|
+
projection: {
|
|
430
|
+
kind: "credits",
|
|
431
|
+
state: "active",
|
|
432
|
+
remaining: 0.001,
|
|
433
|
+
total: 100,
|
|
434
|
+
displayValue: "<0.01",
|
|
435
|
+
},
|
|
436
|
+
amount: "<0.01积分",
|
|
437
|
+
state: "可用",
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
label: "zero credits",
|
|
441
|
+
mode: "credits",
|
|
442
|
+
projection: {
|
|
443
|
+
kind: "credits",
|
|
444
|
+
state: "depleted",
|
|
445
|
+
remaining: 0,
|
|
446
|
+
total: 100,
|
|
447
|
+
displayValue: "0",
|
|
448
|
+
},
|
|
449
|
+
amount: "0积分",
|
|
450
|
+
state: "额度已用完",
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
label: "expired",
|
|
454
|
+
mode: "credits",
|
|
455
|
+
projection: {
|
|
456
|
+
kind: "credits",
|
|
457
|
+
state: "expired",
|
|
458
|
+
remaining: null,
|
|
459
|
+
total: 100,
|
|
460
|
+
displayValue: null,
|
|
461
|
+
},
|
|
462
|
+
amount: "—积分",
|
|
463
|
+
state: "已到期",
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
label: "not started",
|
|
467
|
+
mode: "periodic",
|
|
468
|
+
projection: {
|
|
469
|
+
kind: "percentage",
|
|
470
|
+
state: "not_started",
|
|
471
|
+
remaining: null,
|
|
472
|
+
total: 100,
|
|
473
|
+
displayValue: null,
|
|
474
|
+
},
|
|
475
|
+
amount: "—%",
|
|
476
|
+
state: "尚未生效",
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
label: "suspended",
|
|
480
|
+
mode: "credits",
|
|
481
|
+
projection: {
|
|
482
|
+
kind: "credits",
|
|
483
|
+
state: "suspended",
|
|
484
|
+
remaining: null,
|
|
485
|
+
total: 100,
|
|
486
|
+
displayValue: null,
|
|
487
|
+
},
|
|
488
|
+
amount: "—积分",
|
|
489
|
+
state: "已暂停",
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
label: "missing projection",
|
|
493
|
+
mode: "periodic",
|
|
494
|
+
projection: null,
|
|
495
|
+
amount: "—",
|
|
496
|
+
state: "用量暂不可用",
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
label: "unknown projection",
|
|
500
|
+
mode: "periodic",
|
|
501
|
+
projection: {
|
|
502
|
+
schema: "unknown",
|
|
503
|
+
kind: "percentage",
|
|
504
|
+
state: "active",
|
|
505
|
+
remaining: 100,
|
|
506
|
+
total: 100,
|
|
507
|
+
displayValue: "100",
|
|
508
|
+
},
|
|
509
|
+
amount: "—",
|
|
510
|
+
state: "用量暂不可用",
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
label: "wrong mode projection",
|
|
514
|
+
mode: "periodic",
|
|
515
|
+
projection: {
|
|
516
|
+
kind: "credits",
|
|
517
|
+
state: "active",
|
|
518
|
+
remaining: 100,
|
|
519
|
+
total: 100,
|
|
520
|
+
displayValue: "100",
|
|
521
|
+
},
|
|
522
|
+
amount: "—",
|
|
523
|
+
state: "用量暂不可用",
|
|
524
|
+
},
|
|
525
|
+
...["101", "1.25", "<0.01"].map((displayValue) => ({
|
|
526
|
+
label: `invalid percentage ${displayValue}`,
|
|
527
|
+
mode: "periodic",
|
|
528
|
+
projection: {
|
|
529
|
+
kind: "percentage",
|
|
530
|
+
state: "active",
|
|
531
|
+
remaining: 1,
|
|
532
|
+
total: 100,
|
|
533
|
+
displayValue,
|
|
534
|
+
},
|
|
535
|
+
amount: "—",
|
|
536
|
+
state: "用量暂不可用",
|
|
537
|
+
})),
|
|
538
|
+
{
|
|
539
|
+
label: "invalid credits notation",
|
|
540
|
+
mode: "credits",
|
|
541
|
+
projection: {
|
|
542
|
+
kind: "credits",
|
|
543
|
+
state: "active",
|
|
544
|
+
remaining: 0.1,
|
|
545
|
+
total: 100,
|
|
546
|
+
displayValue: "<1",
|
|
547
|
+
},
|
|
548
|
+
amount: "—",
|
|
549
|
+
state: "用量暂不可用",
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
label: "credits exceed total",
|
|
553
|
+
mode: "credits",
|
|
554
|
+
projection: {
|
|
555
|
+
kind: "credits",
|
|
556
|
+
state: "active",
|
|
557
|
+
remaining: 101,
|
|
558
|
+
total: 100,
|
|
559
|
+
displayValue: "101",
|
|
560
|
+
},
|
|
561
|
+
amount: "—",
|
|
562
|
+
state: "用量暂不可用",
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
label: "not granted",
|
|
566
|
+
mode: null,
|
|
567
|
+
projection: {
|
|
568
|
+
kind: "none",
|
|
569
|
+
state: "unavailable",
|
|
570
|
+
remaining: null,
|
|
571
|
+
total: null,
|
|
572
|
+
displayValue: null,
|
|
573
|
+
},
|
|
574
|
+
amount: "—",
|
|
575
|
+
state: "尚未开通",
|
|
576
|
+
},
|
|
577
|
+
];
|
|
578
|
+
for (const scenario of projectionCases) {
|
|
579
|
+
activeGrant = scenario.mode
|
|
580
|
+
? {
|
|
581
|
+
...structuredClone(originalGrant),
|
|
582
|
+
config: { ...originalGrant.config, mode: scenario.mode },
|
|
583
|
+
}
|
|
584
|
+
: null;
|
|
585
|
+
projectionOverride =
|
|
586
|
+
scenario.projection === null
|
|
587
|
+
? null
|
|
588
|
+
: { schema: "bailing.usage-presentation.v1", ...scenario.projection };
|
|
589
|
+
await detail.getByRole("button", { name: "刷新用量", exact: true }).click();
|
|
590
|
+
await customerPreview.getByText(scenario.state, { exact: true }).waitFor();
|
|
591
|
+
assert.equal(
|
|
592
|
+
await customerPreview.locator(".preview-amount").innerText(),
|
|
593
|
+
scenario.amount,
|
|
594
|
+
scenario.label,
|
|
595
|
+
);
|
|
596
|
+
assert.doesNotMatch(
|
|
597
|
+
await customerPreview.innerText(),
|
|
598
|
+
/Token|Credits|999,000|相当于/i,
|
|
599
|
+
scenario.label,
|
|
600
|
+
);
|
|
601
|
+
if (scenario.label === "fractional credits")
|
|
602
|
+
await page.screenshot({
|
|
603
|
+
path: `${output}/credits-account-desktop.png`,
|
|
604
|
+
fullPage: true,
|
|
605
|
+
animations: "disabled",
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
activeGrant = originalGrant;
|
|
609
|
+
projectionOverride = undefined;
|
|
610
|
+
await page.locator(".el-drawer__close-btn").click();
|
|
611
|
+
await page.getByRole("tab", { name: "套餐管理", exact: true }).click();
|
|
612
|
+
await page.getByRole("button", { name: "新建套餐", exact: true }).click();
|
|
613
|
+
await page.getByLabel("套餐名称", { exact: true }).fill("一次性额度包");
|
|
614
|
+
await page
|
|
615
|
+
.getByRole("radio", {
|
|
616
|
+
name: "额度包 一次获得固定额度,在有效期内按需使用。",
|
|
617
|
+
exact: true,
|
|
618
|
+
})
|
|
619
|
+
.check();
|
|
620
|
+
await page
|
|
621
|
+
.locator(".model-choices .el-checkbox")
|
|
622
|
+
.filter({ hasText: "通用模型" })
|
|
623
|
+
.click();
|
|
624
|
+
await page.locator(".preview").screenshot({
|
|
625
|
+
path: `${output}/credits-plan-preview.png`,
|
|
626
|
+
animations: "disabled",
|
|
627
|
+
});
|
|
628
|
+
await page.setViewportSize({ width: 390, height: 844 });
|
|
629
|
+
await page.locator(".main").evaluate((el) => (el.scrollTop = 0));
|
|
630
|
+
await page.screenshot({
|
|
631
|
+
path: `${output}/token-plan-mobile.png`,
|
|
632
|
+
fullPage: true,
|
|
633
|
+
animations: "disabled",
|
|
634
|
+
});
|
|
635
|
+
const overflow = await page.evaluate(
|
|
636
|
+
() => document.documentElement.scrollWidth > window.innerWidth + 1,
|
|
637
|
+
);
|
|
638
|
+
assert.equal(overflow, false, "mobile should not overflow");
|
|
639
|
+
await page.getByRole("button", { name: "保存套餐", exact: true }).click();
|
|
640
|
+
await page.getByRole("button", { name: "新建套餐", exact: true }).waitFor();
|
|
641
|
+
assert.equal(plans[1].config.mode, "credits");
|
|
642
|
+
assert.ok(!("periodUnit" in plans[1].config));
|
|
643
|
+
await page.setViewportSize({ width: 1440, height: 1100 });
|
|
644
|
+
await page.getByRole("tab", { name: "模型服务", exact: true }).click();
|
|
645
|
+
await page.getByRole("button", { name: "添加模型服务", exact: true }).click();
|
|
646
|
+
const serviceDialog = page.getByRole("dialog");
|
|
647
|
+
await serviceDialog
|
|
648
|
+
.getByLabel("显示名称", { exact: true })
|
|
649
|
+
.fill("附加合成模型");
|
|
650
|
+
await serviceDialog
|
|
651
|
+
.getByLabel("服务标识", { exact: true })
|
|
652
|
+
.fill("extra-synthetic");
|
|
653
|
+
await serviceDialog
|
|
654
|
+
.getByLabel("模型凭证名称", { exact: true })
|
|
655
|
+
.fill("existing-synthetic-credential");
|
|
656
|
+
await serviceDialog
|
|
657
|
+
.getByLabel("模型标识", { exact: true })
|
|
658
|
+
.fill("synthetic-extra");
|
|
659
|
+
await page.getByRole("button", { name: "保存服务", exact: true }).click();
|
|
660
|
+
await serviceDialog.waitFor({ state: "hidden" });
|
|
661
|
+
await page
|
|
662
|
+
.getByRole("heading", { name: "附加合成模型", exact: true })
|
|
663
|
+
.waitFor();
|
|
664
|
+
const savedService = services.find((s) => s.id === "extra-synthetic");
|
|
665
|
+
assert.equal(savedService.config.credential, "existing-synthetic-credential");
|
|
666
|
+
assert.deepEqual(
|
|
667
|
+
Object.keys(savedService.config).sort(),
|
|
668
|
+
[
|
|
669
|
+
"credential",
|
|
670
|
+
"model",
|
|
671
|
+
"providerScope",
|
|
672
|
+
"maxOutputTokens",
|
|
673
|
+
"maxInputBytes",
|
|
674
|
+
"timeoutMs",
|
|
675
|
+
].sort(),
|
|
676
|
+
);
|
|
677
|
+
assert.equal("api_key" in savedService.config, false);
|
|
678
|
+
failPlanRead = true;
|
|
679
|
+
await page.reload();
|
|
680
|
+
await page
|
|
681
|
+
.getByText("用量套餐尚未就绪,请核对迁移。", { exact: false })
|
|
682
|
+
.waitFor();
|
|
683
|
+
assert.equal(
|
|
684
|
+
await page
|
|
685
|
+
.getByRole("tab", { name: "套餐管理", exact: true })
|
|
686
|
+
.getAttribute("class")
|
|
687
|
+
.then((value) => value.includes("is-disabled")),
|
|
688
|
+
true,
|
|
689
|
+
);
|
|
690
|
+
failPlanRead = false;
|
|
691
|
+
permissions = ["usage:read"];
|
|
692
|
+
await page.setViewportSize({ width: 1440, height: 1100 });
|
|
693
|
+
await page.reload();
|
|
694
|
+
await page.getByRole("tab", { name: "账户用量", exact: true }).waitFor();
|
|
695
|
+
await page.getByText("联调周享套餐修订", { exact: true }).waitFor();
|
|
696
|
+
assert.equal(
|
|
697
|
+
await page.getByRole("button", { name: "新建套餐", exact: true }).count(),
|
|
698
|
+
0,
|
|
699
|
+
);
|
|
700
|
+
assert.equal(
|
|
701
|
+
await page.getByRole("button", { name: "开通给账户", exact: true }).count(),
|
|
702
|
+
0,
|
|
703
|
+
);
|
|
704
|
+
await page.getByRole("tab", { name: "模型服务", exact: true }).click();
|
|
705
|
+
assert.equal(
|
|
706
|
+
await page
|
|
707
|
+
.getByRole("button", { name: "添加模型服务", exact: true })
|
|
708
|
+
.count(),
|
|
709
|
+
0,
|
|
710
|
+
);
|
|
711
|
+
assert.equal(
|
|
712
|
+
await page
|
|
713
|
+
.getByRole("link", { name: "接入设置", exact: true })
|
|
714
|
+
.getAttribute("href"),
|
|
715
|
+
"/console/usage-access",
|
|
716
|
+
);
|
|
717
|
+
assert.deepEqual(errors, []);
|
|
718
|
+
assert.deepEqual(unexpected, []);
|
|
719
|
+
console.log(
|
|
720
|
+
JSON.stringify(
|
|
721
|
+
{
|
|
722
|
+
ok: true,
|
|
723
|
+
checks: [
|
|
724
|
+
"mode-controlled credits/percentage previews without Token",
|
|
725
|
+
"mode switch immediately updates full-period percentage",
|
|
726
|
+
"fractional and tiny credit previews use integer-safe floor",
|
|
727
|
+
"old display-unit pending payload cleared without replay",
|
|
728
|
+
"seventeen account projection, malformed projection and state cases",
|
|
729
|
+
"account preview never falls back to raw Token",
|
|
730
|
+
"pending usage preserves actual remaining balance",
|
|
731
|
+
"multi-model shared quota",
|
|
732
|
+
"revisioned edit",
|
|
733
|
+
"lost grant ACK then reload exact-key recovery",
|
|
734
|
+
"no duplicate allocation",
|
|
735
|
+
"actual usage and pending usage",
|
|
736
|
+
"pause/resume revision",
|
|
737
|
+
"allowance pack no period",
|
|
738
|
+
"responsive mobile",
|
|
739
|
+
"unsupported visible",
|
|
740
|
+
"existing model credential reference only",
|
|
741
|
+
"read-only administrator no mutation actions",
|
|
742
|
+
],
|
|
743
|
+
requests: posts.map((x) => ({
|
|
744
|
+
path: x.path,
|
|
745
|
+
revision: x.body.expected_revision,
|
|
746
|
+
})),
|
|
747
|
+
screenshots: output,
|
|
748
|
+
},
|
|
749
|
+
null,
|
|
750
|
+
2,
|
|
751
|
+
),
|
|
752
|
+
);
|
|
753
|
+
} catch (e) {
|
|
754
|
+
console.error(
|
|
755
|
+
JSON.stringify(
|
|
756
|
+
{
|
|
757
|
+
posts,
|
|
758
|
+
errors,
|
|
759
|
+
unexpected,
|
|
760
|
+
body: await page
|
|
761
|
+
.locator("body")
|
|
762
|
+
.innerText({ timeout: 1000 })
|
|
763
|
+
.catch(() => "unavailable"),
|
|
764
|
+
},
|
|
765
|
+
null,
|
|
766
|
+
2,
|
|
767
|
+
),
|
|
768
|
+
);
|
|
769
|
+
await page.screenshot({ path: `${output}/failure.png`, fullPage: true });
|
|
770
|
+
throw e;
|
|
771
|
+
} finally {
|
|
772
|
+
await browser.close();
|
|
773
|
+
}
|