From eb6e7b2f5b56baa95ec6769fd4c0e938fe342139 Mon Sep 17 00:00:00 2001 From: Junya Ishihara Date: Mon, 5 Oct 2026 13:47:48 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E7=9F=A5=E3=82=89=E3=81=9B=E6=AC=84?= =?UTF-8?q?=E3=81=AE=E7=89=B9=E5=88=A5=E3=82=B7=E3=83=95=E3=83=88=E3=81=AE?= =?UTF-8?q?=E6=97=A5=E4=BB=98=E3=81=A8=E6=99=82=E9=96=93=E5=B8=AF=E3=81=AE?= =?UTF-8?q?=E9=96=93=E9=9A=94=E3=82=92=E8=A9=B0=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit お知らせ欄の特別シフト募集表示で、日付と時間帯を全角スペースで区切っていたため 「2026-10-08 12:30-15:30」のように間が空きすぎて見えていた。 半角スペース 1 つで区切るようにした。 旧: (2026-10-08 12:30-15:30) 新: (2026-10-08 12:30-15:30) 日時文字列の組み立てを formatSpecialShiftSchedule() に切り出し、 js/modules/specialShifts.js にエクスポートガードを追加して、テストから実コードを 直接 import して検証している(docs/refactoring/phase-1-test-foundation.md の方針)。 ブラウザでは module が未定義のため no-op。 テスト: 424 passed (32 suites) Co-Authored-By: Claude Opus 5.5 --- js/modules/specialShifts.js | 19 ++++++++++++++- ...special-shift-announcement-spacing.test.js | 24 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/special-shift-announcement-spacing.test.js diff --git a/js/modules/specialShifts.js b/js/modules/specialShifts.js index a376a4c..bac31ba 100644 --- a/js/modules/specialShifts.js +++ b/js/modules/specialShifts.js @@ -229,6 +229,16 @@ async function loadSpecialShifts() { } } +/** + * お知らせ欄に表示する特別シフトの日時文字列を組み立てる + * 日付と時間帯は半角スペース 1 つで区切る(全角だと間が空きすぎて見える) + * @param {{date: string, start_time: string, end_time: string}} shift + * @returns {string} 例: "2026-10-08 12:30-15:30" + */ +function formatSpecialShiftSchedule(shift) { + return `${shift.date} ${shift.start_time}-${shift.end_time}`; +} + /** * 特別シフト募集お知らせを表示する関数(一般ユーザー向け) */ @@ -263,7 +273,7 @@ function displaySpecialShiftAnnouncement() { list.innerHTML = futureShifts.map(shift => { const name = shift.name || '名称未設定'; const dateKey = normalizeShiftDate(shift.date); - return `
  • 「${escapeHtml(name)}」の特別シフトを募集中(${escapeHtml(shift.date)} ${escapeHtml(shift.start_time)}-${escapeHtml(shift.end_time)})
  • `; + return `
  • 「${escapeHtml(name)}」の特別シフトを募集中(${escapeHtml(formatSpecialShiftSchedule(shift))})
  • `; }).join(''); list.querySelectorAll('.announcement-link').forEach(link => { @@ -578,3 +588,10 @@ async function handleDeleteSpecialShiftFromList(event) { button.textContent = originalText; } } + +// テストから実コードを検証できるようにするエクスポートガード +// (ブラウザでは module が未定義のため no-op になる) +// 方針: docs/refactoring/phase-1-test-foundation.md +if (typeof module !== 'undefined' && module.exports) { + module.exports = { formatSpecialShiftSchedule }; +} diff --git a/test/special-shift-announcement-spacing.test.js b/test/special-shift-announcement-spacing.test.js new file mode 100644 index 0000000..f055076 --- /dev/null +++ b/test/special-shift-announcement-spacing.test.js @@ -0,0 +1,24 @@ +/** + * お知らせ欄の特別シフト表示: 日付と時間帯の間隔 + * + * 回帰防止: 日付と時間帯を全角スペースで区切っていたため、 + * 「2026-10-08 12:30-15:30」のように間が空きすぎて見えていた。 + * 半角スペース 1 つで区切る。 + * + * このテストは実コード(js/modules/specialShifts.js)を直接 import して検証する。 + * 方針: docs/refactoring/phase-1-test-foundation.md + */ + +const { formatSpecialShiftSchedule } = require('../js/modules/specialShifts.js'); + +describe('お知らせ欄の特別シフトの日時表示', () => { + const shift = { date: '2026-10-08', start_time: '12:30', end_time: '15:30' }; + + test('日付と時間帯を半角スペース 1 つで区切る', () => { + expect(formatSpecialShiftSchedule(shift)).toBe('2026-10-08 12:30-15:30'); + }); + + test('全角スペースを含まない', () => { + expect(formatSpecialShiftSchedule(shift)).not.toContain(' '); + }); +});