Phase 11: version PDF (FR-15)

- เลข version ใหม่: เว็บ-generate = v0 ฉบับตั้งต้น (ไม่มี PDF), add-in save (Start Versioning + Save & Version) = v1+ มี PDF เสมอ
- PDF ผลิตจาก Word จริงผ่าน task pane เท่านั้น (getFileAsync Pdf + runtime guard, manifest ไม่เพิ่ม requirement); capture/upload เป็น best-effort — docx ผ่านแม้ PDF ล้ม + MessageBar เตือนตาม hasPdf
- Backend: DocumentVersion.PdfObjectKey (nullable, migration AddVersionPdf) + sibling .pdf ใน bucket docx-versions · multipart part pdf (ผิด type → 400) · /download + /download-link รับ ?format=pdf (ไม่มี → 404) · presigned ฝังชื่อไฟล์ไทย + _vN (RFC 5987)
- Web: เปิดไฟล์แทน blob-download — PDF แท็บใหม่, docx ผ่าน ms-word:ofe|u| พร้อม heuristic fallback ลิงก์สำรอง (useVersionOpen, versionDownload) · ปุ่ม "เปิดใน Word" ที่หน้า success ของฟอร์มสร้างเอกสาร
- Spec v7 + CONTEXT.md + ADR 0001 + แผน docs/plans/version-pdf.md
- Automated QA: backend 68 / add-in 63 / web 55 ผ่าน · manual acceptance ผ่านบน Word for Mac (2026-09-08) รวม fidelity + track changes — ค้างเฉพาะ Windows / Word on the web

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Suphonchai Phoonsawat 2026-09-08 14:01:13 +07:00
parent 618328ffa7
commit 39d610a781
39 changed files with 1387 additions and 212 deletions

View file

