Merge branch 'feat/project-comment-image-viewer'
This commit is contained in:
@@ -61,6 +61,9 @@
|
||||
- 업무 창 맨 위 **삭제 오른쪽 = 작성자**(2026-10-21, `showTaskCreator` — `created_by` 아이콘 + 이름(yyyy.mm.dd(요일) hh:mm:ss), `created_at` KST ISO 글자를 그대로 잘라 씀, 세부 업무도).
|
||||
- 업무 창 댓글 칸 **Ctrl+V 이미지 붙여넣기**(2026-10-21) — 칸 위 썸네일(×로 빼기) → [등록] = `POST …/comments/files` 한 요청(댓글 대화창과 같은 API, 글 없이 이미지만도), 업무를 바꾸면 비움.
|
||||
복사한 내용에 글자가 있으면 글자 붙여넣기가 먼저(대화창과 같음). 브라우저 테스트 `tests/js/task_creator_paste.browser.test.js`.
|
||||
- **댓글 사진 누르기 = 이미지 창**(2026-10-22) — 업무 창 댓글·댓글 대화창의 사진(`a.pj-comment-att-img`·`.pj-chat-att-img a`)을 누르면 내려받지 않고
|
||||
`openImageWindow(img, {actual, download, name})` 별도 창: 처음 100%(창보다 커도, 끌어 이동), 휠 확대·축소, [원본 보기](=100%, 예전 "1:1")·[맞춤]·[복사]·[다운로드](첨부 download 주소).
|
||||
Ctrl·Shift·가운데 클릭은 예전처럼 링크. 설명란 이미지 더블클릭은 그대로(처음 맞춤). 테스트 `tests/js/comment_image_viewer.browser.test.js`.
|
||||
- **파일 끌어 놓기**(2026-10-19): 종류 "Files" 로 카드·세부 업무 끌기와 구분, 받는 곳 밖에 놓친 파일은 document 가 막아 화면이 파일로 넘어가지 않음.
|
||||
- **설명란·세부 업무 목록·보드 카드(펼친 세부 업무 줄) → 구글 드라이브**: `POST /project/api/tasks/{id}/drive-files`(`app/integrations/google_drive.py`, 최상위 `PROJECT_DRIVE_FOLDER_ID` 기본 `1Zdak2FtACRJ6peOnA9zD22hsbbsTixJG` 아래 `프로젝트/섹션/업무/세부 업무` 폴더 자동, 세부 업무 섹션 = 맨 위 업무 섹션). 링크 제목 = 파일 이름.확장자(새 탭). 설명란 = 놓은 자리(`descEditor.insertDriveFiles`, 올리는 중 표시·저장 미룸), 세부 업무 줄·카드 = `append=true` 로 서버가 설명 끝에 붙임 — 단 지금 업무 창에 열린 업무면 편집기 끝에(옛 설명 저장이 링크를 덮지 않게, `dropDriveFilesOnTask`).
|
||||
- **링크를 지우면 드라이브 휴지통**: `api_update_task` 가 설명 저장 전후 드라이브 링크 id 를 비교 → 백그라운드 `_sync_drive_links` — 우리가 올린 파일(appProperties `dbxTaskId`)만, 다른 업무 설명에 같은 링크가 있으면 그대로(`db.description_mentions`), 링크가 다시 생기면 휴지통에서 꺼냄. DB 변경 없음.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -289,5 +289,5 @@
|
||||
|
||||
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
|
||||
<script src="/static/project-meeting-cells.js?v=20261012a" defer></script>
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -207,5 +207,5 @@
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/project-help.css?v=20261003a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
@@ -375,6 +375,7 @@
|
||||
<h3>댓글</h3>
|
||||
<p>업무 창 맨 아래에 항상 고정된 댓글 칸에 쓰고 <kbd>Enter</kbd>(스크롤해도 그 자리에 있습니다). 칸 오른쪽 <span class="pjh-ui">☺</span>는 이모티콘, <span class="pjh-ui">@</span>는 멤버 태그입니다. 답글은 원 댓글 아래 들여 쓰여 <span class="pjh-ui">↳</span> 표시와 함께 보입니다. 내가 쓴 댓글은 <span class="pjh-ui">✎</span>로 고치고 <span class="pjh-ui">×</span>로 지웁니다. 댓글 속 웹 주소는 링크가 됩니다. 댓글에 붙인 파일은 그 댓글 아래에 보이고(파일만 보낸 댓글도), 첨부 파일 목록에는 <span class="pjh-ui">댓글</span> 표시가 붙습니다.</p>
|
||||
<p>캡처한 이미지를 댓글 칸에 <kbd>Ctrl</kbd>+<kbd>V</kbd>로 붙여넣으면 칸 위에 작은 미리보기로 담기고(<span class="pjh-ui">×</span>로 빼기), <span class="pjh-ui">등록</span>하면 글과 함께 댓글 첨부로 올라갑니다. 글 없이 이미지만 보내도 됩니다. 복사한 내용에 글자가 함께 있으면 글자가 붙습니다.</p>
|
||||
<p>댓글에 붙은 사진을 누르면 내려받지 않고 <b>이미지 창</b>이 따로 열립니다 — 처음엔 원본 크기(100%)로 보이고, 창보다 크면 마우스로 <b>끌어서 이동</b>, <b>휠</b>로 확대·축소합니다. 아래 막대의 <span class="pjh-ui">원본 보기</span>는 100%로 되돌리기, <span class="pjh-ui">맞춤</span>은 창에 맞추기, <span class="pjh-ui">다운로드</span>는 파일 내려받기입니다. (Ctrl을 누른 채 클릭하면 예전처럼 새 탭에서 엽니다.)</p>
|
||||
<p>댓글 대화창에서 파일을 보낼 때 보낼 수 없는 파일(빈 파일, 20MB 초과)이 있으면 댓글을 만들지 않고 그 파일만 빨갛게 표시합니다 — 빼고 다시 보내세요. 인터넷이 끊겨도 쓴 내용과 파일은 그대로 남아 다시 보낼 수 있고, 같은 댓글이 두 번 올라가지 않습니다. @태그는 이 업무를 볼 수 있는 사람만 고를 수 있습니다. 한글을 입력하는 중(조합 중)의 <kbd>Enter</kbd>는 글자 확정만 하고 보내지 않습니다.</p>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -106,5 +106,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,5 +100,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -108,5 +108,5 @@
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -476,5 +476,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261021a" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261022a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261021a" defer></script>
|
||||
<script src="/static/project.js?v=20261022a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -3374,3 +3374,6 @@ button.pj-meet-quick-open:hover { background: #f1f3f5; color: var(--pj-accent-da
|
||||
.pj-meet-quick-modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
|
||||
.pj-meet-quick-modal .pj-meet-quick-table { font-size: 14px; }
|
||||
.pj-meet-quick-modal .pj-meet-quick-table th { font-size: 13px; padding: 6px 8px; }
|
||||
|
||||
/* 댓글 사진 — 누르면 이미지 창(100%·끌어 이동·휠 확대·다운로드·원본 보기, 2026-10-22) */
|
||||
.pj-comment-att-img img, .pj-chat-att-img img { cursor: zoom-in; }
|
||||
|
||||
+25
-5
@@ -2350,7 +2350,10 @@
|
||||
// 창 크기 = 이미지 원본 크기(+ 여백·도구 막대), 화면보다 크면 화면 95% 까지. 처음엔 원본(100%), 창보다 크면 창에 맞춤.
|
||||
// 창 안: 휠 = 마우스 위치 기준 확대·축소, 끌기 = 이동, 아래 막대 − / % / + · 1:1(원본) · 맞춤,
|
||||
// 더블클릭 = 원본 ↔ 맞춤, 키보드 + − 0(맞춤) 1(원본). 이미지는 같은 서버 첨부 주소라 로그인 쿠키로 그대로 열린다.
|
||||
function openImageWindow(img) {
|
||||
// opts(2026-10-22 댓글 사진) — actual: 창보다 커도 처음부터 100%(원본)로(끌어서 이동), download: 다운로드 주소(막대에 [다운로드]),
|
||||
// name: 창 제목·파일 이름. 막대의 [원본 보기] = 100% 로 되돌리기(예전 "1:1").
|
||||
function openImageWindow(img, opts) {
|
||||
opts = opts || {};
|
||||
const src = new URL(img.getAttribute("src") || img.src, location.href).href;
|
||||
const nw = img.naturalWidth || 1200, nh = img.naturalHeight || 800;
|
||||
const sw = (window.screen && screen.availWidth) || 1600, sh = (window.screen && screen.availHeight) || 900;
|
||||
@@ -2361,7 +2364,8 @@
|
||||
const win = window.open("", "pj-img-" + Date.now(),
|
||||
"popup=yes,width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + ",resizable=yes,scrollbars=no");
|
||||
if (!win) { showToast("팝업이 막혀 있습니다. 브라우저 주소창 오른쪽에서 이 사이트의 팝업을 허용해 주세요.", "error"); return; }
|
||||
const title = (img.getAttribute("alt") || "").trim() || decodeURIComponent((src.split("?")[0].split("/").pop() || "이미지"));
|
||||
const title = (opts.name || img.getAttribute("alt") || "").trim() || decodeURIComponent((src.split("?")[0].split("/").pop() || "이미지"));
|
||||
const dl = opts.download ? new URL(opts.download, location.href).href : "";
|
||||
const ICON = function (d) {
|
||||
return '<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round">' + d + "</svg>";
|
||||
};
|
||||
@@ -2374,6 +2378,8 @@
|
||||
'background:rgba(40,42,47,.92);border:1px solid rgba(255,255,255,.08);border-radius:10px;box-shadow:0 6px 18px rgba(0,0,0,.35);z-index:2}' +
|
||||
'#bar button{height:30px;min-width:34px;padding:0 8px;border:0;border-radius:7px;background:transparent;color:#fff;cursor:pointer;' +
|
||||
'display:inline-flex;align-items:center;justify-content:center;font-family:inherit;font-weight:600;font-size:12.5px}' +
|
||||
'#bar a{height:30px;padding:0 10px;border-radius:7px;color:#fff;text-decoration:none;display:inline-flex;align-items:center;gap:4px;font-weight:600;font-size:12.5px}' +
|
||||
'#bar a:hover{background:rgba(255,255,255,.14)}#bar a:focus-visible{outline:2px solid #9d8cff;outline-offset:1px}' +
|
||||
'#bar button:hover{background:rgba(255,255,255,.14)}#bar button:focus-visible{outline:2px solid #9d8cff;outline-offset:1px}' +
|
||||
'#pct{min-width:56px;text-align:center;font-size:13px;font-variant-numeric:tabular-nums}' +
|
||||
'.sep{width:1px;height:18px;background:rgba(255,255,255,.18);margin:0 4px}' +
|
||||
@@ -2387,10 +2393,13 @@
|
||||
'<button id="out" title="축소 (−)" aria-label="축소">' + ICON('<path d="M5 10h10"/>') + "</button>" +
|
||||
'<span id="pct">100%</span>' +
|
||||
'<button id="in" title="확대 (+)" aria-label="확대">' + ICON('<path d="M5 10h10M10 5v10"/>') + "</button>" +
|
||||
'<span class="sep"></span><button id="one" title="원본 크기 (1)">1:1</button><button id="fit" title="창에 맞춤 (0)">맞춤</button>' +
|
||||
'<span class="sep"></span><button id="one" title="원본 크기 100% (1)">원본 보기</button><button id="fit" title="창에 맞춤 (0)">맞춤</button>' +
|
||||
'<span class="sep"></span><button id="copy" title="이미지 복사 (Ctrl+C) — 카카오톡·한글·그림판 등에 그림으로 붙여넣기" aria-label="이미지 복사">' +
|
||||
ICON('<rect x="7" y="7" width="10" height="10" rx="1.6"/><path d="M13 7V4.6A1.6 1.6 0 0 0 11.4 3H4.6A1.6 1.6 0 0 0 3 4.6v6.8A1.6 1.6 0 0 0 4.6 13H7"/>') +
|
||||
' 복사</button></div>' +
|
||||
' 복사</button>' +
|
||||
(dl ? '<a id="dl" href="' + dl.replace(/"/g, """) + '" download title="이미지 파일 내려받기">' +
|
||||
ICON('<path d="M10 3v10M6 9l4 4 4-4M4 16h12"/>') + " 다운로드</a>" : "") +
|
||||
"</div>" +
|
||||
"<script>(function(){" +
|
||||
"var SRC=" + JSON.stringify(src) + ",TITLE=" + JSON.stringify(title) + ";document.title=TITLE;" +
|
||||
"var img=document.getElementById('img'),stage=document.getElementById('stage'),pct=document.getElementById('pct');" +
|
||||
@@ -2399,7 +2408,7 @@
|
||||
"function zoomAt(n,cx,cy){n=Math.min(MAX,Math.max(MIN,n));x=cx-(cx-x)*n/s;y=cy-(cy-y)*n/s;s=n;apply();}" +
|
||||
"function centerAt(n){s=n;x=(innerWidth-img.naturalWidth*s)/2;y=(innerHeight-BAR-img.naturalHeight*s)/2+4;if(y<8)y=8;apply();}" +
|
||||
"function fitScale(){return Math.min((innerWidth-32)/img.naturalWidth,(innerHeight-BAR-24)/img.naturalHeight);}" +
|
||||
"img.onload=function(){var f=fitScale();centerAt(f<1?f:1);};" +
|
||||
"img.onload=function(){var f=fitScale();centerAt(" + (opts.actual ? "1" : "f<1?f:1") + ");};" +
|
||||
"img.onerror=function(){document.getElementById('err').style.display='flex';};img.src=SRC;" +
|
||||
"stage.addEventListener('wheel',function(e){e.preventDefault();zoomAt(s*Math.exp(-e.deltaY*0.0015),e.clientX,e.clientY);},{passive:false});" +
|
||||
"var drag=null;stage.addEventListener('pointerdown',function(e){if(e.button!==0)return;drag={x:e.clientX,y:e.clientY,ox:x,oy:y};stage.setPointerCapture(e.pointerId);stage.classList.add('drag');});" +
|
||||
@@ -2434,6 +2443,17 @@
|
||||
try { win.focus(); } catch (_) {}
|
||||
}
|
||||
|
||||
// ── 댓글에 첨부된 사진(업무 창 댓글 목록·댓글 대화창) — 누르면 내려받지 않고 이미지 창(100%, 끌어 이동·휠 확대·다운로드·원본 보기)
|
||||
// 으로 연다(2026-10-22). Ctrl·Shift·가운데 단추로 누르면 예전처럼 링크(새 탭·다운로드)로.
|
||||
document.addEventListener("click", function (e) {
|
||||
const a = e.target.closest && e.target.closest("a.pj-comment-att-img, .pj-chat-att-img a");
|
||||
if (!a || e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;
|
||||
const img = a.querySelector("img");
|
||||
if (!img) return;
|
||||
e.preventDefault();
|
||||
openImageWindow(img, { actual: true, download: a.getAttribute("href"), name: img.getAttribute("alt") || a.getAttribute("title") || "" });
|
||||
});
|
||||
|
||||
// ── 댓글·답글 입력칸 — 전송·붙여넣기 뒤에도 70px 고정, 긴 글은 내부 스크롤.
|
||||
function fitComposer(ta) {
|
||||
if (!ta || ta.tagName !== "TEXTAREA") return;
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
// 실제 브라우저 — 업무 창 댓글에 붙은 사진을 누르면 내려받지 않고 이미지 창(별도 브라우저 창)이 열린다(2026-10-22).
|
||||
// 처음 100%(창보다 커도), 끌어서 이동, 휠 확대·축소, [원본 보기] = 100% 로, [다운로드] = 첨부 다운로드 주소. Ctrl+클릭은 예전처럼 링크.
|
||||
// python tests/js/render_project.py
|
||||
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/comment_image_viewer.browser.test.js
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs"), path = require("node:path"), http = require("node:http"), zlib = require("node:zlib");
|
||||
const { chromium } = require("playwright");
|
||||
const ROOT = path.resolve(__dirname, "../.."), OUT = path.join(__dirname, ".out"), STATIC = path.join(ROOT, "app/static");
|
||||
|
||||
// 1600×1000 PNG(단색 + 가로 줄무늬) — 창보다 큰 사진
|
||||
function png(w, h) {
|
||||
const crcTable = Array.from({ length: 256 }, (_, n) => { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; return c >>> 0; });
|
||||
const crc = buf => { let c = 0xffffffff; for (const b of buf) c = crcTable[(c ^ b) & 0xff] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
|
||||
const chunk = (type, data) => { const len = Buffer.alloc(4); len.writeUInt32BE(data.length); const td = Buffer.concat([Buffer.from(type), data]);
|
||||
const c = Buffer.alloc(4); c.writeUInt32BE(crc(td)); return Buffer.concat([len, td, c]); };
|
||||
const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(w, 0); ihdr.writeUInt32BE(h, 4); ihdr[8] = 8; ihdr[9] = 2;
|
||||
const rows = [];
|
||||
for (let y = 0; y < h; y++) { const r = Buffer.alloc(1 + w * 3); for (let x = 0; x < w; x++) { const v = (y >> 5) % 2 ? 90 : 200; r[1 + x * 3] = v; r[2 + x * 3] = 150; r[3 + x * 3] = 255 - v; } rows.push(r); }
|
||||
return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", ihdr), chunk("IDAT", zlib.deflateSync(Buffer.concat(rows))), chunk("IEND", Buffer.alloc(0))]);
|
||||
}
|
||||
const PHOTO = png(1600, 1000);
|
||||
const detail = (id) => ({ id, title: "작업 " + id, project_id: 1, stage_id: 11, description: "", priority: "normal",
|
||||
assignee_email: "", subtasks: [], links: [], followers: [], access: "full", completed_at: null, created_by: "me@test.local" });
|
||||
const downloads = [];
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const url = new URL(req.url, "http://localhost");
|
||||
const json = (code, body) => { res.statusCode = code; res.setHeader("Content-Type", "application/json"); res.end(JSON.stringify(body)); };
|
||||
if (url.pathname === "/project/p/1") { res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(fs.readFileSync(path.join(OUT, "project_render.html"))); return; }
|
||||
if (url.pathname === "/project/api/attachments/7/inline") { res.setHeader("Content-Type", "image/png"); res.end(PHOTO); return; }
|
||||
if (url.pathname === "/project/api/attachments/7/download") {
|
||||
downloads.push(url.pathname);
|
||||
res.setHeader("Content-Type", "image/png"); res.setHeader("Content-Disposition", 'attachment; filename="photo.png"'); res.end(PHOTO); return;
|
||||
}
|
||||
if (url.pathname.startsWith("/project/api/")) {
|
||||
const task = /^\/project\/api\/tasks\/(\d+)$/.exec(url.pathname);
|
||||
if (task) return json(200, { task: detail(+task[1]) });
|
||||
if (url.pathname.endsWith("/comments")) return json(200, { comments: [{ id: 1, task_id: 101, author_email: "me@test.local", author_name: "Me",
|
||||
body: "사진 확인 부탁", created_at: "2026-10-21T16:10:00+09:00", parent_id: null, reactions: [] }], events: [], features: {} });
|
||||
if (url.pathname.endsWith("/attachments")) return json(200, { attachments: [{ id: 7, task_id: 101, comment_id: 1, filename: "photo.png",
|
||||
content_type: "image/png", size_bytes: PHOTO.length, uploaded_by: "me@test.local", created_at: "2026-10-21T16:10:00+09:00" }] });
|
||||
if (url.pathname.endsWith("/members")) return json(200, { members: [{ user_email: "me@test.local" }] });
|
||||
if (url.pathname.endsWith("/live-version")) return json(200, { ts: "v1" });
|
||||
if (url.pathname.endsWith("/alerts")) return json(200, { me: "me@test.local", latest_id: 0, alerts: [] });
|
||||
return json(200, {});
|
||||
}
|
||||
if (url.pathname.startsWith("/static/")) {
|
||||
const file = path.join(STATIC, decodeURIComponent(url.pathname.slice("/static/".length)));
|
||||
if (file.startsWith(STATIC) && fs.existsSync(file)) {
|
||||
res.setHeader("Content-Type", file.endsWith(".js") ? "text/javascript" : file.endsWith(".css") ? "text/css" : "application/octet-stream");
|
||||
res.end(fs.readFileSync(file)); return;
|
||||
}
|
||||
}
|
||||
res.statusCode = 404; res.end("");
|
||||
});
|
||||
|
||||
(async function () {
|
||||
await new Promise(r => server.listen(0, "127.0.0.1", r));
|
||||
const base = "http://127.0.0.1:" + server.address().port;
|
||||
const browser = await chromium.launch(process.env.PJ_TEST_BROWSER ? { executablePath: process.env.PJ_TEST_BROWSER } : {});
|
||||
const ctx = await browser.newContext({ viewport: { width: 1600, height: 1000 }, acceptDownloads: true });
|
||||
const page = await ctx.newPage();
|
||||
const errors = [];
|
||||
page.on("pageerror", e => errors.push(e.message));
|
||||
const pass = [];
|
||||
const ok = (name, cond, extra) => { assert.ok(cond, name + (extra === undefined ? "" : " → " + JSON.stringify(extra))); pass.push(name); console.log("PASS " + name); };
|
||||
try {
|
||||
await page.goto(base + "/project/p/1?task=101");
|
||||
const thumb = page.locator("a.pj-comment-att-img img");
|
||||
await thumb.waitFor();
|
||||
await page.waitForFunction(() => { const i = document.querySelector("a.pj-comment-att-img img"); return i && i.naturalWidth > 0; });
|
||||
ok("댓글 사진 = 누를 수 있는 확대 커서", await thumb.evaluate(i => getComputedStyle(i).cursor) === "zoom-in");
|
||||
const [pop] = await Promise.all([ctx.waitForEvent("page"), thumb.click()]);
|
||||
await pop.waitForFunction(() => { const i = document.getElementById("img"); return i && i.naturalWidth > 0 && document.getElementById("pct").textContent; });
|
||||
ok("누르면 내려받지 않고 이미지 창이 열림", downloads.length === 0 && pop !== page);
|
||||
const st = () => pop.evaluate(() => ({ pct: document.getElementById("pct").textContent, tr: document.getElementById("img").style.transform,
|
||||
title: document.title, w: innerWidth, h: innerHeight }));
|
||||
const s0 = await st();
|
||||
ok("처음 100%(사진 1600×1000 이 창보다 커도), 창 제목 = 파일 이름", s0.pct === "100%" && s0.title === "photo.png" && (s0.w < 1600 || s0.h < 1000), s0);
|
||||
const box = await pop.locator("#stage").boundingBox();
|
||||
await pop.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
||||
await pop.mouse.down();
|
||||
await pop.mouse.move(box.x + box.width / 2 + 150, box.y + box.height / 2 + 80, { steps: 5 });
|
||||
await pop.mouse.up();
|
||||
const s1 = await st();
|
||||
ok("끌면 이미지가 움직임(100% 그대로)", s1.tr !== s0.tr && s1.pct === "100%", { before: s0.tr, after: s1.tr });
|
||||
await pop.mouse.wheel(0, -300);
|
||||
const s2 = await st();
|
||||
await pop.mouse.wheel(0, 600);
|
||||
const s3 = await st();
|
||||
ok("휠 위 = 확대, 아래 = 축소", parseInt(s2.pct, 10) > 100 && parseInt(s3.pct, 10) < parseInt(s2.pct, 10), [s2.pct, s3.pct]);
|
||||
await pop.click("#one");
|
||||
ok("[원본 보기] = 100% 로", (await st()).pct === "100%" && (await pop.locator("#one").textContent()).trim() === "원본 보기");
|
||||
await pop.click("#fit");
|
||||
ok("[맞춤] = 창에 맞춤(100% 아래)", parseInt((await st()).pct, 10) < 100);
|
||||
const dlHref = await pop.getAttribute("#dl", "href");
|
||||
ok("[다운로드] = 첨부 다운로드 주소", /\/project\/api\/attachments\/7\/download$/.test(dlHref || ""), dlHref);
|
||||
const [download] = await Promise.all([pop.waitForEvent("download"), pop.click("#dl")]);
|
||||
ok("[다운로드] 누르면 파일 내려받기", download.suggestedFilename() === "photo.png" && downloads.length === 1, download.suggestedFilename());
|
||||
await pop.locator("#bar").screenshot({ path: path.join(OUT, "comment_image_bar.png") });
|
||||
await pop.screenshot({ path: path.join(OUT, "comment_image_viewer.png") });
|
||||
await pop.close();
|
||||
ok("페이지 오류 없음", errors.length === 0, errors);
|
||||
console.log("\nALL PASS (" + pass.length + ")");
|
||||
} finally {
|
||||
await browser.close();
|
||||
server.close();
|
||||
}
|
||||
})().catch(e => { console.error(e); process.exit(1); });
|
||||
Reference in New Issue
Block a user