Archived
修复轮1:mail 账号列表排序键还原为 name(与 channel/llm 惯例一致),测试改断言集合而非顺序
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TM4kUBvekALu9qqmp7D3wr
This commit is contained in:
@@ -72,7 +72,13 @@ describe.skipIf(database === undefined)('mail store(真 PG)', () => {
|
|||||||
expect((await store.get('acc-a'))?.isDefault).toBe(false);
|
expect((await store.get('acc-a'))?.isDefault).toBe(false);
|
||||||
expect((await store.get('acc-b'))?.isDefault).toBe(true);
|
expect((await store.get('acc-b'))?.isDefault).toBe(true);
|
||||||
expect((await store.findByName('甲'))?.id).toBe('acc-a');
|
expect((await store.findByName('甲'))?.id).toBe('acc-a');
|
||||||
expect((await store.list()).map((a) => a.id)).toEqual(['acc-a', 'acc-b']);
|
/*
|
||||||
|
* 排序键是 name(与 channel / llm 两个 store 同惯例:这份清单是运营面给人看的账号列表)。
|
||||||
|
* 中文名的先后依 PG 的 collation 而定 —— 本机 en_US.utf8 与 alpine 的 C 都按码点把「乙」排在「甲」前,
|
||||||
|
* 而 ICU 的中文 collation 按拼音会反过来。所以这里断言**集合**,不断言序:
|
||||||
|
* 这条用例要验的是「两个账号都回来了」,不是「谁在前」。
|
||||||
|
*/
|
||||||
|
expect((await store.list()).map((a) => a.id).sort()).toEqual(['acc-a', 'acc-b']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('游标 jsonb 存取回来还是同一形;savePoll 只改给了的列', async () => {
|
it('游标 jsonb 存取回来还是同一形;savePoll 只改给了的列', async () => {
|
||||||
|
|||||||
@@ -78,13 +78,7 @@ function accountValues(record: MailAccountRecord): typeof mailAccountTable.$infe
|
|||||||
export function createMailAccountStore(db: Db): MailAccountStore {
|
export function createMailAccountStore(db: Db): MailAccountStore {
|
||||||
return {
|
return {
|
||||||
async list() {
|
async list() {
|
||||||
/*
|
const rows = await db.select().from(mailAccountTable).orderBy(mailAccountTable.name);
|
||||||
* 按 id 排序,不按 name:name 是人填的中文,数据库默认 collation(en_US.utf8/C)
|
|
||||||
* 按码点比较,不是拼音 —— 「甲」(U+7532)反而排在「乙」(U+4E59)后面,
|
|
||||||
* 与直觉「甲比乙靠前」相反(实测钉住,brief 原按 name 排序在本机会导致
|
|
||||||
* 账号:save/get/findByName/list 那条用例的 list() 顺序断言失败)。id 排序稳定、不受地域字符集影响。
|
|
||||||
*/
|
|
||||||
const rows = await db.select().from(mailAccountTable).orderBy(mailAccountTable.id);
|
|
||||||
return rows.map(toAccount);
|
return rows.map(toAccount);
|
||||||
},
|
},
|
||||||
async get(id) {
|
async get(id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user