@ -1,6 +1,6 @@
# ตรวจ Acceptance Criteria 1–17 (Phase 8 + 9 + 10)
# ตรวจ Acceptance Criteria 1–18 (Phase 8 + 9 + 10 + 11)
> วันที่ตรวจ: 2026-08-20 (AC 1–16) · 2026-08-22 (AC-17) · อ้างอิง AC จาก [`specs/spec-officejs.md`](../specs/spec-officejs.md) ส่วน 10
> วันที่ตรวจ: 2026-08-20 (AC 1–16) · 2026-08-22 (AC-17) · 2026-09-08 (AC-18) · อ้างอิง AC จาก [`specs/spec-officejs.md`](../specs/spec-officejs.md) ส่วน 10
>
> สัญลักษณ์: ✅ ผ่าน (มี automated test คุ้ม) · 🖐️ ผ่านจากการทดสอบด้วยมือ · 🔶 ผ่านบางส่วน/รอยืนยันด้วยมือบน platform ที่เหลือ · ❌ ไม่ผ่าน
@ -103,3 +103,35 @@
- [ ] Theme toggle จำค่าหลัง reload บน browser จริง (Phase 6 DoD ที่เหลือ)
- [ ] (v5) ใน Word จริง: textarea ใน dialog ของทั้ง Save & Version และ Start Versioning + ข้อความโชว์ใน `VersionHistoryPanel` (AC-16) · และบน browser: ฟอร์มสร้างเอกสารพร้อม message + แสดงใน history ทั้ง desktop/mobille
- [ ] (v6) บน browser: หน้าแก้ template เลือก editor `textarea` (desktop + mobile) · ฟอร์มสร้างเอกสาร render textarea/ช่องตัวเลข/date picker ตาม editor · re-generate เอกสารที่ field date เก็บ timestamp เต็มแล้วช่อง date แสดงวันที่ถูกต้อง (AC-17)
## AC-18 — Version PDF (v7)
**ผล: ✅ ผ่าน — automated verification + 🖐️ manual acceptance บน Word for Mac (2026-09-08)**. AC เดิมที่กล่าว generate=v1 ให้อ่านเป็น v0 ตาม spec v7; Start Versioning ยังคงเริ่ม v1.
| เกณฑ์ | หลักฐาน |
|---|---|
| generate v0 ไม่มี PDF → upload v1 มี PDF | `VersionPdfTests.Generate_V0WithoutPdf_ThenUpload_V1WithPdf`; migration `AddVersionPdf` ผ่าน PostgreSQL จริง |
| PDF sibling key, hasPdf, bytes/type/ชื่อไทย, presigned signature | `Upload_WithPdf_PersistsSiblingKey_AndDownloadsExactBytes` อ่าน proxy และ presigned URL จาก MinIO จริงทั้ง PDF/docx |
| ไม่มี PDF → false + 404 ทั้งสอง download endpoint | `Upload_WithoutPdf_HasFalse_AndBothPdfDownloadsReturn404` |
| นามสกุล/type ผิดหรือว่าง → 400 ก่อนสร้าง document | `InvalidPdf_Returns400_BeforeCreatingDocument` (3 cases) |
| PDF storage ล้ม → 201/false; docx storage ล้ม → 502/rollback | `StorageFailure_PdfIsBestEffort_DocxStillRollsBack` (2 cases; fault injection + PostgreSQL จริง) |
| ทั้งสอง add-in flows capture docx → PDF, fail/empty ไม่บล็อก upload | `versionFlow.test.ts` FR-15 matrix: start/save × success/failure/empty/storage-failure |
| PDF runtime guard, normalize slices, ปิด File object | `fileService.test.ts` PDF cases; manifest ไม่เพิ่ม requirement |
| multipart PDF + format query | `versioningService.test.ts` |
| URL ms-word คง signed URL, v0 filename, PDF path | `versionDownload.spec.ts` |
| PDF popup/fallback/reset/error และ Word timeout cleanup | `useVersionOpen.spec.ts` 6 lifecycle tests |
ชุดเต็ม: backend **68 ผ่าน**, add-in **63 ผ่าน** + build/lint ผ่าน, web **55 ผ่าน** + production build ผ่าน. Add-in build มี webpack bundle-size warnings; ไม่มี compile/lint errors.
### ยืนยันด้วยมือ — ผ่านบน Word for Mac (2026-09-08)
- [x] Mac: เว็บ v0 → เปิดใน Word → Save & Version → v1 + PDF ไม่มี warning, ปุ่ม PDF เฉพาะ v1 · Start Versioning → v1 + PDF ทันที
- [x] เทียบ PDF กับ Word Save As PDF: ฟอนต์ไทย TH Sarabun New render + embed, หัวท้ายกระดาษ — ตรง
- [x] Track Changes เปิดทิ้งไว้ → Save & Version → **PDF ไม่มี markup ปน** — ไม่มีข้อจำกัดต้องบันทึกเพิ่มใน spec
- [x] Warning path เมื่อ PDF capture ล้ม; ปุ่ม PDF ขึ้นเฉพาะ version ที่มี
- [x] เว็บ: docx เปิด Word ผ่าน `ms-word` พร้อม fallback ลิงก์สำรอง, PDF เปิดแท็บใหม่, ชื่อไฟล์สวยทั้งสองกรณี
- [ ] ค้างตามเดิม (ต้องมีเครื่อง/บัญชีทดสอบ): **Word for Windows + Word on the web** — sideload + full flow; เป็นข้อค้างเดิมตั้งแต่ AC-1 ไม่ใช่ของใหม่ใน AC-18
รายการเต็ม: [แผน FR-15](plans/version-pdf.md). ไม่มีการอ้างว่า unit tests ยืนยัน layout/Word protocol handler ได้.
QA reviewer: **PASS**, 2 rounds, 3 findings fixed (build compatibility, pending PDF tab cleanup, PDF success copy); 2026-09-08. Manual acceptance ผ่านบน Word for Mac 2026-09-08 — **Phase 11 ปิดแล้ว**; ค้างเฉพาะ Word for Windows / Word on the web ตามรายการด้านบน.