merge: 최신 main을 사용자 군주 자율행동 브랜치에 통합한다
This commit is contained in:
@@ -27,7 +27,7 @@ export const persistYearbookSnapshot = async (
|
||||
transaction.logEntry.findMany({
|
||||
where: {
|
||||
scope: LogScope.SYSTEM,
|
||||
category: LogCategory.ACTION,
|
||||
category: { in: [LogCategory.SUMMARY, LogCategory.ACTION] },
|
||||
year: snapshot.year,
|
||||
month: snapshot.month,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ const cityIds = [991_201, 991_202, 991_203, 991_204, 991_205, 991_206, 991_207];
|
||||
const nationId = 991_201;
|
||||
const yearbookProfile = 'monthly-boundary-pre-persistence';
|
||||
const yearbookServerId = 'monthly-boundary-generation-20260731';
|
||||
const archivedLogTexts = ['월경계 과거 정세', '월경계 과거 행동'];
|
||||
const archivedLogTexts = ['월경계 과거 정세', '월경계 과거 장수 동향', '월경계 과거 호환 행동'];
|
||||
|
||||
integration('monthly pre-update persistence', () => {
|
||||
let db: GamePrismaClient;
|
||||
@@ -78,11 +78,18 @@ integration('monthly pre-update persistence', () => {
|
||||
},
|
||||
{
|
||||
scope: LogScope.SYSTEM,
|
||||
category: LogCategory.ACTION,
|
||||
category: LogCategory.SUMMARY,
|
||||
year: 200,
|
||||
month: 12,
|
||||
text: archivedLogTexts[1]!,
|
||||
},
|
||||
{
|
||||
scope: LogScope.SYSTEM,
|
||||
category: LogCategory.ACTION,
|
||||
year: 200,
|
||||
month: 12,
|
||||
text: archivedLogTexts[2]!,
|
||||
},
|
||||
],
|
||||
});
|
||||
await db.city.createMany({
|
||||
@@ -256,7 +263,7 @@ integration('monthly pre-update persistence', () => {
|
||||
);
|
||||
expect(cityIds.map((id) => yearbookStates.get(id))).toEqual([31, 32, 33, 34, 41, 42, 43]);
|
||||
expect(yearbookRow.globalHistory).toEqual([archivedLogTexts[0]]);
|
||||
expect(yearbookRow.globalAction).toEqual([archivedLogTexts[1]]);
|
||||
expect(yearbookRow.globalAction).toEqual([archivedLogTexts[2], archivedLogTexts[1]]);
|
||||
expect(await db.yearbookHistory.count({ where: { profileName: yearbookProfile } })).toBe(0);
|
||||
} finally {
|
||||
await hooks.close();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import type { GamePrisma } from '@sammo-ts/infra';
|
||||
import { LogCategory, LogScope } from '@sammo-ts/logic';
|
||||
|
||||
import { persistYearbookSnapshot } from '../src/turn/yearbookPersistence.js';
|
||||
|
||||
describe('persistYearbookSnapshot', () => {
|
||||
it('archives canonical summary logs and compatible action logs together in descending ID order', async () => {
|
||||
const findMany = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce([{ text: '천하 동향' }])
|
||||
.mockResolvedValueOnce([{ text: '호환 행동' }, { text: '장수 동향' }]);
|
||||
const upsert = vi.fn().mockResolvedValue(undefined);
|
||||
const transaction = {
|
||||
logEntry: { findMany },
|
||||
yearbookHistory: { upsert },
|
||||
} as unknown as GamePrisma.TransactionClient;
|
||||
|
||||
await persistYearbookSnapshot(transaction, {
|
||||
serverId: 'hwe:generation',
|
||||
sourceId: 0,
|
||||
year: 195,
|
||||
month: 1,
|
||||
map: { year: 195, month: 1 },
|
||||
nations: [],
|
||||
});
|
||||
|
||||
expect(findMany).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
expect.objectContaining({
|
||||
where: {
|
||||
scope: LogScope.SYSTEM,
|
||||
category: { in: [LogCategory.SUMMARY, LogCategory.ACTION] },
|
||||
year: 195,
|
||||
month: 1,
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
})
|
||||
);
|
||||
expect(upsert).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
create: expect.objectContaining({ globalAction: ['호환 행동', '장수 동향'] }),
|
||||
update: expect.objectContaining({ globalAction: ['호환 행동', '장수 동향'] }),
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user