Files
Aislo/resources/tester/test_spreadsheet_clip_used.py
T

58 lines
1.9 KiB
Python

"""스프레드시트 행 · 열 · 전체 고른 복사 = 쓴 최외곽까지(PLAN 99-4).
`clipWholeToUsed`(순수) · `blockToClipboard` 를 vite `--ssr` 로 번들해 Node 로 돌림 —
열 머리 → 쓴 줄 수만 · 행 머리 → 쓴 칸 수만 · 전체 → 최외곽 사각형 · 빈 시트 → 빈 복사 · 보통 범위는 그대로.
"""
from __future__ import annotations
import json
import shutil
import subprocess
import tempfile
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
ENTRY = ROOT / "resources" / "tester" / "spreadsheet" / "spreadsheet_clip_used_entry.ts"
VITE = ROOT / "config" / "node_modules" / "vite" / "bin" / "vite.js"
@pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음")
def test_고른_복사_쓴_범위까지():
with tempfile.TemporaryDirectory(prefix="spreadsheet_clip_used_") as outdir:
entry_rel = "../" + str(ENTRY.relative_to(ROOT)).replace("\\", "/")
build = subprocess.run(
[
"node",
str(VITE),
"build",
"--configLoader",
"runner",
"--ssr",
entry_rel,
"--outDir",
outdir,
],
cwd=str(ROOT),
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=120,
)
assert build.returncode == 0, f"vite ssr 번들 실패:\n{build.stdout}\n{build.stderr}"
run = subprocess.run(
["node", str(Path(outdir) / "spreadsheet_clip_used_entry.js")],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=60,
)
assert run.stdout.strip(), run.stderr
result = json.loads(run.stdout)
assert result["fail"] == 0, result["failures"]
assert result["pass"] == 14