89ad338024
- Subproject tasks via parent /tasks are re-filtered by current access (FULL/READ kept)
- PUT /api/projects/order: every id must be manageable; bad/duplicate ids -> 400, all-or-nothing
- Inbox, web alert popup, PC notifier open tasks via /project/t/{id}; embed=1 survives redirect;
old /p/{home}?task= redirects READ users to the linked project
- Project page / snapshot / workload include the opened archived or sub project only
- Alerts: DB-side filters + oldest-first paging (no 50-row cut); badges counted without caps;
my tasks keep every open task (completed capped)
- Meeting results: next-week meeting open, or own meeting open when no next meeting;
header edits + result checks under row locks (FOR UPDATE / FOR SHARE)
- Inbox panel waits for the task window save (same retry/discard flow) before switching/closing;
read failures stay unread
- Attachment upload removes only its own file on DB failure
- New project modal: create once, retry only failed member assignments
- update_task / update_project: locked-row validation in one transaction; completion hints from real transition
- Creator added as explicit member when another owner is chosen
- _once lock lifetime managed by refcount (no leak on failure)
- Section default assignee must still be a registered project user; follower add uses can_assign
- Docs (PROJECT_MODULE 6-15, help), tests (DB-less, real PostgreSQL, jsdom, Chrome)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
135 lines
9.1 KiB
JavaScript
135 lines
9.1 KiB
JavaScript
// 실제 브라우저 — 수신함 오른쪽 작업 창(iframe)이 다른 줄로 바뀌거나 닫히기 전에 작업 창의 저장을 기다리는지,
|
|
// 저장 실패면 작업 창과 같은 "버리고 넘어가기 / 계속 편집"을 묻는지, 공유 링크 리다이렉트 뒤에도 embed 인지,
|
|
// iframe 안 Esc·빠른 A→B→A·읽음 실패를 확인한다. 서버는 가짜(이 파일의 http 서버), 화면은 실제 템플릿 렌더 결과.
|
|
// python tests/js/render_project.py
|
|
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/inbox_panel.browser.test.js
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs"), path = require("node:path"), http = require("node:http");
|
|
const { chromium } = require("playwright");
|
|
const ROOT = path.resolve(__dirname, "../.."), OUT = path.join(__dirname, ".out"), STATIC = path.join(ROOT, "app/static");
|
|
|
|
const detail = (id, title) => ({ id, title, project_id: 1, stage_id: 11, description: "", priority: "normal",
|
|
assignee_email: "", subtasks: [], links: [], followers: [], access: "full", completed_at: null });
|
|
let putStatus = 200, holdPut = false, releasePut = null, failNotiRead = false;
|
|
const puts = [], reads = [];
|
|
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/inbox") { res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(fs.readFileSync(path.join(OUT, "inbox_render.html"))); return; }
|
|
const tm = /^\/project\/t\/(\d+)$/.exec(url.pathname);
|
|
if (tm) { // 공유 링크 — 서버(router.task_permalink)처럼 embed 를 이어서 보낸다
|
|
res.statusCode = 303;
|
|
res.setHeader("Location", `/project/p/1?task=${tm[1]}${url.searchParams.get("embed") === "1" ? "&embed=1" : ""}`);
|
|
res.end(); return;
|
|
}
|
|
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.startsWith("/project/api/")) {
|
|
let raw = ""; for await (const c of req) raw += c;
|
|
const body = raw ? JSON.parse(raw) : null;
|
|
const task = /^\/project\/api\/tasks\/(\d+)$/.exec(url.pathname);
|
|
if (task && req.method === "GET") return json(200, { task: detail(+task[1], "작업 " + task[1]) });
|
|
if (task && req.method === "PUT") {
|
|
puts.push({ id: +task[1], body });
|
|
if (holdPut) await new Promise(r => { releasePut = r; });
|
|
return putStatus >= 400 ? json(putStatus, { detail: "서버 오류" }) : json(200, { task: Object.assign(detail(+task[1], "작업"), body) });
|
|
}
|
|
if (url.pathname === "/project/api/mentions/read") { reads.push("m" + (body && body.task_id)); return json(200, { ok: true, marked: 1 }); }
|
|
const nr = /^\/project\/api\/notifications\/(\d+)\/read$/.exec(url.pathname);
|
|
if (nr) { reads.push("n" + nr[1]); return failNotiRead ? json(500, { detail: "db" }) : json(200, { ok: true }); }
|
|
if (url.pathname.endsWith("/comments")) return json(200, { comments: [], events: [], features: {} });
|
|
if (url.pathname.endsWith("/attachments")) return json(200, { attachments: [] });
|
|
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 page = await browser.newPage({ viewport: { width: 1920, height: 1080 } }); // 작업 창이 왼쪽 목록을 가리지 않는 보통 PC 화면
|
|
const dialogs = [];
|
|
let dialogAnswer = false;
|
|
page.on("dialog", async d => { dialogs.push(d.type() + ":" + d.message().slice(0, 20)); if (dialogAnswer) await d.accept(); else await d.dismiss(); });
|
|
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/inbox");
|
|
const frameOf = () => page.frames().find(f => f !== page.mainFrame());
|
|
const frameUrl = () => (frameOf() ? frameOf().url() : "");
|
|
const waitModal = async () => {
|
|
await page.waitForFunction(() => { const f = document.querySelector(".pj-inbox-panel iframe"); const d = f && f.contentDocument;
|
|
const m = d && d.getElementById("pj-modal-task"); return !!(m && !m.hidden && d.getElementById("pj-t-id").value); });
|
|
};
|
|
await page.click('#pj-mention-tasks .pj-inbox-item[data-task-id="101"]');
|
|
await waitModal();
|
|
ok("공유 링크 리다이렉트 뒤에도 embed 화면(작업 창만)", /\/project\/p\/1\?/.test(frameUrl()) && /embed=1/.test(frameUrl()) &&
|
|
await frameOf().evaluate(() => document.documentElement.classList.contains("pj-embed")), frameUrl());
|
|
ok("같은 작업의 태그·알림을 함께 확인", reads.includes("m101") && reads.includes("n901"), reads);
|
|
|
|
// ① 저장 실패 → 다른 줄 → 묻기 → 계속 편집: 창·입력 그대로
|
|
putStatus = 500;
|
|
const fr = frameOf();
|
|
await fr.fill("#pj-t-title", "작업 101 고침");
|
|
await fr.evaluate(() => document.getElementById("pj-t-title").blur());
|
|
await page.waitForTimeout(150);
|
|
dialogAnswer = false;
|
|
await page.click('#pj-mention-tasks .pj-inbox-item[data-task-id="102"]');
|
|
await page.waitForTimeout(400);
|
|
ok("저장 실패면 바꾸기 전에 묻고(작업 창과 같은 확인), 계속 편집이면 그대로", dialogs.length === 1 && /\?task=|\/p\/1/.test(frameUrl()) &&
|
|
await fr.evaluate(() => document.getElementById("pj-t-title").value) === "작업 101 고침" &&
|
|
!reads.includes("m102"), { dialogs, url: frameUrl(), reads });
|
|
|
|
// ② 저장 대기 중 A→B→A — 확인 뒤 A 그대로, 새 줄 안 열림
|
|
putStatus = 200; holdPut = true;
|
|
await page.click('#pj-mention-tasks .pj-inbox-item[data-task-id="102"]');
|
|
await page.waitForTimeout(150);
|
|
await page.click('#pj-mention-tasks .pj-inbox-item[data-task-id="101"]');
|
|
await page.waitForTimeout(100);
|
|
ok("저장이 끝나기 전엔 창을 바꾸지 않는다", frameOf() === fr && releasePut !== null);
|
|
holdPut = false; releasePut(); releasePut = null;
|
|
await page.waitForTimeout(500);
|
|
ok("A→B→A 빨리 — 저장 성공 뒤 A 작업 창 그대로(다시 읽지 않음)", frameOf() === fr &&
|
|
await fr.evaluate(() => document.getElementById("pj-t-id").value) === "101" && puts[puts.length - 1].body.title === "작업 101 고침" &&
|
|
!reads.includes("m102"), { puts: puts.length, reads });
|
|
|
|
// ③ 저장 성공 상태에서 B → 바로 바뀌고 이탈 경고 없음
|
|
const before = dialogs.length;
|
|
await page.click('#pj-mention-tasks .pj-inbox-item[data-task-id="102"]');
|
|
await waitModal();
|
|
await page.waitForFunction(() => document.querySelector(".pj-inbox-panel iframe").contentDocument.getElementById("pj-t-id").value === "102");
|
|
ok("저장된 상태면 묻지 않고 B 로(beforeunload 경고도 없음)", dialogs.length === before && reads.includes("m102"), dialogs);
|
|
|
|
// ④ iframe 안 포커스에서 Esc — 작업 창이 닫히며 패널도 닫힘, 확인한 줄은 목록에서 빠짐
|
|
const fr2 = frameOf();
|
|
await fr2.focus("#pj-t-title");
|
|
await page.keyboard.press("Escape");
|
|
await page.waitForFunction(() => !document.querySelector(".pj-inbox-panel").classList.contains("is-open"));
|
|
await page.waitForTimeout(400);
|
|
ok("iframe 안에서 Esc → 패널 닫힘, 확인한 태그 줄은 빠짐", await page.evaluate(() =>
|
|
!document.querySelector('#pj-mention-tasks .pj-inbox-item[data-task-id="102"]')));
|
|
|
|
// ⑤ 읽음 실패한 알림 줄은 남는다
|
|
failNotiRead = true;
|
|
await page.click('#pj-inbox .pj-inbox-item[data-id="903"]', { button: "right" });
|
|
await page.click(".pj-ctxmenu button, .pj-ctxmenu [role=menuitem], .pj-ctxmenu li");
|
|
await page.waitForTimeout(400);
|
|
ok("읽음 처리 실패 — 줄이 남고 굵게(읽지 않음)", await page.evaluate(() => {
|
|
const li = document.querySelector('#pj-inbox .pj-inbox-item[data-id="903"]'); return !!li && li.classList.contains("is-unread"); }));
|
|
console.log("\nALL PASS (" + pass.length + ")");
|
|
} finally {
|
|
await browser.close();
|
|
server.close();
|
|
}
|
|
})().catch(e => { console.error(e); process.exit(1); });
|