fix(project): grow cells and repair Enter

This commit is contained in:
2026-10-03 17:04:02 +09:00
parent 090e508bf3
commit d3c1ca12e9
10 changed files with 219 additions and 23 deletions
+92
View File
@@ -414,6 +414,98 @@ const server = http.createServer(function (req, res) {
assert(all.folded && all.width > 200 && all.saved === all.width, JSON.stringify(all));
console.log("PASS context menu single/all column fitting including collapsed columns");
await interactive.close();
for (const meeting of [false, true]) {
const typing = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
const typingErrors = []; typing.on("pageerror", e => typingErrors.push(e.message));
const url = "/project/goals/2026" + (meeting ? "/meetings/9" : "");
await typing.goto("http://127.0.0.1:" + server.address().port + url);
const editor = typing.locator(meeting ? 'tr[data-item="2"] .pj-meet-text' : '.pj-goal-text[data-row="10"][data-month="1"]');
const width = () => editor.locator("..").evaluate(td => td.getBoundingClientRect().width);
const originalWidth = await width();
const paragraph = "입력한 문단이 길어지면 이 셀의 열 너비가 자동으로 늘어납니다 ".repeat(4);
await editor.fill(paragraph);
await typing.waitForFunction(([selector, before]) => document.querySelector(selector).parentElement.getBoundingClientRect().width > before + 100,
[meeting ? 'tr[data-item="2"] .pj-meet-text' : '.pj-goal-text[data-row="10"][data-month="1"]', originalWidth]);
assert((await width()) > 600, "typing may grow past the manual drag limit");
assert.equal(await editor.evaluate(e => e.value), paragraph);
const grown = await width();
await editor.fill("첫 줄"); await typing.waitForTimeout(40);
assert.equal(await width(), grown, "deleting text does not shrink the user's column");
await editor.press("End");
const before = await editor.evaluate(e => ({ height: e.getBoundingClientRect().height, line: parseFloat(getComputedStyle(e).lineHeight) }));
await editor.press("Enter");
const after = await editor.evaluate(e => ({ height: e.getBoundingClientRect().height, value: e.value, caret: window.getSelection().isCollapsed }));
assert.equal(after.value, "첫 줄\n");
assert(after.height >= before.height + before.line - 1, JSON.stringify({ before, after }));
assert(after.caret);
await editor.press("End"); await editor.press("Backspace");
assert.equal(await editor.evaluate(e => e.value), "첫 줄", "one Backspace removes the final newline after End");
await editor.press("Enter");
await typing.keyboard.insertText("둘째 줄");
assert.equal(await editor.evaluate(e => e.value), "첫 줄\n둘째 줄");
await editor.press("Enter"); await editor.press("Enter"); await typing.keyboard.insertText("넷째 줄");
assert.equal(await editor.evaluate(e => e.value), "첫 줄\n둘째 줄\n\n넷째 줄");
await editor.evaluate(e => {
const event = new InputEvent("beforeinput", { inputType: "insertParagraph", bubbles: true, cancelable: true }); e.dispatchEvent(event);
});
assert.equal(await editor.evaluate(e => e.value), "첫 줄\n둘째 줄\n\n넷째 줄\n");
await typing.keyboard.insertText("모바일 개행");
await editor.evaluate(e => e.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", isComposing: true, bubbles: true, cancelable: true })));
assert((await editor.evaluate(e => e.value)).endsWith("모바일 개행"), "IME confirmation does not insert an extra newline");
await typing.evaluate(() => document.documentElement.classList.add("pj-ui-scale"));
const zoomedWidth = await width();
await editor.fill(paragraph.repeat(2)); await typing.waitForTimeout(60);
assert((await width()) > zoomedWidth * 1.5, "live growth uses logical widths at 75% zoom");
assert.equal(await editor.evaluate(e => e.value), paragraph.repeat(2));
await editor.evaluate(e => { e.value = "pj-rich:v1:" + JSON.stringify([{ text: "큰 글씨", size: 32, bold: true }]); });
await editor.press("End");
const bigBefore = await editor.evaluate(e => e.getBoundingClientRect().height);
await editor.press("Enter");
const bigAfter = await editor.evaluate(e => ({ height: e.getBoundingClientRect().height, text: window.PJGoalText.readRuns(e).map(r => r.text).join("") }));
assert.equal(bigAfter.text, "큰 글씨\n");
assert(bigAfter.height > bigBefore + 20, "large styled Enter shows an unclipped new line at 75% zoom " + JSON.stringify({ bigBefore, bigAfter }));
await typing.keyboard.insertText("다음 줄");
assert.equal(await editor.evaluate(e => window.PJGoalText.readRuns(e).map(r => r.text).join("")), "큰 글씨\n다음 줄");
await editor.evaluate(e => {
const walker = document.createTreeWalker(e, NodeFilter.SHOW_TEXT); let text;
while ((text = walker.nextNode())) {
if (text.textContent.includes("다음 줄")) {
const r = document.createRange(); r.setStart(text, 0); r.setEnd(text, 2);
const s = window.getSelection(); s.removeAllRanges(); s.addRange(r); break;
}
}
e.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
});
await typing.getByRole("button", { name: "기울임", exact: true }).click();
const multilineRuns = await editor.evaluate(e => window.PJGoalText.readRuns(e));
assert.equal(multilineRuns.map(r => r.text).join(""), "큰 글씨\n다음 줄");
assert(multilineRuns.some(r => r.text === "다음" && r.italic), "formatting respects newlines when calculating selection offsets");
assert(!multilineRuns[0].italic, "the first paragraph is not formatted by selecting the second");
const numeric = typing.locator(meeting ? 'tr[data-item="2"] .pj-meet-amount[data-field="target_amount"]' : 'input.pj-goal-num[data-month="2"]').first();
const beforeNumber = await numeric.locator("..").evaluate(td => td.getBoundingClientRect().width);
await numeric.fill("123,456,789,012,345,678,901,234,567,890");
await typing.waitForTimeout(60);
assert(await numeric.locator("..").evaluate((td, old) => td.getBoundingClientRect().width > old, beforeNumber), "numeric cells grow while editing");
const name = typing.locator(meeting ? 'tr[data-item="2"] .pj-meet-label' : 'tr[data-row-id="10"] .pj-goal-row-text');
await name.click();
const beforeName = await name.locator("..").evaluate(td => td.getBoundingClientRect().width);
await name.fill("항목 이름도 입력 길이에 맞게 자동으로 넓어집니다"); await typing.waitForTimeout(60);
assert(await name.locator("..").evaluate((td, old) => td.getBoundingClientRect().width > old, beforeName));
assert.deepEqual(typingErrors, []);
await typing.close();
console.log("PASS " + (meeting ? "meeting" : "goals") + " live text/numeric/name growth, single Enter blank line, repeated Enter, mobile input and IME");
}
const mergedTyping = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
await mergedTyping.goto("http://127.0.0.1:" + server.address().port + "/project/goals/2026/meetings/9?merged");
const mergedEditor = mergedTyping.locator('td[data-meet-item="2"] .pj-meet-text');
const otherWidth = await mergedTyping.locator('col[data-meet-col="target"]').evaluate(c => c.style.width);
await mergedEditor.fill("세로 병합한 칸의 내용도 길이에 따라 열 너비를 늘립니다 ".repeat(5));
await mergedTyping.waitForTimeout(60);
assert((await mergedEditor.locator("..").boundingBox()).width > 600);
assert.equal(await mergedEditor.locator("..").getAttribute("rowspan"), "2");
assert.equal(await mergedTyping.locator('col[data-meet-col="target"]').evaluate(c => c.style.width), otherWidth);
await mergedTyping.close();
console.log("PASS merged meeting live growth preserves rowspan and independent amount widths");
console.log("ALL PASS");
} finally {
if (browser) await browser.close();