fix(test): 容量合同按 fixture.psql 的 f: 字母表断言(BUG-739)
Independent Staging Quality Gate run 2683 唯一失败: database-consultation-session-capacity 期望 false:session_missing, 实际是 f:session_missing。夹具把 boolean::text 的 false 规范成 psql -A 的 f。 五处期望值对齐既有合同;无 Docker 源码合同锁住 false→f。
This commit is contained in:
@@ -22,6 +22,14 @@ const consultRoute = readFileSync(
|
||||
new URL("../src/app/api/consult/route.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const databaseCapacityTest = readFileSync(
|
||||
new URL("./database-consultation-session-capacity.test.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const postgresFixture = readFileSync(
|
||||
new URL("./helpers/postgres-fixture.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const SESSION_SELECT =
|
||||
"id,title,theme,model_id,messages,session_type,rectification_case_id,chart_profile_id,chart_profile_name,chart_profile_role,updated_at,pinned,archived_at";
|
||||
@@ -286,3 +294,16 @@ test("session-detail JSON at the old ~19-round cap versus the new ~50-round cap"
|
||||
`50/19 size ratio was ${ratio.toFixed(3)} (utf8 ${oldBytes} → ${newBytes})`,
|
||||
);
|
||||
});
|
||||
|
||||
test("live Postgres capacity assertions use fixture.psql's false→f alphabet (BUG-739)", () => {
|
||||
assert.match(
|
||||
postgresFixture,
|
||||
/\.replace\(\/\(\^|:\)false\(\?=:|\$\)\/gm, "\$1f"\)/,
|
||||
);
|
||||
assert.match(databaseCapacityTest, /"f:session_missing"/);
|
||||
assert.match(databaseCapacityTest, /"f:invalid_question_message"/);
|
||||
assert.equal((databaseCapacityTest.match(/"f:session_full"/g) ?? []).length, 3);
|
||||
assert.doesNotMatch(databaseCapacityTest, /"false:session_missing"/);
|
||||
assert.doesNotMatch(databaseCapacityTest, /"false:invalid_question_message"/);
|
||||
assert.doesNotMatch(databaseCapacityTest, /"false:session_full"/);
|
||||
});
|
||||
|
||||
@@ -119,7 +119,7 @@ test("append_consultation_question ignores thinking fields and enforces the phys
|
||||
|
||||
assert.equal(
|
||||
appendQuestion(fixture, userId, "missing-session", "会话不存在"),
|
||||
"false:session_missing",
|
||||
"f:session_missing",
|
||||
);
|
||||
|
||||
seedSession(fixture, userId, "'[]'::jsonb");
|
||||
@@ -132,7 +132,7 @@ test("append_consultation_question ignores thinking fields and enforces the phys
|
||||
|
||||
assert.equal(
|
||||
appendQuestionSql(fixture, userId, "too-long", "repeat('x', 16001)"),
|
||||
"false:invalid_question_message",
|
||||
"f:invalid_question_message",
|
||||
);
|
||||
|
||||
seedSession(fixture, userId, `
|
||||
@@ -215,7 +215,7 @@ test("append_consultation_question ignores thinking fields and enforces the phys
|
||||
assert.ok(quotaPhysical < 1_000_000, `quota-boundary physical JSON was ${quotaPhysical}`);
|
||||
assert.equal(
|
||||
appendQuestionSql(fixture, userId, "quota-full", "repeat('y', 1001)"),
|
||||
"false:session_full",
|
||||
"f:session_full",
|
||||
);
|
||||
assert.equal(
|
||||
fixture.psql(`select jsonb_array_length(messages) from public.chat_sessions where id = '${SESSION_ID}'`),
|
||||
@@ -247,7 +247,7 @@ test("append_consultation_question ignores thinking fields and enforces the phys
|
||||
assert.ok(hugePhysical > 1_000_000, `receipt pad physical JSON was ${hugePhysical}`);
|
||||
assert.equal(
|
||||
appendQuestion(fixture, userId, "physical-full", "正文很短但行已经胀了"),
|
||||
"false:session_full",
|
||||
"f:session_full",
|
||||
);
|
||||
assert.equal(
|
||||
fixture.psql(`select jsonb_array_length(messages) from public.chat_sessions where id = '${SESSION_ID}'`),
|
||||
@@ -265,7 +265,7 @@ test("append_consultation_question ignores thinking fields and enforces the phys
|
||||
`);
|
||||
assert.equal(
|
||||
appendQuestion(fixture, userId, "count-full", "满了就不能再写"),
|
||||
"false:session_full",
|
||||
"f:session_full",
|
||||
);
|
||||
assert.equal(
|
||||
fixture.psql(`select jsonb_array_length(messages) from public.chat_sessions where id = '${SESSION_ID}'`),
|
||||
|
||||
@@ -243,6 +243,8 @@ export function startPostgresFixture(): PostgresFixture {
|
||||
{ encoding: "utf8", env: environment },
|
||||
)
|
||||
.trim()
|
||||
// boolean::text is "false"; psql -A prints "f". Keep colon-joined
|
||||
// results on the t/f alphabet so tests can assert "f:" stably.
|
||||
.replace(/(^|:)false(?=:|$)/gm, "$1f");
|
||||
},
|
||||
psqlAs(role, password, sql) {
|
||||
|
||||
Reference in New Issue
Block a user