Compare commits

..
3 Commits
Author SHA1 Message Date
Yu Sung 2b5da942df build: Node.js 24 및 Vue CLI 5 전환 2026-11-18 10:50:03 +09:00
Yu Sung 1ba1311373 feat(sub-banner): 서브 배너 생성·수정 폼에 언어 선택 추가
- 생성·수정 폼에 KO/JA/EN 언어 select 추가 (신규 기본값 KO, 수정은 저장된 lang 유지)
- multipart request JSON 파트에 정규 대문자 lang 을 항상 포함해 전송
- 목록에 언어 열 추가, lang 누락 응답은 KO 로 간주하지 않고 계약 미충족 안내
- EN 은 현재 앱 공개 국가 매핑에서 미노출됨을 폼에 안내
- 400 등 4xx 거부 시 입력값·선택 파일·날짜를 보존하고 재전송을 막지 않도록 처리
- 언어 관련 focused test 추가
2026-11-03 02:17:03 +09:00
Yu Sung 1ec55506b2 feat(notice): 관리자 공지 예약 공개(publishAt) 연동
- 생성 요청에 선택적 publishAt 추가(생략/null 은 즉시 공개)
- 수정 요청은 undefined 면 publishAt 생략해 기존 예약 보존, 명시적 null 만 즉시 공개 전환으로 전송
- 목록 조회를 GET /api/v2/admin/notices 로 변경하고 timezone 파라미터 제거
- 작성/수정 다이얼로그에 예약 공개 입력과 미래 시각 검증 추가, 표시 날짜는 KST 문자열 그대로 사용
2026-10-30 23:22:59 +09:00
8 changed files with 7933 additions and 22987 deletions
+4 -1
View File
@@ -1,8 +1,11 @@
# soda-live-admin # soda-live-admin
## Project setup ## Project setup
Use Node.js 24.x for this project. Install dependencies from the lock file with:
``` ```
npm install npm ci
``` ```
### Compiles and hot-reloads for development ### Compiles and hot-reloads for development
+7510 -22945
View File
File diff suppressed because it is too large Load Diff
+20 -11
View File
@@ -2,6 +2,9 @@
"name": "soda-live-admin", "name": "soda-live-admin",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"engines": {
"node": "^24.0.0"
},
"scripts": { "scripts": {
"serve_local": "vue-cli-service serve --mode local --port 8888", "serve_local": "vue-cli-service serve --mode local --port 8888",
"serve": "vue-cli-service serve --port 8888", "serve": "vue-cli-service serve --port 8888",
@@ -17,7 +20,7 @@
"cropperjs": "^1.5.13", "cropperjs": "^1.5.13",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"vue": "^2.6.11", "vue": "2.6.14",
"vue-excel-xlsx": "^1.2.2", "vue-excel-xlsx": "^1.2.2",
"vue-router": "^3.2.0", "vue-router": "^3.2.0",
"vue-show-more-text": "^2.0.2", "vue-show-more-text": "^2.0.2",
@@ -32,21 +35,21 @@
"vuex": "^3.4.0" "vuex": "^3.4.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~4.5.0", "@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~4.5.0", "@vue/cli-service": "~5.0.0",
"axios": "0.21.2", "axios": "0.21.2",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"eslint": "^6.7.2", "eslint": "^7.32.0",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^7.20.0",
"sass": "~1.32.0", "sass": "~1.32.0",
"sass-loader": "^10.0.0", "sass-loader": "^10.0.0",
"vue-cli-plugin-axios": "~0.0.4", "vue-cli-plugin-axios": "~0.0.4",
"vue-cli-plugin-vuetify": "~2.4.5", "vue-cli-plugin-vuetify": "~2.4.5",
"vue-template-compiler": "^2.6.11", "vue-template-compiler": "2.6.14",
"vuetify-loader": "^1.7.0" "vuetify-loader": "1.7.3"
}, },
"eslintConfig": { "eslintConfig": {
"root": true, "root": true,
@@ -61,7 +64,13 @@
"parser": "babel-eslint" "parser": "babel-eslint"
}, },
"rules": { "rules": {
"no-unused-vars": "off" "no-unused-vars": "off",
"vue/valid-v-slot": [
"error",
{
"allowModifiers": true
}
]
} }
}, },
"browserslist": [ "browserslist": [
+18 -7
View File
@@ -1,21 +1,33 @@
import Vue from 'vue'; import Vue from 'vue';
async function save(title, content) { async function save(title, content, publishAt) {
const request = {title: title, content: content} const request = {title: title, content: content}
// publishAt 생략 또는 null 은 즉시 공개
if (publishAt != null) {
request.publishAt = publishAt
}
return Vue.axios.post("/notice", request) return Vue.axios.post("/notice", request)
} }
async function modify(id, title, content) { async function modify(id, title, content, publishAt) {
const request = {id: id} const request = {id: id}
if (title.trim().length > 0) { if (title != null && title.trim().length > 0) {
request.title = title request.title = title
} }
if (content.trim().length > 0) { if (content != null && content.trim().length > 0) {
request.content = content request.content = content
} }
// undefined 는 기존 예약 상태 보존(생략),
// null 은 사용자가 즉시 공개 전환을 명시한 경우에만 전송
if (publishAt !== undefined) {
request.publishAt = publishAt
}
return Vue.axios.put("/notice", request) return Vue.axios.put("/notice", request)
} }
@@ -25,9 +37,8 @@ async function deleteNotice(id) {
async function getNotices(page) { async function getNotices(page) {
return Vue.axios.get( return Vue.axios.get(
"/notice?page=" + (page - 1) + "/api/v2/admin/notices?page=" + (page - 1) +
"&size=20" + "&size=20"
"&timezone=" + Intl.DateTimeFormat().resolvedOptions().timeZone
) )
} }
+22 -1
View File
@@ -20,6 +20,23 @@ export const SUB_BANNER_PLACEMENTS = [
{value: 'CONTENT_RECOMMENDATION', text: '콘텐츠'} {value: 'CONTENT_RECOMMENDATION', text: '콘텐츠'}
] ]
export const SUB_BANNER_LANGS = [
{value: 'KO', text: '한국어'},
{value: 'JA', text: '일본어'},
{value: 'EN', text: '영어'}
]
export const SUB_BANNER_DEFAULT_LANG = 'KO'
export function langLabel(lang) {
const found = SUB_BANNER_LANGS.find((item) => item.value === lang)
return found ? found.text : ''
}
export function isSubBannerLang(lang) {
return SUB_BANNER_LANGS.some((item) => item.value === lang)
}
export function placementLabel(placement) { export function placementLabel(placement) {
const found = SUB_BANNER_PLACEMENTS.find((item) => item.value === placement) const found = SUB_BANNER_PLACEMENTS.find((item) => item.value === placement)
return found ? found.text : '' return found ? found.text : ''
@@ -150,6 +167,8 @@ export function createSubBannerForm(banner = {}) {
return { return {
id: banner.id === undefined ? null : banner.id, id: banner.id === undefined ? null : banner.id,
placement: banner.placement || SUB_BANNER_PLACEMENTS[0].value, placement: banner.placement || SUB_BANNER_PLACEMENTS[0].value,
// 저장된 언어가 있으면 그대로 사용하고, 신규 등록일 때만 KO 를 기본값으로 쓴다.
lang: isSubBannerLang(banner.lang) ? banner.lang : SUB_BANNER_DEFAULT_LANG,
image: null, image: null,
image_url: banner.imageUrl || null, image_url: banner.imageUrl || null,
web_url: banner.webUrl === null || banner.webUrl === undefined ? '' : String(banner.webUrl), web_url: banner.webUrl === null || banner.webUrl === undefined ? '' : String(banner.webUrl),
@@ -236,7 +255,9 @@ function baseRequest(form) {
placement: form.placement, placement: form.placement,
webUrl: urls.webUrl, webUrl: urls.webUrl,
androidDeepLink: urls.androidDeepLink, androidDeepLink: urls.androidDeepLink,
iosDeepLink: urls.iosDeepLink iosDeepLink: urls.iosDeepLink,
// 언어는 생성·수정 모두 현재 선택을 정규 대문자 코드로 항상 보낸다.
lang: isSubBannerLang(form.lang) ? form.lang : SUB_BANNER_DEFAULT_LANG
} }
} }
+63 -1
View File
@@ -66,6 +66,9 @@
<th class="text-center"> <th class="text-center">
이미지 이미지
</th> </th>
<th class="text-center">
언어
</th>
<th class="text-center"> <th class="text-center">
웹 URL 웹 URL
</th> </th>
@@ -99,6 +102,7 @@
class="list-image" class="list-image"
> >
</td> </td>
<td>{{ langText(item) }}</td>
<td>{{ item.webUrl || '-' }}</td> <td>{{ item.webUrl || '-' }}</td>
<td>{{ item.androidDeepLink || '-' }}</td> <td>{{ item.androidDeepLink || '-' }}</td>
<td>{{ item.iosDeepLink || '-' }}</td> <td>{{ item.iosDeepLink || '-' }}</td>
@@ -121,7 +125,7 @@
</tr> </tr>
<tr v-if="sub_banners.length === 0"> <tr v-if="sub_banners.length === 0">
<td <td
colspan="8" colspan="9"
class="text-center" class="text-center"
> >
등록된 배너가 없습니다. 등록된 배너가 없습니다.
@@ -162,6 +166,30 @@
</v-col> </v-col>
</v-row> </v-row>
</v-card-text> </v-card-text>
<v-card-text>
<v-row align="center">
<v-col cols="4">
<label for="sub-banner-lang">언어</label>
</v-col>
<v-col cols="8">
<v-select
id="sub-banner-lang"
v-model="sub_banner.lang"
:items="langs"
item-text="text"
item-value="value"
label="언어 선택"
:error-messages="form_errors.lang"
/>
</v-col>
</v-row>
<v-row>
<v-col class="guide-text">
영어(EN)는 저장과 목록 조회는 가능하지만 현재 앱 공개 국가 매핑(JP → 일본어, 그 외 → 한국어)에서는 노출되지 않습니다.
배너 소재 언어와 연결된 이벤트 언어는 운영자가 직접 맞춰 주세요.
</v-col>
</v-row>
</v-card-text>
<v-card-text> <v-card-text>
<v-row align="center"> <v-row align="center">
<v-col cols="4"> <v-col cols="4">
@@ -339,7 +367,9 @@ import {
buildSubBannerUpdateRequest, buildSubBannerUpdateRequest,
createSubBannerForm, createSubBannerForm,
formatScheduleRange, formatScheduleRange,
langLabel,
scheduleStatus, scheduleStatus,
SUB_BANNER_LANGS,
SUB_BANNER_PLACEMENTS, SUB_BANNER_PLACEMENTS,
validateSubBannerForm validateSubBannerForm
} from "@/utils/sub_banner" } from "@/utils/sub_banner"
@@ -355,6 +385,7 @@ export default {
show_write_dialog: false, show_write_dialog: false,
show_delete_confirm_dialog: false, show_delete_confirm_dialog: false,
placements: SUB_BANNER_PLACEMENTS, placements: SUB_BANNER_PLACEMENTS,
langs: SUB_BANNER_LANGS,
selected_placement: SUB_BANNER_PLACEMENTS[0].value, selected_placement: SUB_BANNER_PLACEMENTS[0].value,
sub_banners: [], sub_banners: [],
selected_sub_banner: {}, selected_sub_banner: {},
@@ -376,6 +407,16 @@ export default {
this.$dialog.notify.success(message) this.$dialog.notify.success(message)
}, },
// 400 등 4xx 는 ApiResponse 가 아닌 표준 Spring Boot body 일 수 있어 단정하지 않는다.
clientErrorMessage(error) {
const response = error && error.response
if (!response || response.status < 400 || response.status >= 500) return null
const body = response.data
const message = body && typeof body === 'object' ? (body.message || body.error) : null
return message || '입력값을 서버가 거부했습니다. 값을 확인한 뒤 다시 시도해 주세요.'
},
imageAdd(payload) { imageAdd(payload) {
const file = payload const file = payload
@@ -427,6 +468,11 @@ export default {
return scheduleStatus(subBanner) return scheduleStatus(subBanner)
}, },
langText(subBanner) {
// lang 이 없는 응답을 KO 로 간주하지 않는다.
return langLabel(subBanner.lang) || '-'
},
validate() { validate() {
const errors = validateSubBannerForm( const errors = validateSubBannerForm(
this.sub_banner, this.sub_banner,
@@ -480,9 +526,15 @@ export default {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
} }
} catch (e) { } catch (e) {
const clientError = this.clientErrorMessage(e)
if (clientError !== null) {
// 서버가 확실히 거부했으므로 입력값·선택 파일·날짜를 그대로 두고 재전송도 막지 않는다.
this.notifyError(clientError)
} else {
// 결과가 불명확하므로 자동 재시도 없이 중복 전송을 막고 목록으로 상태를 확인한다. // 결과가 불명확하므로 자동 재시도 없이 중복 전송을 막고 목록으로 상태를 확인한다.
this.submit_blocked = true this.submit_blocked = true
this.notifyError('응답을 받지 못했습니다. 등록 여부를 목록에서 확인해 주세요.') this.notifyError('응답을 받지 못했습니다. 등록 여부를 목록에서 확인해 주세요.')
}
} finally { } finally {
this.is_loading = false this.is_loading = false
} }
@@ -521,8 +573,13 @@ export default {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
} }
} catch (e) { } catch (e) {
const clientError = this.clientErrorMessage(e)
if (clientError !== null) {
this.notifyError(clientError)
} else {
this.submit_blocked = true this.submit_blocked = true
this.notifyError('응답을 받지 못했습니다. 수정 여부를 목록에서 확인해 주세요.') this.notifyError('응답을 받지 못했습니다. 수정 여부를 목록에서 확인해 주세요.')
}
} finally { } finally {
this.is_loading = false this.is_loading = false
} }
@@ -561,6 +618,11 @@ export default {
if (res.status === 200 && res.data.success === true) { if (res.status === 200 && res.data.success === true) {
// 서버가 id 오름차순으로 내려주므로 재정렬하지 않고 전부 표시한다. // 서버가 id 오름차순으로 내려주므로 재정렬하지 않고 전부 표시한다.
this.sub_banners = Array.isArray(res.data.data) ? res.data.data : [] this.sub_banners = Array.isArray(res.data.data) ? res.data.data : []
// 응답에 lang 이 없으면 KO 로 간주하지 않고 계약 미충족을 알린다.
if (this.sub_banners.some((item) => !item || item.lang === undefined)) {
this.notifyError('목록 응답에 lang 이 없습니다. 언어 계약이 적용된 서버인지 확인해 주세요.')
}
} else { } else {
// 조회 실패를 빈 목록으로 오인하지 않는다. // 조회 실패를 빈 목록으로 오인하지 않는다.
this.notifyError(res.data.message || '목록을 불러오지 못했습니다. 다시 시도해 주세요.') this.notifyError(res.data.message || '목록을 불러오지 못했습니다. 다시 시도해 주세요.')
+133 -3
View File
@@ -56,7 +56,7 @@
{{ item.title }} {{ item.title }}
</td> </td>
<td> <td>
{{ item.date }} {{ displayDate(item) }}
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -95,6 +95,33 @@
:editor-toolbar="customToolbar" :editor-toolbar="customToolbar"
/> />
</v-card-text> </v-card-text>
<v-card-text>
<v-checkbox
v-model="use_schedule"
:disabled="is_modify && !can_change_publish_at"
label="예약 공개"
hide-details
/>
<v-text-field
v-show="use_schedule"
v-model="publish_at_input"
:disabled="is_modify && !can_change_publish_at"
label="공개 시각 (KST)"
type="datetime-local"
/>
<v-checkbox
v-show="is_modify && can_change_publish_at && !use_schedule"
v-model="publish_now"
label="지금 공개로 전환"
hide-details
/>
<div
v-show="is_modify && !can_change_publish_at"
class="text-caption grey--text"
>
이미 공개된 공지는 공개 시각을 변경할 수 없습니다.
</div>
</v-card-text>
<v-card-actions v-show="!is_loading"> <v-card-actions v-show="!is_loading">
<v-btn <v-btn
v-show="is_modify" v-show="is_modify"
@@ -185,6 +212,11 @@ export default {
total_page: 0, total_page: 0,
notices: [], notices: [],
notice: {}, notice: {},
use_schedule: false,
publish_now: false,
publish_at_input: '',
original_publish_at: null,
can_change_publish_at: true,
show_write_dialog: false, show_write_dialog: false,
show_delete_confirm_dialog: false, show_delete_confirm_dialog: false,
customToolbar: [ customToolbar: [
@@ -219,6 +251,44 @@ export default {
await this.getNotices() await this.getNotices()
}, },
// "yyyy-MM-dd HH:mm:ss"(KST) -> "yyyy-MM-ddTHH:mm" (시간대 변환 없이 문자열만 변환)
toInputValue(publishAt) {
if (!publishAt) return ''
return publishAt.replace(' ', 'T').substring(0, 16)
},
// "yyyy-MM-ddTHH:mm" -> "yyyy-MM-dd HH:mm:ss"(KST)
toContractValue(input) {
if (!input) return null
const value = input.replace('T', ' ')
if (value.length === 16) return value + ':00'
return value.substring(0, 19)
},
nowKstString() {
const parts = new Intl.DateTimeFormat('en-CA', {
timeZone: 'Asia/Seoul',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false
}).formatToParts(new Date()).reduce((acc, p) => {
acc[p.type] = p.value
return acc
}, {})
return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}:${parts.second}`
},
displayDate(item) {
const source = (item.isScheduled === true && item.publishAt) ? item.publishAt : item.createdAt
if (!source) return ''
return source.substring(0, 10)
},
async getNotices() { async getNotices() {
this.is_loading = true this.is_loading = true
@@ -245,6 +315,7 @@ export default {
}, },
showWriteDialog() { showWriteDialog() {
this.resetPublishState()
this.show_write_dialog = true this.show_write_dialog = true
}, },
@@ -253,12 +324,35 @@ export default {
this.notice.id = item.id; this.notice.id = item.id;
this.notice.title = item.title; this.notice.title = item.title;
this.notice.content = item.content; this.notice.content = item.content;
this.resetPublishState()
this.original_publish_at = item.publishAt || null
// 예약 공지이면서 공개 시각이 아직 도래하지 않은 경우에만 공개 시각 변경을 시도할 수 있다.
// 공개 경계의 최종 판단은 API 응답을 따른다.
this.can_change_publish_at = item.isScheduled === true &&
!!item.publishAt &&
item.publishAt > this.nowKstString()
if (this.can_change_publish_at) {
this.use_schedule = true
this.publish_at_input = this.toInputValue(item.publishAt)
}
this.show_write_dialog = true this.show_write_dialog = true
}, },
resetPublishState() {
this.use_schedule = false
this.publish_now = false
this.publish_at_input = ''
this.original_publish_at = null
this.can_change_publish_at = true
},
cancel() { cancel() {
this.is_modify = false this.is_modify = false
this.notice = {} this.notice = {}
this.resetPublishState()
this.show_write_dialog = false this.show_write_dialog = false
}, },
@@ -273,9 +367,36 @@ export default {
return false; return false;
} }
if (this.use_schedule) {
if (this.publish_at_input == null || this.publish_at_input.trim().length === 0) {
this.notifyError("공개 시각을 입력하세요.")
return false;
}
if (this.toContractValue(this.publish_at_input) <= this.nowKstString()) {
this.notifyError("공개 시각은 현재보다 미래여야 합니다.")
return false;
}
}
return true return true
}, },
// 수정 요청에 담을 publishAt 산출
// undefined: 생략(기존 예약 상태 보존), null: 지금 공개로 전환, 문자열: 재예약
publishAtForModify() {
if (!this.can_change_publish_at) return undefined
if (this.publish_now && !this.use_schedule) return null
if (this.use_schedule) {
const publishAt = this.toContractValue(this.publish_at_input)
if (publishAt !== this.original_publish_at) return publishAt
}
return undefined
},
async submit() { async submit() {
if (!this.validate()) return; if (!this.validate()) return;
if (this.is_loading) return; if (this.is_loading) return;
@@ -283,13 +404,15 @@ export default {
this.is_loading = true this.is_loading = true
try { try {
const res = await api.save(this.notice.title, this.notice.content) const publishAt = this.use_schedule ? this.toContractValue(this.publish_at_input) : null
const res = await api.save(this.notice.title, this.notice.content, publishAt)
if (res.status === 200 && res.data.success === true) { if (res.status === 200 && res.data.success === true) {
this.show_write_dialog = false this.show_write_dialog = false
this.notifySuccess('등록되었습니다.') this.notifySuccess('등록되었습니다.')
this.page = 1 this.page = 1
await this.getNotices() await this.getNotices()
this.notice = {} this.notice = {}
this.resetPublishState()
} else { } else {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
} }
@@ -307,13 +430,19 @@ export default {
this.is_loading = true this.is_loading = true
try { try {
const res = await api.modify(this.notice.id, this.notice.title, this.notice.content) const res = await api.modify(
this.notice.id,
this.notice.title,
this.notice.content,
this.publishAtForModify()
)
if (res.status === 200 && res.data.success === true) { if (res.status === 200 && res.data.success === true) {
this.show_write_dialog = false this.show_write_dialog = false
this.notifySuccess('수정되었습니다.') this.notifySuccess('수정되었습니다.')
this.page = 1 this.page = 1
await this.getNotices() await this.getNotices()
this.notice = {} this.notice = {}
this.resetPublishState()
this.is_modify = false this.is_modify = false
} else { } else {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
@@ -346,6 +475,7 @@ export default {
this.page = 1 this.page = 1
await this.getNotices() await this.getNotices()
this.notice = {} this.notice = {}
this.resetPublishState()
this.is_modify = false this.is_modify = false
} else { } else {
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
+148 -3
View File
@@ -38,6 +38,7 @@ const {
buildSubBannerUpdateRequest, buildSubBannerUpdateRequest,
createSubBannerForm, createSubBannerForm,
formatScheduleRange, formatScheduleRange,
langLabel,
normalizeUrls, normalizeUrls,
placementLabel, placementLabel,
resolveSubBannerTarget, resolveSubBannerTarget,
@@ -55,6 +56,7 @@ const envelope = (data, success = true, message = null) => ({ success, message,
const subBanner = (overrides = {}) => ({ const subBanner = (overrides = {}) => ({
id: 1, id: 1,
placement: 'HOME_RECOMMENDATION', placement: 'HOME_RECOMMENDATION',
lang: 'KO',
imageUrl: 'https://cdn.example.test/promo.jpg', imageUrl: 'https://cdn.example.test/promo.jpg',
webUrl: 'https://example.test/promo', webUrl: 'https://example.test/promo',
androidDeepLink: null, androidDeepLink: null,
@@ -186,7 +188,8 @@ test('주소 수정: 전부 비우면 오류, 한 필드만 비우면 해당 값
placement: 'HOME_RECOMMENDATION', placement: 'HOME_RECOMMENDATION',
webUrl: 'https://example.test/promo', webUrl: 'https://example.test/promo',
androidDeepLink: 'sampleapp://promo', androidDeepLink: 'sampleapp://promo',
iosDeepLink: null iosDeepLink: null,
lang: 'KO'
}) })
}) })
@@ -267,7 +270,8 @@ test('등록 요청: 네 기본 필드는 항상 보내고 날짜 미입력은
placement: 'CONTENT_RECOMMENDATION', placement: 'CONTENT_RECOMMENDATION',
webUrl: 'https://example.test/promo', webUrl: 'https://example.test/promo',
androidDeepLink: 'sampleapp://promo', androidDeepLink: 'sampleapp://promo',
iosDeepLink: null iosDeepLink: null,
lang: 'KO'
}) })
assert.deepEqual(buildSubBannerCreateRequest({ ...base, start_date: '2026-11-01T09:30' }).startDate, '2026-11-01 09:30') assert.deepEqual(buildSubBannerCreateRequest({ ...base, start_date: '2026-11-01T09:30' }).startDate, '2026-11-01 09:30')
assert.deepEqual(buildSubBannerCreateRequest({ ...base, end_date: '2026-11-30T23:59' }).endDate, '2026-11-30 23:59') assert.deepEqual(buildSubBannerCreateRequest({ ...base, end_date: '2026-11-30T23:59' }).endDate, '2026-11-30 23:59')
@@ -283,7 +287,8 @@ test('수정 요청: 미변경 경계는 생략해 보존하고 지운 경계만
placement: 'HOME_RECOMMENDATION', placement: 'HOME_RECOMMENDATION',
webUrl: 'https://example.test/promo', webUrl: 'https://example.test/promo',
androidDeepLink: 'sampleapp://promo', androidDeepLink: 'sampleapp://promo',
iosDeepLink: null iosDeepLink: null,
lang: 'KO'
} }
// loaded date 재전송: 값이 같으면 생략해 저장 값을 보존한다. // loaded date 재전송: 값이 같으면 생략해 저장 값을 보존한다.
@@ -394,6 +399,7 @@ test('등록: image 와 application/json request 파트를 보내고 목록을
webUrl: 'https://example.test/promo', webUrl: 'https://example.test/promo',
androidDeepLink: null, androidDeepLink: null,
iosDeepLink: null, iosDeepLink: null,
lang: 'KO',
startDate: '2026-11-01 09:30' startDate: '2026-11-01 09:30'
}) })
assert.deepEqual(successes, ['등록되었습니다.']) assert.deepEqual(successes, ['등록되었습니다.'])
@@ -451,6 +457,7 @@ test('수정: 목록 객체로 폼을 채우고 일정만 바꾸면 image 를
webUrl: 'https://example.test/promo', webUrl: 'https://example.test/promo',
androidDeepLink: 'sampleapp://promo', androidDeepLink: 'sampleapp://promo',
iosDeepLink: null, iosDeepLink: null,
lang: 'KO',
endDate: '2026-12-31 23:59' endDate: '2026-12-31 23:59'
}) })
assert.deepEqual(successes, ['수정되었습니다.']) assert.deepEqual(successes, ['수정되었습니다.'])
@@ -550,6 +557,144 @@ test('중복 제출 방지: 진행 중 재호출과 timeout 이후 재전송을
assert.equal(timeoutPage.errors.length, 1) assert.equal(timeoutPage.errors.length, 1)
}) })
test('언어: 신규 기본값은 KO 이고 선택한 코드가 정규 대문자로 직렬화된다', () => {
assert.equal(createSubBannerForm().lang, 'KO')
assert.equal(langLabel('KO'), '한국어')
assert.equal(langLabel('JA'), '일본어')
assert.equal(langLabel('EN'), '영어')
assert.equal(langLabel('ko'), '')
for (const lang of ['KO', 'JA', 'EN']) {
const created = buildSubBannerCreateRequest(form({ lang, web_url: 'https://example.test/promo' }))
assert.deepEqual(created, {
placement: 'HOME_RECOMMENDATION',
webUrl: 'https://example.test/promo',
androidDeepLink: null,
iosDeepLink: null,
lang
})
const saved = subBanner({ lang })
const updated = buildSubBannerUpdateRequest(createSubBannerForm(saved), saved)
assert.deepEqual(Object.keys(updated), ['placement', 'webUrl', 'androidDeepLink', 'iosDeepLink', 'lang'])
assert.equal(updated.lang, lang)
}
})
test('언어: 수정 폼은 저장된 JA/EN 으로 미리 선택되고 다른 값만 바꿔도 보존된다', async () => {
stubFormData()
const { vm } = page()
const calls = []
Vue.axios = {
put: async (...args) => { calls.push(args); return { status: 200, data: envelope(subBanner({ lang: 'JA' })) } },
get: async () => ({ status: 200, data: envelope([subBanner({ lang: 'JA' })]) })
}
const saved = subBanner({ id: 55, lang: 'JA', startDate: '2026-11-01 09:30', endDate: '2026-11-30 23:59' })
vm.showModifyDialog(saved)
assert.equal(vm.sub_banner.lang, 'JA')
// 이미지와 종료 일시만 바꿔도 저장된 언어가 그대로 전송된다.
vm.imageAdd({ name: 'new.jpg', type: 'image/jpeg' })
vm.sub_banner.end_date = '2026-12-31T23:59'
await vm.modify()
assert.equal(calls[0][0], '/admin/sub-banners/55')
assert.equal(calls[0][1].get('image').name, 'new.jpg')
assert.deepEqual(requestOf(calls[0][1]), {
placement: 'HOME_RECOMMENDATION',
webUrl: 'https://example.test/promo',
androidDeepLink: null,
iosDeepLink: null,
lang: 'JA',
endDate: '2026-12-31 23:59'
})
const en = subBanner({ id: 56, lang: 'EN' })
vm.showModifyDialog(en)
assert.equal(vm.sub_banner.lang, 'EN')
// 언어만 바꿔도 나머지 값은 그대로다.
vm.sub_banner.lang = 'KO'
await vm.modify()
assert.deepEqual(requestOf(calls[1][1]), {
placement: 'HOME_RECOMMENDATION',
webUrl: 'https://example.test/promo',
androidDeepLink: null,
iosDeepLink: null,
lang: 'KO'
})
assert.equal(calls[1][1].has('image'), false)
})
test('언어 오류: 400 Boot body 와 success=false 모두 입력·이미지·날짜를 보존한다', async () => {
stubFormData()
const bootError = {
response: {
status: 400,
data: { timestamp: '2026-11-01T00:00:00.000+00:00', status: 400, error: 'Bad Request', message: '지원하지 않는 언어입니다.', path: '/admin/sub-banners' }
}
}
const { vm, errors, successes } = page()
Vue.axios = {
post: async () => { throw bootError },
get: async () => ({ status: 200, data: envelope([subBanner()]) })
}
vm.showCreateDialog()
vm.sub_banner.lang = 'EN'
vm.sub_banner.web_url = 'https://example.test/promo'
vm.sub_banner.start_date = '2026-11-01T09:30'
vm.imageAdd({ name: 'promo.jpg', type: 'image/jpeg' })
await vm.submit()
assert.deepEqual(errors, ['지원하지 않는 언어입니다.'])
assert.deepEqual(successes, [])
// 400 은 서버가 확실히 거부한 것이므로 재전송을 막지 않고 상태를 보존한다.
assert.equal(vm.submit_blocked, false)
assert.equal(vm.show_write_dialog, true)
assert.equal(vm.sub_banner.lang, 'EN')
assert.equal(vm.sub_banner.web_url, 'https://example.test/promo')
assert.equal(vm.sub_banner.start_date, '2026-11-01T09:30')
assert.equal(vm.sub_banner.image.name, 'promo.jpg')
const failed = page()
Vue.axios = { put: async () => ({ status: 200, data: envelope(null, false, '언어 값이 올바르지 않습니다.') }) }
failed.vm.showModifyDialog(subBanner({ id: 9, lang: 'JA', startDate: '2026-11-01 09:30' }))
failed.vm.sub_banner.lang = 'EN'
await failed.vm.modify()
assert.deepEqual(failed.errors, ['언어 값이 올바르지 않습니다.'])
assert.equal(failed.vm.sub_banner.lang, 'EN')
assert.equal(failed.vm.sub_banner.start_date, '2026-11-01T09:30')
assert.equal(failed.vm.sub_banner.image_url, 'https://cdn.example.test/promo.jpg')
})
test('목록: 언어를 표시하고 lang 이 없는 응답은 KO 로 간주하지 않는다', async () => {
const { vm, errors } = page()
Vue.axios = {
get: async () => ({
status: 200,
data: envelope([subBanner({ id: 1, lang: 'KO' }), subBanner({ id: 2, lang: 'JA' }), subBanner({ id: 3, lang: 'EN' })])
})
}
await vm.getSubBanners()
const rendered = activatorText(vm)
assert.ok(rendered.includes('한국어'))
assert.ok(rendered.includes('일본어'))
assert.ok(rendered.includes('영어'))
assert.deepEqual(errors, [])
const missing = subBanner({ id: 4 })
delete missing.lang
Vue.axios = { get: async () => ({ status: 200, data: envelope([missing]) }) }
await vm.getSubBanners()
assert.equal(errors.length, 1)
assert.equal(vm.langText(missing), '-')
})
;(async () => { ;(async () => {
for (const { name, run } of tests) { for (const { name, run } of tests) {
try { try {