feat: commit review feedback fixes from mobile (Closes #1376)
CI / lint (pull_request) Successful in 3m3s
CI / build-release (pull_request) Successful in 6s
CI / browser-journey (pull_request) Successful in 5m18s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-25 03:08:53 +00:00
1 parent b541c707fc
commit 502fcb30f5
12 files changed
+521 -69

No files matched your search

@@ -0,0 +1,85 @@
from pathlib import Path
import pytest
ROOT = Path(__file__).parents[2]
@pytest.mark.parametrize("viewport", [(320, 568), (390, 844)])
def test_mobile_author_commits_one_review_feedback_fix(viewport):
playwright = pytest.importorskip("playwright.sync_api")
html = (ROOT / "frontend" / "index.html").read_text()
detail = {
"state": "open", "merged": False, "head_sha": "abc1234",
"capabilities": {"authored": True},
"reviewers": [{
"review_id": 42, "login": "sam", "status": "changes_requested",
"head_sha": "abc1234", "blocking": True, "feedback_state": "loaded",
"comments": [{"id": 99, "path": "src/api.py", "body": "Handle empty state.", "line": 12}],
}],
"files": [{"filename": "src/api.py", "status": "modified", "diff_available": True,
"diff_lines": ["@@ -12 +12 @@", "+return empty"]}],
}
with playwright.sync_playwright() as runtime:
try:
browser = runtime.chromium.launch(headless=True)
except Exception as error:
pytest.skip(f"Chromium is not installed: {error}")
page = browser.new_page(viewport={"width": viewport[0], "height": viewport[1]})
page.set_content(html, wait_until="domcontentloaded")
page.add_style_tag(path=ROOT / "frontend" / "dashboard.css")
page.add_script_tag(path=ROOT / "frontend" / "pull-sheet.js")
page.evaluate(
"""detail => {
globalThis.confirm = () => true;
globalThis.fixCalls = [];
globalThis.fixItem = {repository:'stackchain/api', number:7, key:'stackchain/api#7'};
globalThis.fixDetail = detail;
globalThis.fixController = createPullSheet({fetchJson: async (path, options = {}) => {
fixCalls.push({path, options});
if ((options.method || 'GET') === 'GET') return {
path:'src/api.py', head_sha:'abc1234', blob_sha:'blob123', content:'return empty\\n'
};
return {path:'src/api.py', previous_head_sha:'abc1234', head_sha:'def5678', blob_sha:'blob456'};
}});
document.querySelector('#pull-sheet').classList.add('open');
document.querySelector('#pull-review').open = true;
document.querySelector('#pull-files').innerHTML = detail.files.map((file, index) =>
createPullSheet.renderFile(file, index, false, value => String(value))
).join('');
createPullSheet.bindFeedbackControls(document, fixController,
() => fixItem, () => fixDetail, () => 'alex');
createPullSheet.review(detail, null, document);
}""",
detail,
)
page.locator(".pull-review-feedback summary").click()
page.locator('[data-address-review-feedback="42"]').click()
page.locator("#make-pull-feedback-fix").click()
page.locator("#pull-feedback-file-content").fill("return handled\n")
page.locator("#pull-feedback-commit-message").fill("fix: handle empty state")
page.locator("#commit-pull-feedback-fix").click()
page.wait_for_function("fixCalls.length === 2")
result = page.evaluate("""() => ({
calls:fixCalls, head:fixDetail.head_sha,
editorHidden:document.querySelector('#pull-feedback-file-editor').hidden,
status:document.querySelector('#pull-feedback-status').textContent,
scrollWidth:document.documentElement.scrollWidth,
clientWidth:document.documentElement.clientWidth,
heights:Array.from(document.querySelectorAll('#pull-feedback-pass button'))
.filter(button => button.getClientRects().length > 0).map(button => button.getBoundingClientRect().height),
})""")
browser.close()
assert result["scrollWidth"] <= result["clientWidth"]
assert min(result["heights"]) >= 44
assert result["head"] == "def5678"
assert result["editorHidden"] is True
assert "committed" in result["status"].lower()
assert "path=src%2Fapi.py" in result["calls"][0]["path"]
body = result["calls"][1]["options"]["body"]
assert '"expected_blob_sha":"blob123"' in body
assert '"content":"return handled\\n"' in body