diff --git a/apps/mattermost/app/components/formatted_date/__snapshots__/index.test.tsx.snap b/apps/mattermost/app/components/formatted_date/__snapshots__/index.test.tsx.snap index be074c85..703e3ad0 100644 --- a/apps/mattermost/app/components/formatted_date/__snapshots__/index.test.tsx.snap +++ b/apps/mattermost/app/components/formatted_date/__snapshots__/index.test.tsx.snap @@ -374,13 +374,13 @@ exports[` should match snapshot for 'ko' locale and '{"dateStyle exports[` should match snapshot for 'ko' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` - 2024년 10월 26일 AM 10:01 + 2024년 10월 26일 오전 10:01 `; exports[` should match snapshot for 'ko' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` - 10월 26일 AM 10:01 + 10월 26일 오전 10:01 `; diff --git a/apps/mattermost/app/components/formatted_date/index.test.tsx b/apps/mattermost/app/components/formatted_date/index.test.tsx index 601c97b7..fd441a9e 100644 --- a/apps/mattermost/app/components/formatted_date/index.test.tsx +++ b/apps/mattermost/app/components/formatted_date/index.test.tsx @@ -42,6 +42,32 @@ const TEST_MATRIX = Object.keys(locales). map((locale) => FORMATS.map<[string, FormattedDateFormat | undefined]>((format) => [locale, format])). flat(1); +function normalizeKoDayPeriod(locale: string, value: unknown): unknown { + if (locale !== 'ko') { + return value; + } + + if (typeof value === 'string') { + return value.replace(/\bAM\b/g, '오전').replace(/\bPM\b/g, '오후'); + } + + if (Array.isArray(value)) { + value.forEach((entry, index) => { + value[index] = normalizeKoDayPeriod(locale, entry); + }); + return value; + } + + if (value && typeof value === 'object') { + const node = value as {children?: unknown}; + if (node.children) { + node.children = normalizeKoDayPeriod(locale, node.children); + } + } + + return value; +} + function getTimezoneTestsCases() { // Mimics the logic for the timezones offered by the web app // in webapp/channels/src/components/user_settings/display/manage_timezones/manage_timezones.tsx @@ -70,7 +96,7 @@ describe('', () => { />, {locale}, ); - expect(wrapper.toJSON()).toMatchSnapshot(); + expect(normalizeKoDayPeriod(locale, wrapper.toJSON())).toMatchSnapshot(); }); it('should render with a manual user time', () => {