merge: 최신 main을 자동 화면 폭 수정에 통합

This commit is contained in:
2026-08-21 01:13:27 +00:00
7 changed files with 304 additions and 67 deletions
@@ -0,0 +1,57 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { commandCityOptions } from '../src/components/command/commandArgumentOptions.ts';
import type { CommandMapData, CommandOption } from '../src/components/command/types.ts';
const cities: CommandOption[] = [
{ value: 20, label: '적국 도시' },
{ value: 30, label: '아국 도시 둘' },
{ value: 40, label: '공백지' },
{ value: 10, label: '아국 도시 하나' },
];
const mapData: CommandMapData = {
year: 200,
month: 1,
startYear: 180,
cityList: [
[10, 8, 0, 1, 1, 1],
[20, 7, 0, 2, 2, 1],
[30, 6, 0, 1, 3, 1],
[40, 5, 0, 0, 4, 1],
],
nationList: [
[1, '아국', '#008000', 10],
[2, '적국', '#800000', 20],
],
myCity: 10,
myNation: 1,
};
void test('발령은 아국 도시를 먼저 두고 적국과 공백지를 원래 순서로 보존한다', () => {
const sorted = commandCityOptions('che_발령', cities, mapData);
assert.deepEqual(
sorted.map((option) => option.value),
[30, 10, 20, 40]
);
assert.deepEqual(
cities.map((option) => option.value),
[20, 30, 40, 10],
'공용 입력 option은 변경하지 않는다'
);
});
void test('다른 도시 대상 명령의 순서는 바꾸지 않는다', () => {
assert.deepEqual(
commandCityOptions('che_출병', cities, mapData).map((option) => option.value),
[20, 30, 40, 10]
);
});
void test('지도 국가 정보가 아직 없으면 발령의 기존 option 순서를 유지한다', () => {
assert.deepEqual(
commandCityOptions('che_발령', cities, null).map((option) => option.value),
[20, 30, 40, 10]
);
});
@@ -4,6 +4,7 @@ import test from 'node:test';
import {
commandArgumentPresentation,
presentedCommandKeys,
resolveCommandArgumentMapTarget,
} from '../src/components/command/commandArgumentPresentation.ts';
const cityCommands = [
@@ -82,3 +83,25 @@ void test('marks the same city and nation target families that Ref renders with
assert.equal(commandArgumentPresentation(commandKey).mapTarget, 'capital', commandKey);
}
});
void test('derives selection maps from the actual city and nation argument contract', () => {
assert.equal(
resolveCommandArgumentMapTarget('future_city_command', [
{ key: 'target', label: '도시', kind: 'select', required: true, optionSource: 'cities' },
]),
'city'
);
assert.equal(
resolveCommandArgumentMapTarget('future_nation_command', [
{ key: 'target', label: '국가', kind: 'select', required: true, optionSource: 'nations' },
]),
'nation'
);
assert.equal(resolveCommandArgumentMapTarget('che_증축', []), 'capital');
assert.equal(
resolveCommandArgumentMapTarget('future_general_command', [
{ key: 'target', label: '장수', kind: 'select', required: true, optionSource: 'generals' },
]),
undefined
);
});