[feat] solution/site,frontend,backend: 숙박 예약 구성 — 요금·인원·창구를 한자리에
숙박으로 발행하면 서버 기본표가 booking 섹션을 켜는데, 발행본이 읽는 fact (reservation_required·reservation_channel)가 **숙박 스키마에 없다**. 그래서 펜션·민박의 "실시간 예약" 섹션에는 전화번호 한 줄만 남았다 — 요금도 인원도 취소 규정도 없었다. 숙박은 예약이 곧 매출이고 "얼마예요 / 몇 명까지 / 어떻게 예약해요" 가 이 업종 질의의 대부분인데, 그 답의 근거가 페이지에 없으면 AI 는 OTA 후기에서 추측한다. ★ 예약을 처리하게 만든 게 아니다. 재고도 결제도 갖지 않는다(PRODUCT.md 6절) — 날짜 선택기·예약 폼을 그리지 않았고, "여기서 결제되지 않는다" 를 화면 맨 앞과 llms.txt 에 명시했다. 없는 기능을 흉내내면 손님은 예약한 줄 알고 안 온다. - site/sections/StayBookingSection: 객실별 요금·인원 / 예약 창구(전화 + 확정 채널) / 예약 전 확인 8항목. 근거가 없으면 섹션째 안 나간다 - site/lib/derive: stayBookingView() 가 그릴지 말지까지 판단한다 — 내비·탭이 같은 함수를 본다(각자 판단하면 눌러도 아무 일 없는 탭이 생긴다). 예약 채널은 문의 목록에서 뺀다 - site/seo/jsonld: unitBaseRate() 를 요금 숫자의 단일 출처로. makesOffer(객실별 1박) · potentialAction(확정 채널만) 추가. availability 는 안 넣는다 — 빈 방을 모른다 - site/seo/llms: 숙박 ## 예약 블록을 위쪽에. 아래에만 있으면 답에 안 실린다 - frontend/industryData, backend/site_payload: 기본 섹션명 "실시간 예약" → "예약 안내". 실시간 예약을 하지 않는데 제목이 그렇게 말했다(두 파일은 parity 테스트가 묶는다) - site/seo/verify: 데모 payload 가 원래 굽히지 않던 오탐 둘을 고쳤다(main 에서 재현) — 속성의 & 이스케이프 때문에 화면에 있는 이미지 URL 을 못 찾던 것, ㎡ 의 단위 코드 MTK 를 본문에서 찾던 것. 되돌린 사본에서도 못 찾으면 그대로 실패다 tsc·eslint 통과, vitest 43 passed(신규 21). 데모 재굽기 성공 → /s/moonlight-stay-jeju 200. 백엔드 pytest 는 venv 가 없어 미실행 — 섹션표 parity 는 같은 방식으로 손대조했다.
This commit is contained in:
1 parent
6df125d840
commit
d498d36ccf
15 files changed
+846
-24
No files matched your search
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* 숙박 예약 구성 — 이 검사가 지키는 것.
|
||||
*
|
||||
* 1. 미검증 fact·확정 전 링크가 예약 화면에 새지 않는다(절대규칙 1).
|
||||
* 예약은 틀리면 바로 클레임이 나는 자리다 — 확인 안 된 요금이나 남의 숙소 예약 링크가
|
||||
* 한 번 나가면 손님은 헛걸음하고, 그 전화는 사장님이 받는다.
|
||||
* 2. 화면의 요금과 JSON-LD 의 `makesOffer.price` 가 **같은 숫자**다(절대규칙 3).
|
||||
* 갈라지면 발행 게이트가 사이트를 막는다 — 조용히 틀리는 게 아니라 발행이 멈추는 종류다.
|
||||
* 3. 예약 액션이 **실제로 예약이 되는 URL** 만 가리킨다.
|
||||
* 확정 전 채널을 `potentialAction` 에 넣으면 AI 가 그 주소로 손님을 보낸다.
|
||||
*/
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import {
|
||||
PlaceCategory,
|
||||
FactStatus,
|
||||
sanitizePayloadForPublish,
|
||||
type SitePayload,
|
||||
} from '@o2o/shared';
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '@/fixtures/moonlight-stay';
|
||||
import {stayBookingView} from '@/lib/derive';
|
||||
import {collectJsonLd} from '@/seo/jsonld';
|
||||
import {renderLlmsTxt} from '@/seo/llms';
|
||||
import {verifyJsonLd, visibleText} from '@/seo/verify';
|
||||
import {render} from '@/entry-server';
|
||||
import {homeMeta} from '@/seo/meta';
|
||||
import {renderHead} from '@/seo/head';
|
||||
|
||||
const PAGE = {title: '달빛스테이 제주', description: '제주 애월 독채 펜션'};
|
||||
|
||||
/** 확정 전 야놀자 링크 — fixture 가 일부러 남겨 둔 값이다. */
|
||||
const UNCONFIRMED_URL = 'https://www.yanolja.com/pension/0000000';
|
||||
|
||||
/**
|
||||
* 프리렌더가 굽는 문서와 **같은 모양**으로 만든다.
|
||||
*
|
||||
* ★ 앱 마크업만 놓고 대조하면 안 된다 — canonical·og:image 처럼 head 로 나가는 값과
|
||||
* 하이드레이션 블롭이 빠져서, 멀쩡한 값이 "화면에 없다" 로 잡힌다(실측 12건).
|
||||
* 검사는 **나갈 그 HTML** 에 대고 해야 의미가 있다(verify.ts 머리주석).
|
||||
* ★ 자산 경로는 이 검사와 무관하므로 고정 문자열을 쓴다.
|
||||
*/
|
||||
function html(input: SitePayload = MOONLIGHT_STAY_PAYLOAD): string {
|
||||
const payload = sanitizePayloadForPublish(input);
|
||||
const meta = homeMeta(payload);
|
||||
const head = renderHead({
|
||||
payload,
|
||||
meta,
|
||||
scriptSrc: '/assets/index.js',
|
||||
cssHrefs: ['/assets/index.css'],
|
||||
});
|
||||
return [
|
||||
'<!doctype html><html lang="ko"><head>',
|
||||
head,
|
||||
'</head><body>',
|
||||
`<div id="root">${render(payload)}</div>`,
|
||||
`<script>window.__SITE_PAYLOAD__=${JSON.stringify(payload)}</script>`,
|
||||
'</body></html>',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
describe('stayBookingView — 예약에 쓸 값을 고르는 자리', () => {
|
||||
it('숙박이 아니면 아무것도 돌려주지 않는다 — 다른 업종은 BookingSection 이 그린다', () => {
|
||||
const cafe = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
place: {...MOONLIGHT_STAY_PAYLOAD.place, category: PlaceCategory.CAFE},
|
||||
};
|
||||
expect(stayBookingView(cafe)).toBeNull();
|
||||
});
|
||||
|
||||
it('확정된 예약 채널만 창구가 된다 — 확정 전 URL 은 동명 업소일 수 있다', () => {
|
||||
const view = stayBookingView(MOONLIGHT_STAY_PAYLOAD)!;
|
||||
expect(view.links.map((link) => link.url)).not.toContain(UNCONFIRMED_URL);
|
||||
expect(view.links).toHaveLength(1); // 네이버 플레이스만 확정됨
|
||||
});
|
||||
|
||||
it('미검증 fact 는 예약 전 확인에 오르지 않는다', () => {
|
||||
const withUnverifiedPolicy = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
facts: MOONLIGHT_STAY_PAYLOAD.facts.map((fact) =>
|
||||
fact.key === 'cancel_policy' ? {...fact, status: FactStatus.UNVERIFIED} : fact,
|
||||
),
|
||||
};
|
||||
const labels = stayBookingView(withUnverifiedPolicy)!.notices.map((row) => row.label);
|
||||
expect(labels).not.toContain('취소·환불 규정');
|
||||
// 확인된 나머지는 그대로 남는다 — 한 건이 빠졌다고 표가 사라지면 안 된다.
|
||||
expect(labels).toContain('체크인 시간');
|
||||
});
|
||||
|
||||
it('근거가 하나도 없으면 null 이다 — 눌러도 아무 일 없는 예약 메뉴를 만들지 않는다', () => {
|
||||
const bare: SitePayload = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
place: {...MOONLIGHT_STAY_PAYLOAD.place, phone: undefined},
|
||||
facts: [],
|
||||
units: [],
|
||||
links: [],
|
||||
};
|
||||
expect(stayBookingView(bare)).toBeNull();
|
||||
});
|
||||
|
||||
it('기준 요금 표기는 어느 요금인지 밝힌다 — 밝히지 않은 가격은 그 자체로 오해다', () => {
|
||||
const offers = stayBookingView(MOONLIGHT_STAY_PAYLOAD)!.offers;
|
||||
expect(offers[0].baseRateText).toBe('주중 1박 280,000원');
|
||||
expect(offers[0].capacityText).toBe('기준 2명 · 최대 4명');
|
||||
});
|
||||
});
|
||||
|
||||
describe('발행 HTML — 예약 섹션이 실제로 나가는가', () => {
|
||||
it('요금 · 인원 · 취소 규정 · 예약 창구가 한자리에 있다', () => {
|
||||
const text = visibleText(html());
|
||||
expect(text).toContain('예약 창구');
|
||||
expect(text).toContain('주중 1박 280,000원');
|
||||
expect(text).toContain('기준 2명 · 최대 4명');
|
||||
expect(text).toContain('전화 예약 0507-1345-8821');
|
||||
expect(text).toContain('네이버 플레이스에서 예약');
|
||||
});
|
||||
|
||||
it('여기서 결제되지 않는다는 사실을 먼저 말한다 — 우리는 재고도 결제도 갖지 않는다', () => {
|
||||
expect(visibleText(html())).toContain('빈 방 확인과 결제는 아래 예약 창구에서 진행됩니다');
|
||||
});
|
||||
|
||||
it('확정 전 예약 링크는 화면에 없다', () => {
|
||||
expect(html()).not.toContain(UNCONFIRMED_URL);
|
||||
});
|
||||
|
||||
it('booking 항목이 없는 payload 에서도 예약 안내가 나간다 — 옛 payload·fixture', () => {
|
||||
const withoutBooking = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
theme: {
|
||||
...MOONLIGHT_STAY_PAYLOAD.theme,
|
||||
sections: MOONLIGHT_STAY_PAYLOAD.theme.sections.filter((s) => s.id !== 'booking'),
|
||||
},
|
||||
};
|
||||
expect(visibleText(html(withoutBooking))).toContain('예약 창구');
|
||||
});
|
||||
|
||||
it('사장님이 끈 예약 섹션은 되살리지 않는다 — 껐다와 항목이 없다는 다르다', () => {
|
||||
const disabled = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
theme: {
|
||||
...MOONLIGHT_STAY_PAYLOAD.theme,
|
||||
sections: MOONLIGHT_STAY_PAYLOAD.theme.sections.map((s) =>
|
||||
s.id === 'booking' ? {...s, enabled: false} : s,
|
||||
),
|
||||
},
|
||||
};
|
||||
expect(visibleText(html(disabled))).not.toContain('예약 창구');
|
||||
});
|
||||
});
|
||||
|
||||
describe('구조화 데이터 — 예약 값이 화면과 어긋나지 않는가 (절대규칙 3)', () => {
|
||||
it('makesOffer · potentialAction 을 포함한 전체 JSON-LD 가 화면 대조를 통과한다', () => {
|
||||
const nodes = collectJsonLd(MOONLIGHT_STAY_PAYLOAD, PAGE);
|
||||
expect(verifyJsonLd(html(), nodes)).toEqual([]);
|
||||
});
|
||||
|
||||
it('객실별 요금이 makesOffer 로 나가고, 가격은 화면과 같은 숫자다', () => {
|
||||
const [business] = collectJsonLd(MOONLIGHT_STAY_PAYLOAD, PAGE);
|
||||
const offers = business.makesOffer as {name: string; price: number}[];
|
||||
expect(offers.map((offer) => [offer.name, offer.price])).toEqual([
|
||||
['Moonlight A동', 280000],
|
||||
['Starlight B동', 300000],
|
||||
]);
|
||||
expect(visibleText(html())).toContain('280,000');
|
||||
});
|
||||
|
||||
it('빈 방 재고를 모르므로 availability 를 주장하지 않는다', () => {
|
||||
const [business] = collectJsonLd(MOONLIGHT_STAY_PAYLOAD, PAGE);
|
||||
for (const offer of business.makesOffer as Record<string, unknown>[]) {
|
||||
expect(offer.availability).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('예약 액션은 확정된 채널만 가리킨다', () => {
|
||||
const [business] = collectJsonLd(MOONLIGHT_STAY_PAYLOAD, PAGE);
|
||||
const action = business.potentialAction as {target: {urlTemplate: string}};
|
||||
expect(action.target.urlTemplate).toBe('https://m.place.naver.com/accommodation/1234567890');
|
||||
});
|
||||
|
||||
it('예약 채널이 하나도 확정되지 않으면 예약 액션을 내보내지 않는다', () => {
|
||||
const noChannel = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
links: MOONLIGHT_STAY_PAYLOAD.links.map((link) => ({...link, confirmed: false})),
|
||||
};
|
||||
const [business] = collectJsonLd(noChannel, PAGE);
|
||||
expect(business.potentialAction).toBeUndefined();
|
||||
// 요금은 그대로 나간다 — 예약 창구가 전화뿐인 업소도 요금은 사실이다.
|
||||
expect((business.makesOffer as unknown[]).length).toBe(2);
|
||||
});
|
||||
|
||||
it('숙박이 아니면 예약 오퍼·액션을 붙이지 않는다', () => {
|
||||
const cafe = {
|
||||
...MOONLIGHT_STAY_PAYLOAD,
|
||||
place: {...MOONLIGHT_STAY_PAYLOAD.place, category: PlaceCategory.CAFE},
|
||||
};
|
||||
const [business] = collectJsonLd(cafe, PAGE);
|
||||
expect(business.makesOffer).toBeUndefined();
|
||||
expect(business.potentialAction).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('llms.txt — AI 가 예약 경로를 읽는 자리', () => {
|
||||
it('재고와 결제를 우리가 갖지 않는다고 명시한다', () => {
|
||||
expect(renderLlmsTxt(MOONLIGHT_STAY_PAYLOAD)).toContain(
|
||||
'이 홈페이지는 빈 방 재고와 결제를 처리하지 않습니다.',
|
||||
);
|
||||
});
|
||||
|
||||
it('예약 창구와 기준 요금이 위쪽 블록에 있다 — 아래에만 있으면 답에 안 실린다', () => {
|
||||
const txt = renderLlmsTxt(MOONLIGHT_STAY_PAYLOAD);
|
||||
expect(txt).toContain('- 전화 예약: 0507-1345-8821');
|
||||
expect(txt).toContain('- 기준 요금 — Moonlight A동: 주중 1박 280,000원');
|
||||
expect(txt.indexOf('## 예약')).toBeLessThan(txt.indexOf('## 이용 정보'));
|
||||
});
|
||||
|
||||
it('확정 전 채널은 예약 블록에 없다', () => {
|
||||
const txt = renderLlmsTxt(MOONLIGHT_STAY_PAYLOAD);
|
||||
const booking = txt.slice(txt.indexOf('## 예약'), txt.indexOf('## 이용 정보'));
|
||||
expect(booking).not.toContain(UNCONFIRMED_URL);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user