feat: expose archived general histories
This commit is contained in:
@@ -41,14 +41,51 @@ const context = (session: GameSessionTokenPayload | null): GameApiContext => {
|
||||
turnTime: new Date('2025-01-01T00:00:00.000Z'),
|
||||
data: {
|
||||
nation: 3,
|
||||
leadership: 80,
|
||||
strength: 70,
|
||||
leader: 80,
|
||||
power: 70,
|
||||
intel: 60,
|
||||
personal: 'che_의리',
|
||||
officer_level: 8,
|
||||
personal: 3,
|
||||
history: '<C>●</>첫 기록<br><Y>●</>둘째 기록<br>',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
serverId: 'che_legacy_1',
|
||||
generalNo: 11,
|
||||
owner: 'user-1',
|
||||
name: '현재형장수',
|
||||
lastYearMonth: 22012,
|
||||
turnTime: new Date('2025-01-01T00:00:00.000Z'),
|
||||
data: {
|
||||
nationId: 3,
|
||||
stats: { leadership: 81, strength: 71, intelligence: 61 },
|
||||
officerLevel: 7,
|
||||
role: {
|
||||
personality: 'che_의리',
|
||||
specialDomestic: 'che_상재',
|
||||
specialWar: 'che_신산',
|
||||
},
|
||||
history: ['<C>●</>현재형 기록'],
|
||||
},
|
||||
},
|
||||
]
|
||||
: [],
|
||||
findFirst: async ({ where }: { where: { owner: string; serverId: string; generalNo: number } }) =>
|
||||
where.owner === 'user-1' && where.serverId === 'che_legacy_1' && where.generalNo === 10
|
||||
? {
|
||||
id: 1,
|
||||
serverId: 'che_legacy_1',
|
||||
generalNo: 10,
|
||||
owner: 'user-1',
|
||||
name: '과거장수',
|
||||
lastYearMonth: 22012,
|
||||
turnTime: new Date('2025-01-01T00:00:00.000Z'),
|
||||
data: {
|
||||
history: '<C>●</>첫 기록<br><Y>●</>둘째 기록<br>',
|
||||
},
|
||||
}
|
||||
: null,
|
||||
},
|
||||
gameHistory: {
|
||||
findMany: async () => [
|
||||
@@ -77,6 +114,9 @@ const context = (session: GameSessionTokenPayload | null): GameApiContext => {
|
||||
},
|
||||
],
|
||||
},
|
||||
emperor: {
|
||||
findMany: async () => [{ id: 7, serverId: 'che_legacy_1' }],
|
||||
},
|
||||
};
|
||||
const redis = {
|
||||
get: async () => null,
|
||||
@@ -108,14 +148,56 @@ describe('archive.myPastPlays', () => {
|
||||
expect.objectContaining({
|
||||
serverId: 'che_legacy_1',
|
||||
scenarioName: '테스트',
|
||||
dynastyId: 7,
|
||||
generals: [
|
||||
expect.objectContaining({
|
||||
name: '과거장수',
|
||||
nationName: '촉',
|
||||
leadership: 80,
|
||||
strength: 70,
|
||||
officerLevel: 8,
|
||||
personal: '3',
|
||||
historyCount: 2,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
name: '현재형장수',
|
||||
nationName: '촉',
|
||||
leadership: 81,
|
||||
strength: 71,
|
||||
intel: 61,
|
||||
officerLevel: 7,
|
||||
personal: 'che_의리',
|
||||
special: 'che_상재',
|
||||
special2: 'che_신산',
|
||||
historyCount: 1,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('loads archived history only for a general owned by the authenticated session', async () => {
|
||||
const input = { serverId: 'che_legacy_1', generalNo: 10 };
|
||||
await expect(appRouter.createCaller(context(null)).archive.myPastPlayDetail(input)).rejects.toMatchObject({
|
||||
code: 'UNAUTHORIZED',
|
||||
});
|
||||
|
||||
const result = await appRouter.createCaller(context(auth)).archive.myPastPlayDetail(input);
|
||||
expect(result).toEqual({
|
||||
serverId: 'che_legacy_1',
|
||||
generalNo: 10,
|
||||
name: '과거장수',
|
||||
lastYearMonth: 22012,
|
||||
history: ['<C>●</>첫 기록', '<Y>●</>둘째 기록'],
|
||||
});
|
||||
|
||||
const otherUser = {
|
||||
...auth,
|
||||
sessionId: 'other-session',
|
||||
user: { ...auth.user, id: 'user-2', username: 'user-2' },
|
||||
};
|
||||
await expect(appRouter.createCaller(context(otherUser)).archive.myPastPlayDetail(input)).rejects.toMatchObject({
|
||||
code: 'NOT_FOUND',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user