Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a4f170fd9 | ||
|
|
0ed2f4a80b | ||
|
|
bebd4848b4 | ||
|
|
8125d68c95 |
No files matched your search
@@ -6,7 +6,7 @@ import { getBillByLevel, LogCategory } from '@sammo-ts/logic';
|
|||||||
import { accessAuthedProcedure } from '../../../trpc.js';
|
import { accessAuthedProcedure } from '../../../trpc.js';
|
||||||
import {
|
import {
|
||||||
loadCrewTypeDisplayNames,
|
loadCrewTypeDisplayNames,
|
||||||
loadItemDisplayNames,
|
loadItemDisplayDetails,
|
||||||
resolveDedicationLevelName,
|
resolveDedicationLevelName,
|
||||||
resolveOfficerLevelName,
|
resolveOfficerLevelName,
|
||||||
sanitizeInternalDisplayCode,
|
sanitizeInternalDisplayCode,
|
||||||
@@ -133,7 +133,7 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
|||||||
typeof constValues.maxDedLevel === 'number' && Number.isFinite(constValues.maxDedLevel)
|
typeof constValues.maxDedLevel === 'number' && Number.isFinite(constValues.maxDedLevel)
|
||||||
? Math.max(0, Math.trunc(constValues.maxDedLevel))
|
? Math.max(0, Math.trunc(constValues.maxDedLevel))
|
||||||
: 30;
|
: 30;
|
||||||
const [personalityNames, domesticNames, warNames, crewTypeNames, itemNames] = await Promise.all([
|
const [personalityNames, domesticNames, warNames, crewTypeNames, itemDetails] = await Promise.all([
|
||||||
loadTraitNames(
|
loadTraitNames(
|
||||||
generalRows.map((general) => general.personalCode),
|
generalRows.map((general) => general.personalCode),
|
||||||
'personality'
|
'personality'
|
||||||
@@ -147,7 +147,7 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
|||||||
'war'
|
'war'
|
||||||
),
|
),
|
||||||
loadCrewTypeDisplayNames(worldState, ctx.profile.id),
|
loadCrewTypeDisplayNames(worldState, ctx.profile.id),
|
||||||
loadItemDisplayNames(
|
loadItemDisplayDetails(
|
||||||
generalRows.flatMap((general) => [
|
generalRows.flatMap((general) => [
|
||||||
general.weaponCode,
|
general.weaponCode,
|
||||||
general.bookCode,
|
general.bookCode,
|
||||||
@@ -158,7 +158,8 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
|||||||
]);
|
]);
|
||||||
const traitName = (code: string, names: Awaited<ReturnType<typeof loadTraitNames>>): string =>
|
const traitName = (code: string, names: Awaited<ReturnType<typeof loadTraitNames>>): string =>
|
||||||
names.get(code)?.name ?? sanitizeInternalDisplayCode(code);
|
names.get(code)?.name ?? sanitizeInternalDisplayCode(code);
|
||||||
const itemName = (code: string): string => itemNames.get(code) ?? sanitizeInternalDisplayCode(code);
|
const itemName = (code: string): string => itemDetails.get(code)?.name ?? sanitizeInternalDisplayCode(code);
|
||||||
|
const itemInfo = (code: string): string => itemDetails.get(code)?.info ?? '';
|
||||||
|
|
||||||
const generals = generalRows.map((general) => {
|
const generals = generalRows.map((general) => {
|
||||||
const meta =
|
const meta =
|
||||||
@@ -225,11 +226,22 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
|||||||
horse: itemName(general.horseCode),
|
horse: itemName(general.horseCode),
|
||||||
item: itemName(general.itemCode),
|
item: itemName(general.itemCode),
|
||||||
},
|
},
|
||||||
|
itemInfo: {
|
||||||
|
weapon: itemInfo(general.weaponCode),
|
||||||
|
book: itemInfo(general.bookCode),
|
||||||
|
horse: itemInfo(general.horseCode),
|
||||||
|
item: itemInfo(general.itemCode),
|
||||||
|
},
|
||||||
traits: {
|
traits: {
|
||||||
personal: traitName(general.personalCode, personalityNames),
|
personal: traitName(general.personalCode, personalityNames),
|
||||||
specialDomestic: traitName(general.specialCode, domesticNames),
|
specialDomestic: traitName(general.specialCode, domesticNames),
|
||||||
specialWar: traitName(general.special2Code, warNames),
|
specialWar: traitName(general.special2Code, warNames),
|
||||||
},
|
},
|
||||||
|
traitInfo: {
|
||||||
|
personal: personalityNames.get(general.personalCode)?.info ?? '',
|
||||||
|
specialDomestic: domesticNames.get(general.specialCode)?.info ?? '',
|
||||||
|
specialWar: warNames.get(general.special2Code)?.info ?? '',
|
||||||
|
},
|
||||||
progression: {
|
progression: {
|
||||||
experienceLevel: metaNumber('explevel'),
|
experienceLevel: metaNumber('explevel'),
|
||||||
dedicationLevel,
|
dedicationLevel,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export interface TurnCommandAvailability {
|
|||||||
name: string;
|
name: string;
|
||||||
turnDurationText?: string;
|
turnDurationText?: string;
|
||||||
costText?: string;
|
costText?: string;
|
||||||
|
statExperienceText?: string;
|
||||||
reqArg: boolean;
|
reqArg: boolean;
|
||||||
possible: boolean;
|
possible: boolean;
|
||||||
status: AvailabilityStatus;
|
status: AvailabilityStatus;
|
||||||
@@ -151,6 +152,39 @@ const REF_GENERAL_COMMAND_GROUPS = [
|
|||||||
commands: ReadonlyArray<GeneralTurnCommandKey>;
|
commands: ReadonlyArray<GeneralTurnCommandKey>;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
// Ref 명령 선택기의 경험 종류를 복원하며, 결과나 병종에 따라 달라지는 경우는 따로 표시한다.
|
||||||
|
const GENERAL_COMMAND_STAT_EXPERIENCE = {
|
||||||
|
'통솔 경험': [
|
||||||
|
'che_강행',
|
||||||
|
'che_귀환',
|
||||||
|
'che_등용',
|
||||||
|
'che_모병',
|
||||||
|
'che_사기진작',
|
||||||
|
'che_선동',
|
||||||
|
'che_숙련전환',
|
||||||
|
'che_이동',
|
||||||
|
'che_전투태세',
|
||||||
|
'che_정착장려',
|
||||||
|
'che_주민선정',
|
||||||
|
'che_증여',
|
||||||
|
'che_집합',
|
||||||
|
'che_징병',
|
||||||
|
'che_첩보',
|
||||||
|
'che_헌납',
|
||||||
|
'che_훈련',
|
||||||
|
'cr_맹훈련',
|
||||||
|
],
|
||||||
|
'무력 경험': ['che_성벽보수', 'che_수비강화', 'che_치안강화', 'che_탈취', 'che_파괴'],
|
||||||
|
'지력 경험': ['che_기술연구', 'che_농지개간', 'che_상업투자', 'che_화계'],
|
||||||
|
'무작위 능력치 경험': ['che_군량매매', 'che_단련', 'che_물자조달', 'che_인재탐색'],
|
||||||
|
'무작위 능력치 경험 가능': ['che_견문'],
|
||||||
|
'병종별 능력치 경험': ['che_출병'],
|
||||||
|
} as const satisfies Record<string, readonly GeneralTurnCommandKey[]>;
|
||||||
|
|
||||||
|
const statExperienceByCommand = new Map<string, string>(
|
||||||
|
Object.entries(GENERAL_COMMAND_STAT_EXPERIENCE).flatMap(([text, keys]) => keys.map((key) => [key, text] as const))
|
||||||
|
);
|
||||||
|
|
||||||
const REF_NATION_COMMAND_GROUPS = [
|
const REF_NATION_COMMAND_GROUPS = [
|
||||||
{
|
{
|
||||||
category: '휴식',
|
category: '휴식',
|
||||||
@@ -858,11 +892,13 @@ const buildGroups = (
|
|||||||
// 개인·국가 모두 실행 정의의 준비 턴과 마지막 실행 턴을 표시한다.
|
// 개인·국가 모두 실행 정의의 준비 턴과 마지막 실행 턴을 표시한다.
|
||||||
const turnDurationText = getTurnDurationText(entry.definition);
|
const turnDurationText = getTurnDurationText(entry.definition);
|
||||||
const costText = getCommandCostText(entry, ctx, view, env);
|
const costText = getCommandCostText(entry, ctx, view, env);
|
||||||
|
const statExperienceText = scope === 'general' ? statExperienceByCommand.get(entry.definition.key) : undefined;
|
||||||
const value: TurnCommandAvailability = {
|
const value: TurnCommandAvailability = {
|
||||||
key: entry.definition.key,
|
key: entry.definition.key,
|
||||||
name: entry.definition.name,
|
name: entry.definition.name,
|
||||||
...(turnDurationText ? { turnDurationText } : {}),
|
...(turnDurationText ? { turnDurationText } : {}),
|
||||||
...(costText ? { costText } : {}),
|
...(costText ? { costText } : {}),
|
||||||
|
...(statExperienceText ? { statExperienceText } : {}),
|
||||||
reqArg: entry.reqArg,
|
reqArg: entry.reqArg,
|
||||||
inputFields: entry.inputFields,
|
inputFields: entry.inputFields,
|
||||||
...availability,
|
...availability,
|
||||||
|
|||||||
@@ -504,6 +504,37 @@ describe('buildTurnCommandTable', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('projects stat experience hints for general commands without promising a fixed stat increase', async () => {
|
||||||
|
const table = await buildTurnCommandTable({
|
||||||
|
worldState: buildWorldState(),
|
||||||
|
general: buildGeneral(),
|
||||||
|
city: buildCity(),
|
||||||
|
nation: buildNation(),
|
||||||
|
nationGenerals: null,
|
||||||
|
});
|
||||||
|
const find = (key: string) => table.general.flatMap(({ values }) => values).find((entry) => entry.key === key);
|
||||||
|
const expected = {
|
||||||
|
che_선동: '통솔 경험',
|
||||||
|
che_탈취: '무력 경험',
|
||||||
|
che_파괴: '무력 경험',
|
||||||
|
che_화계: '지력 경험',
|
||||||
|
che_이동: '통솔 경험',
|
||||||
|
che_수비강화: '무력 경험',
|
||||||
|
che_상업투자: '지력 경험',
|
||||||
|
che_물자조달: '무작위 능력치 경험',
|
||||||
|
che_인재탐색: '무작위 능력치 경험',
|
||||||
|
che_견문: '무작위 능력치 경험 가능',
|
||||||
|
che_출병: '병종별 능력치 경험',
|
||||||
|
};
|
||||||
|
for (const [key, statExperienceText] of Object.entries(expected)) {
|
||||||
|
expect(find(key)).toMatchObject({ statExperienceText });
|
||||||
|
}
|
||||||
|
expect(find('휴식')?.statExperienceText).toBeUndefined();
|
||||||
|
expect(
|
||||||
|
table.nation.flatMap(({ values }) => values).every(({ statExperienceText }) => !statExperienceText)
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('projects the Ref twenty-year non-aggression end-year window', async () => {
|
it('projects the Ref twenty-year non-aggression end-year window', async () => {
|
||||||
const table = await buildTurnCommandTable({
|
const table = await buildTurnCommandTable({
|
||||||
worldState: buildWorldState(),
|
worldState: buildWorldState(),
|
||||||
|
|||||||
@@ -1072,6 +1072,34 @@ describe('battle-center general and user permissions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('projects registered trait and equipment descriptions for battle center viewers', async () => {
|
||||||
|
const me = buildGeneral({ meta: { belong: 3 } });
|
||||||
|
const other = buildGeneral({
|
||||||
|
id: 8,
|
||||||
|
personalCode: 'che_안전',
|
||||||
|
specialCode: 'che_상재',
|
||||||
|
special2Code: 'che_신산',
|
||||||
|
horseCode: 'che_명마_15_적토마',
|
||||||
|
weaponCode: 'unregistered',
|
||||||
|
itemCode: 'che_내정_납금박산로',
|
||||||
|
});
|
||||||
|
const fixture = createContext({ me, targets: [me, other], nationMeta: { secretLimit: 3 } });
|
||||||
|
const result = await appRouter.createCaller(fixture.context).nation.getBattleCenter();
|
||||||
|
|
||||||
|
expect(result.generals.find(({ id }) => id === other.id)).toMatchObject({
|
||||||
|
traitInfo: {
|
||||||
|
personal: expect.stringContaining('징·모병 비용'),
|
||||||
|
specialDomestic: expect.stringContaining('상업 투자'),
|
||||||
|
specialWar: expect.stringContaining('[계략] 화계·탈취·파괴·선동'),
|
||||||
|
},
|
||||||
|
itemInfo: { horse: '통솔 +15', weapon: '', book: '', item: '[내정] 내정 성공률 +15%p' },
|
||||||
|
});
|
||||||
|
expect(result.generals.find(({ id }) => id === me.id)).toMatchObject({
|
||||||
|
traitInfo: { personal: '', specialDomestic: '', specialWar: '' },
|
||||||
|
itemInfo: { horse: '', weapon: '', book: '', item: '' },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('redacts another user action log while allowing own, NPC, chief, and non-private logs', async () => {
|
it('redacts another user action log while allowing own, NPC, chief, and non-private logs', async () => {
|
||||||
const me = buildGeneral({ meta: { belong: 3, permission: 'normal' } });
|
const me = buildGeneral({ meta: { belong: 3, permission: 'normal' } });
|
||||||
const otherUser = buildGeneral({ id: 8, userId: 'user-8', name: '타유저', npcState: 0 });
|
const otherUser = buildGeneral({ id: 8, userId: 'user-8', name: '타유저', npcState: 0 });
|
||||||
|
|||||||
@@ -1545,6 +1545,77 @@ test('shows speciality reset cooldowns and reserves special user commands from t
|
|||||||
await picker.screenshot({ path: test.info().outputPath('special-user-commands-mobile-500.png') });
|
await picker.screenshot({ path: test.info().outputPath('special-user-commands-mobile-500.png') });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('shows stat experience next to strategy commands and preserves reservation on desktop and mobile', async ({
|
||||||
|
page,
|
||||||
|
}, testInfo) => {
|
||||||
|
const strategy = commandTable.general.find(({ category }) => category === '계략')!;
|
||||||
|
const requests = await install(page, false, {
|
||||||
|
general: [
|
||||||
|
{
|
||||||
|
...strategy,
|
||||||
|
values: strategy.values.map((command, index) => ({
|
||||||
|
...command,
|
||||||
|
statExperienceText: ['지력 경험', '통솔 경험', '무력 경험', '무력 경험'][index],
|
||||||
|
costText: '금 500 · 쌀 500',
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
nation: [],
|
||||||
|
inputOptions,
|
||||||
|
});
|
||||||
|
for (const viewport of [
|
||||||
|
{ width: 1365, height: 900 },
|
||||||
|
{ width: 390, height: 844 },
|
||||||
|
]) {
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
await page.goto(gamePath('/'));
|
||||||
|
await page.getByRole('button', { name: '1턴 명령 입력', exact: true }).click();
|
||||||
|
const picker = page.getByTestId('command-picker');
|
||||||
|
const fire = picker.getByRole('button', { name: /화계.*지력 경험/ });
|
||||||
|
await expect(picker.locator('.command-stat-experience')).toHaveText([
|
||||||
|
'(지력 경험)',
|
||||||
|
'(통솔 경험)',
|
||||||
|
'(무력 경험)',
|
||||||
|
'(무력 경험)',
|
||||||
|
]);
|
||||||
|
await expect(fire.locator('.command-cost')).toHaveText('금 500 · 쌀 500');
|
||||||
|
await expect(fire).toHaveClass(/blocked reservable/);
|
||||||
|
await expect(fire).toHaveAttribute('title', '현재 조건에서는 실행할 수 없습니다.');
|
||||||
|
await expect(fire).toBeEnabled();
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
await fire.hover();
|
||||||
|
await fire.focus();
|
||||||
|
await expect(fire).toBeFocused();
|
||||||
|
const geometry = await picker.locator('.command-item').evaluateAll((buttons) =>
|
||||||
|
buttons.map((button) => {
|
||||||
|
const experience = button.querySelector('.command-stat-experience')!;
|
||||||
|
return {
|
||||||
|
button: button.getBoundingClientRect().toJSON(),
|
||||||
|
hint: experience.getBoundingClientRect().toJSON(),
|
||||||
|
overflow: button.scrollWidth - button.clientWidth,
|
||||||
|
hintFont: getComputedStyle(experience).font,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(geometry.every(({ button, hint, overflow }) => overflow <= 0 && hint.right <= button.right)).toBe(true);
|
||||||
|
const artifact = `general-stat-experience-${viewport.width}`;
|
||||||
|
await writeFile(
|
||||||
|
testInfo.outputPath(`${artifact}.json`),
|
||||||
|
JSON.stringify({ url: page.url(), geometry }, null, 2)
|
||||||
|
);
|
||||||
|
await writeFile(testInfo.outputPath(`${artifact}.html`), await picker.evaluate((element) => element.outerHTML));
|
||||||
|
await picker.screenshot({ path: testInfo.outputPath(`${artifact}.png`) });
|
||||||
|
await fire.click();
|
||||||
|
const form = page.getByTestId('command-argument-form');
|
||||||
|
await form.locator('select').first().selectOption('2');
|
||||||
|
await page.getByRole('button', { name: '화계 입력', exact: true }).click();
|
||||||
|
await expect(page.locator('[data-command-scope="general"] .action-column > div').first()).toHaveText(
|
||||||
|
'【허창】에 화계실행'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect(JSON.stringify(requests)).toContain('"action":"che_화계","args":{"destCityId":2}');
|
||||||
|
});
|
||||||
|
|
||||||
test('shows general command durations from metadata on desktop and mobile', async ({ page }) => {
|
test('shows general command durations from metadata on desktop and mobile', async ({ page }) => {
|
||||||
const requests = await install(page, false, {
|
const requests = await install(page, false, {
|
||||||
general: [
|
general: [
|
||||||
|
|||||||
@@ -332,8 +332,14 @@ const battleCenter = (state: FixtureState) => ({
|
|||||||
crewTypeId: 1,
|
crewTypeId: 1,
|
||||||
crewTypeName: '보병',
|
crewTypeName: '보병',
|
||||||
equipment: { weapon: 'None', book: 'None', horse: 'None', item: 'None' },
|
equipment: { weapon: 'None', book: 'None', horse: 'None', item: 'None' },
|
||||||
equipmentNames: { weapon: '-', book: '-', horse: '-', item: '-' },
|
equipmentNames: state.richMyInfo
|
||||||
traits: { personal: '-', specialDomestic: '-', specialWar: '-' },
|
? { weapon: '단도', book: '효경전', horse: '적토마(+15)', item: '납금박산로' }
|
||||||
|
: { weapon: '-', book: '-', horse: '-', item: '-' },
|
||||||
|
itemInfo: state.richMyInfo
|
||||||
|
? { weapon: '무력 +1', book: '지력 +1', horse: '통솔 +15', item: '내정 성공률 +15%p' }
|
||||||
|
: undefined,
|
||||||
|
traits: state.mainTraits ?? { personal: '-', specialDomestic: '-', specialWar: '-' },
|
||||||
|
traitInfo: state.richMyInfo ? myGeneral(state).general.traitInfo : undefined,
|
||||||
progression: {
|
progression: {
|
||||||
experienceLevel: 1,
|
experienceLevel: 1,
|
||||||
dedicationLevel: 2,
|
dedicationLevel: 2,
|
||||||
@@ -387,7 +393,7 @@ const battleCenter = (state: FixtureState) => ({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const install = async (page: Page, state: FixtureState) => {
|
const install = async (page: Page, state: FixtureState, includeAuxiliaryWindows = false) => {
|
||||||
await page.addInitScript(
|
await page.addInitScript(
|
||||||
({ basePath, profile }) => {
|
({ basePath, profile }) => {
|
||||||
if (location.pathname.startsWith(`${basePath}/`)) {
|
if (location.pathname.startsWith(`${basePath}/`)) {
|
||||||
@@ -397,7 +403,8 @@ const install = async (page: Page, state: FixtureState) => {
|
|||||||
},
|
},
|
||||||
{ basePath: gameBasePath, profile: gameProfile }
|
{ basePath: gameBasePath, profile: gameProfile }
|
||||||
);
|
);
|
||||||
await page.route('**/image/game/**', async (route) => {
|
const routeTarget = includeAuxiliaryWindows ? page.context() : page;
|
||||||
|
await routeTarget.route('**/image/game/**', async (route) => {
|
||||||
const filename = basename(new URL(route.request().url()).pathname);
|
const filename = basename(new URL(route.request().url()).pathname);
|
||||||
if (
|
if (
|
||||||
legacyImageRoot &&
|
legacyImageRoot &&
|
||||||
@@ -414,7 +421,7 @@ const install = async (page: Page, state: FixtureState) => {
|
|||||||
}
|
}
|
||||||
await route.fulfill({ status: 200, contentType: 'image/jpeg', body: Buffer.from('') });
|
await route.fulfill({ status: 200, contentType: 'image/jpeg', body: Buffer.from('') });
|
||||||
});
|
});
|
||||||
await page.route(gameTrpcRoute, async (route) => {
|
await routeTarget.route(gameTrpcRoute, async (route) => {
|
||||||
const operations = operationNames(route);
|
const operations = operationNames(route);
|
||||||
const rawRequestBody: unknown = route.request().postData() ? route.request().postDataJSON() : {};
|
const rawRequestBody: unknown = route.request().postData() ? route.request().postDataJSON() : {};
|
||||||
const requestBody =
|
const requestBody =
|
||||||
@@ -671,6 +678,28 @@ const install = async (page: Page, state: FixtureState) => {
|
|||||||
if (pageName) state.accessPages.push(pageName);
|
if (pageName) state.accessPages.push(pageName);
|
||||||
return response({ recorded: true });
|
return response({ recorded: true });
|
||||||
}
|
}
|
||||||
|
if (operation === 'nation.getGeneralList') {
|
||||||
|
const center = battleCenter(state);
|
||||||
|
return response({
|
||||||
|
nation: center.nation,
|
||||||
|
viewer: { generalId: center.me.id, permission: center.me.permissionLevel },
|
||||||
|
generals: center.generals.map((general) => ({
|
||||||
|
...general,
|
||||||
|
experienceLevel: general.progression.experienceLevel,
|
||||||
|
dedicationText: general.progression.dedicationText,
|
||||||
|
honorText: '무명',
|
||||||
|
cityName: '업',
|
||||||
|
belong: general.serviceYears,
|
||||||
|
refreshScoreTotal: 0,
|
||||||
|
reservedCommands: [],
|
||||||
|
battleStats: {
|
||||||
|
...general.battleStats,
|
||||||
|
battles: general.warnum,
|
||||||
|
wins: general.battleStats.kills,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
||||||
if (operation === 'nation.getBattleCenter') {
|
if (operation === 'nation.getBattleCenter') {
|
||||||
if (state.permission === 'member' && !state.battleTenured) {
|
if (state.permission === 'member' && !state.battleTenured) {
|
||||||
return {
|
return {
|
||||||
@@ -2627,6 +2656,129 @@ test('감찰부 keeps the selector interaction and shows the permission error pa
|
|||||||
await expect(page.getByRole('alert')).toContainText('권한이 부족합니다.');
|
await expect(page.getByRole('alert')).toContainText('권한이 부족합니다.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('세력장수 이름 링크는 선택한 장수의 감찰부를 열고 목록 검색을 보존한다', async ({ page, context }) => {
|
||||||
|
const state: FixtureState = {
|
||||||
|
permission: 'member',
|
||||||
|
battleTenured: true,
|
||||||
|
myset: 3,
|
||||||
|
settingMutations: [],
|
||||||
|
accessPages: [],
|
||||||
|
};
|
||||||
|
await install(page, state, true);
|
||||||
|
for (const viewport of [
|
||||||
|
{ width: 1365, height: 900 },
|
||||||
|
{ width: 390, height: 844 },
|
||||||
|
]) {
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
await page.goto('nation/generals');
|
||||||
|
const filter = page.getByLabel('장수명 필터');
|
||||||
|
await expect(filter).toBeVisible();
|
||||||
|
await filter.fill('검증장수');
|
||||||
|
const link = page.getByRole('link', { name: '검증장수' });
|
||||||
|
await expect(link).toHaveAttribute('href', `${gameBasePath}/battle-center?generalId=7`);
|
||||||
|
await expect(link).toHaveCSS('text-decoration-line', 'underline');
|
||||||
|
await link.hover();
|
||||||
|
await expect(link).toHaveCSS('cursor', 'pointer');
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
await link.focus();
|
||||||
|
await expect(link).toHaveCSS('outline-style', 'solid');
|
||||||
|
await waitForVisualAssets(page);
|
||||||
|
await persistParityArtifact(
|
||||||
|
page,
|
||||||
|
`nation-generals-battle-link-${viewport.width}`,
|
||||||
|
await link.evaluate((element) => ({
|
||||||
|
url: location.href,
|
||||||
|
link: element.outerHTML,
|
||||||
|
cell: element.parentElement!.getBoundingClientRect().toJSON(),
|
||||||
|
rect: element.getBoundingClientRect().toJSON(),
|
||||||
|
color: getComputedStyle(element).color,
|
||||||
|
outline: getComputedStyle(element).outline,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
|
const opened = context.waitForEvent('page');
|
||||||
|
if (viewport.width > 500) await link.press('Enter');
|
||||||
|
else await link.click();
|
||||||
|
const battle = await opened;
|
||||||
|
await battle.setViewportSize(viewport);
|
||||||
|
await expect(battle).toHaveURL(new RegExp(`${gameBasePath}/battle-center\\?generalId=7$`));
|
||||||
|
await expect(battle.locator('.selector-row select').nth(1)).toHaveValue('7');
|
||||||
|
await expect(battle.locator('.battle-general-card')).toContainText('검증장수');
|
||||||
|
await battle.reload();
|
||||||
|
await expect(battle.locator('.battle-general-card')).toContainText('검증장수');
|
||||||
|
await Promise.all([
|
||||||
|
battle.waitForEvent('close'),
|
||||||
|
battle.getByRole('button', { name: '창 닫기' }).first().click(),
|
||||||
|
]);
|
||||||
|
await expect(filter).toHaveValue('검증장수');
|
||||||
|
await expect(page.locator('#nation-general-list tbody tr')).toHaveCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.battleTenured = false;
|
||||||
|
await page.reload();
|
||||||
|
await expect(page.locator('#nation-general-list [data-general-name]').first()).toBeVisible();
|
||||||
|
await expect(page.locator('#nation-general-list a[data-general-name]')).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('감찰부 특기와 장비는 마우스와 키보드로 설명을 확인할 수 있다', async ({ page }) => {
|
||||||
|
const state: FixtureState = {
|
||||||
|
permission: 'head',
|
||||||
|
myset: 3,
|
||||||
|
richMyInfo: true,
|
||||||
|
mainTraits: { personal: '안전', specialDomestic: '상재', specialWar: '신산' },
|
||||||
|
settingMutations: [],
|
||||||
|
accessPages: [],
|
||||||
|
};
|
||||||
|
await install(page, state);
|
||||||
|
const card = page.locator('.battle-general-card');
|
||||||
|
const tooltip = page.locator('.tippy-box[data-state="visible"]');
|
||||||
|
for (const viewport of [
|
||||||
|
{ width: 1365, height: 900 },
|
||||||
|
{ width: 390, height: 844 },
|
||||||
|
]) {
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
await page.goto('battle-center?generalId=7');
|
||||||
|
await expect(card).toContainText('검증장수');
|
||||||
|
await waitForVisualAssets(page);
|
||||||
|
const cardBefore = await card.boundingBox();
|
||||||
|
for (const [id, description] of [
|
||||||
|
['special-domestic', '상업 내정 효율이 증가합니다.'],
|
||||||
|
['special-war', '계략 성공률이 증가합니다.'],
|
||||||
|
['horse', '통솔 +15'],
|
||||||
|
['item', '내정 성공률 +15%p'],
|
||||||
|
]) {
|
||||||
|
const trigger = card.locator(`[data-rich-tooltip="${id}"]`);
|
||||||
|
await trigger.hover();
|
||||||
|
await expect(trigger).toHaveCSS('cursor', 'help');
|
||||||
|
await expect(tooltip).toContainText(description);
|
||||||
|
await page.mouse.move(1, 1);
|
||||||
|
await expect(tooltip).toHaveCount(0);
|
||||||
|
}
|
||||||
|
const war = card.locator('[data-rich-tooltip="special-war"]');
|
||||||
|
await war.focus();
|
||||||
|
await expect(war).toBeFocused();
|
||||||
|
await expect(tooltip.locator('.rich-tooltip-content__line')).toHaveText([
|
||||||
|
'계략 성공률이 증가합니다.',
|
||||||
|
'발동 순서는 레거시와 같습니다.',
|
||||||
|
]);
|
||||||
|
const cardAfter = await card.boundingBox();
|
||||||
|
expect(cardAfter?.width).toBe(cardBefore?.width);
|
||||||
|
expect(cardAfter?.height).toBe(cardBefore?.height);
|
||||||
|
await persistParityArtifact(page, `battle-center-description-${viewport.width}`, {
|
||||||
|
url: page.url(),
|
||||||
|
card: cardAfter,
|
||||||
|
trigger: await war.boundingBox(),
|
||||||
|
tooltip: await tooltip.boundingBox(),
|
||||||
|
font: await tooltip.evaluate((element) => getComputedStyle(element).font),
|
||||||
|
markup: await tooltip.innerHTML(),
|
||||||
|
});
|
||||||
|
await page.locator('.selector-row select').nth(1).selectOption('8');
|
||||||
|
await expect(card).toContainText('다른장수');
|
||||||
|
await expect(war).not.toHaveAttribute('tabindex', '0');
|
||||||
|
await expect(tooltip).toHaveCount(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('감찰부 하단 창 닫기 버튼은 상단 버튼과 같은 크기를 유지한다', async ({ page }) => {
|
test('감찰부 하단 창 닫기 버튼은 상단 버튼과 같은 크기를 유지한다', async ({ page }) => {
|
||||||
const head: FixtureState = { permission: 'head', myset: 3, settingMutations: [], accessPages: [] };
|
const head: FixtureState = { permission: 'head', myset: 3, settingMutations: [], accessPages: [] };
|
||||||
await install(page, head);
|
await install(page, head);
|
||||||
|
|||||||
@@ -461,12 +461,29 @@ test('personnel selects an informed general and reports the JosaUtil-composed re
|
|||||||
/허저/,
|
/허저/,
|
||||||
/장료/,
|
/장료/,
|
||||||
]);
|
]);
|
||||||
await picker.getByPlaceholder('장수명·도시·관직·특성 검색').fill('장료');
|
const search = picker.getByPlaceholder('장수명·도시·관직·특성 검색');
|
||||||
|
const vacancy = picker.getByRole('button', { name: /공석으로 두기/ });
|
||||||
|
await expect(vacancy).toBeVisible();
|
||||||
|
await search.fill(' ');
|
||||||
|
await expect(vacancy).toBeVisible();
|
||||||
|
await search.fill('허창');
|
||||||
|
await expect(vacancy).toHaveCount(0);
|
||||||
|
expect(await picker.locator('.personnel-picker-card').count()).toBeGreaterThan(1);
|
||||||
|
await search.fill('없는장수');
|
||||||
|
await expect(vacancy).toHaveCount(0);
|
||||||
|
await expect(picker.getByText('검색 조건에 맞는 후보가 없습니다.')).toBeVisible();
|
||||||
|
await search.clear();
|
||||||
|
await expect(vacancy).toBeVisible();
|
||||||
|
await search.fill('장료');
|
||||||
|
await expect(vacancy).toHaveCount(0);
|
||||||
const candidate = picker.getByRole('button', { name: /장료/ });
|
const candidate = picker.getByRole('button', { name: /장료/ });
|
||||||
await expect(candidate).toContainText('허창 · 일반 장수');
|
await expect(candidate).toContainText('허창 · 일반 장수');
|
||||||
await expect(candidate).toContainText('통솔70');
|
await expect(candidate).toContainText('통솔70');
|
||||||
await expect(candidate).toContainText('소속10년');
|
await expect(candidate).toContainText('소속10년');
|
||||||
await expect(candidate).toContainText('병력100');
|
await expect(candidate).toContainText('병력100');
|
||||||
|
await search.press('Tab');
|
||||||
|
await expect(candidate).toBeFocused();
|
||||||
|
expect(state.appointedGeneralId).toBeUndefined();
|
||||||
await candidate.hover();
|
await candidate.hover();
|
||||||
expect(await candidate.evaluate((button) => getComputedStyle(button).cursor)).toBe('pointer');
|
expect(await candidate.evaluate((button) => getComputedStyle(button).cursor)).toBe('pointer');
|
||||||
await candidate.focus();
|
await candidate.focus();
|
||||||
@@ -590,6 +607,52 @@ test('personnel reflows row-level appointments at 500px and 390px without gradie
|
|||||||
await screenshot(page, 'core-personnel-mobile-rows.png');
|
await screenshot(page, 'core-personnel-mobile-rows.png');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('personnel hides vacancy during mobile search and keeps intentional vacancy available after clearing', async ({
|
||||||
|
page,
|
||||||
|
}, testInfo) => {
|
||||||
|
const state: FixtureState = { role: 'head', rate: 20 };
|
||||||
|
await installFixture(page, state);
|
||||||
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await gotoOffice(page, 'nation/personnel');
|
||||||
|
const change = page.getByRole('button', { name: '허창 태수 변경하기', exact: true });
|
||||||
|
await change.click();
|
||||||
|
const picker = page.getByTestId('personnel-selection-dialog');
|
||||||
|
const search = picker.getByRole('searchbox');
|
||||||
|
const vacancy = picker.getByRole('button', { name: /공석으로 두기/ });
|
||||||
|
await expect(search).toBeFocused();
|
||||||
|
await expect(vacancy).toBeVisible();
|
||||||
|
await search.fill('장료');
|
||||||
|
await expect(picker.getByRole('button', { name: /장료/ })).toBeVisible();
|
||||||
|
await expect(vacancy).toHaveCount(0);
|
||||||
|
await expect(picker).toHaveCSS('transform', 'none');
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
const geometry = await picker.evaluate((element) => ({
|
||||||
|
url: location.href,
|
||||||
|
rect: element.getBoundingClientRect().toJSON(),
|
||||||
|
overflow: element.scrollWidth - element.clientWidth,
|
||||||
|
candidateFont: getComputedStyle(element.querySelector('.personnel-picker-card')!).font,
|
||||||
|
}));
|
||||||
|
expect(geometry.overflow).toBeLessThanOrEqual(0);
|
||||||
|
await writeFile(testInfo.outputPath('personnel-search-mobile.json'), JSON.stringify(geometry, null, 2));
|
||||||
|
await writeFile(testInfo.outputPath('personnel-search-mobile.html'), await picker.evaluate((el) => el.outerHTML));
|
||||||
|
await screenshot(page, 'personnel-search-mobile.png');
|
||||||
|
await search.press('Escape');
|
||||||
|
await expect(picker).toBeHidden();
|
||||||
|
await expect(change).toBeFocused();
|
||||||
|
expect(state.appointedGeneralId).toBeUndefined();
|
||||||
|
|
||||||
|
await change.click();
|
||||||
|
await search.fill('장료');
|
||||||
|
await expect(vacancy).toHaveCount(0);
|
||||||
|
await search.clear();
|
||||||
|
await vacancy.click();
|
||||||
|
await acceptAppConfirmation(page, '허창 태수직을 비우시겠습니까?');
|
||||||
|
await expect(page.getByTestId('game-toast')).toContainText('관직을 비웠습니다.');
|
||||||
|
expect(state.appointedGeneralId).toBe(0);
|
||||||
|
expect(state.appointedCityId).toBe(1);
|
||||||
|
expect(state.appointedOfficerLevel).toBe(4);
|
||||||
|
});
|
||||||
|
|
||||||
test('personnel chooses a kick target in the informed picker and double-confirms a user general', async ({ page }) => {
|
test('personnel chooses a kick target in the informed picker and double-confirms a user general', async ({ page }) => {
|
||||||
const state: FixtureState = { role: 'head', rate: 20 };
|
const state: FixtureState = { role: 'head', rate: 20 };
|
||||||
await installFixture(page, state);
|
await installFixture(page, state);
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ export type CommandAvailability = {
|
|||||||
name: string;
|
name: string;
|
||||||
turnDurationText?: string;
|
turnDurationText?: string;
|
||||||
costText?: string;
|
costText?: string;
|
||||||
|
statExperienceText?: string;
|
||||||
reqArg: boolean;
|
reqArg: boolean;
|
||||||
status: 'available' | 'blocked' | 'needsInput' | 'unknown';
|
status: 'available' | 'blocked' | 'needsInput' | 'unknown';
|
||||||
possible: boolean;
|
possible: boolean;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import type { CommandAvailability, CommandGroup, CommandTable } from '../command/types';
|
||||||
import SkeletonLines from '../ui/SkeletonLines.vue';
|
import SkeletonLines from '../ui/SkeletonLines.vue';
|
||||||
|
|
||||||
type CommandAvailability = {
|
|
||||||
key: string;
|
|
||||||
name: string;
|
|
||||||
turnDurationText?: string;
|
|
||||||
costText?: string;
|
|
||||||
reqArg: boolean;
|
|
||||||
status: 'available' | 'blocked' | 'needsInput' | 'unknown';
|
|
||||||
possible: boolean;
|
|
||||||
reason?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CommandGroup = {
|
|
||||||
category: string;
|
|
||||||
values: CommandAvailability[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type CommandTable = {
|
|
||||||
general: CommandGroup[];
|
|
||||||
nation: CommandGroup[];
|
|
||||||
};
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
commandTable: CommandTable | null;
|
commandTable: Pick<CommandTable, 'general' | 'nation'> | null;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
activeCategory?: string;
|
activeCategory?: string;
|
||||||
scope?: 'all' | 'general' | 'nation';
|
scope?: 'all' | 'general' | 'nation';
|
||||||
@@ -162,7 +142,12 @@ const commandTitle = (command: CommandAvailability) =>
|
|||||||
:title="commandTitle(command)"
|
:title="commandTitle(command)"
|
||||||
@click="emit('select', command.key)"
|
@click="emit('select', command.key)"
|
||||||
>
|
>
|
||||||
|
<span class="command-heading">
|
||||||
<span class="command-name">{{ command.name }}</span>
|
<span class="command-name">{{ command.name }}</span>
|
||||||
|
<small v-if="command.statExperienceText" class="command-stat-experience">
|
||||||
|
({{ command.statExperienceText }})
|
||||||
|
</small>
|
||||||
|
</span>
|
||||||
<small v-if="command.turnDurationText" class="command-duration">
|
<small v-if="command.turnDurationText" class="command-duration">
|
||||||
/{{ command.turnDurationText }}
|
/{{ command.turnDurationText }}
|
||||||
</small>
|
</small>
|
||||||
@@ -249,6 +234,13 @@ const commandTitle = (command: CommandAvailability) =>
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.command-stat-experience {
|
||||||
|
display: inline-block;
|
||||||
|
margin-inline-start: 0.3em;
|
||||||
|
font-size: var(--sammo-font-size-smaller);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.command-duration {
|
.command-duration {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: var(--sammo-font-size-small);
|
font-size: var(--sammo-font-size-small);
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
<div class="personnel-picker-results" aria-label="선택 후보">
|
<div class="personnel-picker-results" aria-label="선택 후보">
|
||||||
<button
|
<button
|
||||||
v-if="vacancyLabel"
|
v-if="vacancyLabel && !normalizedQuery"
|
||||||
type="button"
|
type="button"
|
||||||
class="personnel-picker-card vacancy-card"
|
class="personnel-picker-card vacancy-card"
|
||||||
:class="{ selected: selectedId === 0 }"
|
:class="{ selected: selectedId === 0 }"
|
||||||
|
|||||||
@@ -978,10 +978,21 @@ onBeforeUnmount(() => {
|
|||||||
<template v-else-if="column.id === 'belong'">{{ general.belong }}년</template>
|
<template v-else-if="column.id === 'belong'">{{ general.belong }}년</template>
|
||||||
<template v-else-if="column.id === 'age'">{{ general.age }}세</template>
|
<template v-else-if="column.id === 'age'">{{ general.age }}세</template>
|
||||||
<template v-else-if="column.id === 'name'">
|
<template v-else-if="column.id === 'name'">
|
||||||
<span data-general-name :style="{ color: getNpcColor(general.npcState) }">{{
|
<RouterLink
|
||||||
|
v-if="data && data.viewer.permission >= 1"
|
||||||
|
class="general-name-link"
|
||||||
|
:to="{ name: 'battle-center', query: { generalId: general.id } }"
|
||||||
|
:style="{ color: getNpcColor(general.npcState) }"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener"
|
||||||
|
title="감찰부에서 보기 (새 탭)"
|
||||||
|
data-general-name
|
||||||
|
>{{ general.name }}</RouterLink
|
||||||
|
>
|
||||||
|
<span v-else data-general-name :style="{ color: getNpcColor(general.npcState) }">{{
|
||||||
general.name
|
general.name
|
||||||
}}</span
|
}}</span>
|
||||||
><template v-if="general.ownerName"
|
<template v-if="general.ownerName"
|
||||||
><br /><small>({{ general.ownerName }})</small></template
|
><br /><small>({{ general.ownerName }})</small></template
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
@@ -1370,6 +1381,14 @@ td {
|
|||||||
color: skyblue;
|
color: skyblue;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
.general-name-link {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.general-name-link:focus-visible {
|
||||||
|
outline: 1px solid currentColor;
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
.numeric-cell {
|
.numeric-cell {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user