68 lines
2.9 KiB
Python
68 lines
2.9 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
if os.getenv("STACKCHAIN_RUN_RELEASE_E2E") != "1":
|
|
pytest.skip("packaged branch-cleanup journey runs only in the browser gate", allow_module_level=True)
|
|
pytest.importorskip("playwright.sync_api")
|
|
from playwright.sync_api import expect, sync_playwright
|
|
|
|
|
|
ROOT = Path(__file__).parents[2]
|
|
FRONTEND = ROOT / "frontend"
|
|
|
|
|
|
@pytest.mark.parametrize("viewport", [
|
|
{"width": 320, "height": 568},
|
|
{"width": 390, "height": 844},
|
|
])
|
|
def test_merged_source_branch_cleanup_is_phone_openable_and_exact(viewport):
|
|
with sync_playwright() as playwright:
|
|
browser = playwright.chromium.launch(headless=True)
|
|
page = browser.new_page(viewport=viewport)
|
|
page.set_content((FRONTEND / "index.html").read_text())
|
|
page.add_style_tag(path=FRONTEND / "dashboard.css")
|
|
page.add_script_tag(path=FRONTEND / "release-receipt.js")
|
|
result = page.evaluate("""async () => {
|
|
const calls=[];
|
|
const values=new Map();
|
|
const storage={
|
|
getItem:key=>values.get(key)||null,
|
|
setItem:(key,value)=>values.set(key,value),
|
|
removeItem:key=>values.delete(key),
|
|
};
|
|
const receipt=createReleaseReceipt({
|
|
storage,
|
|
getLogin:()=> 'timmy',
|
|
listNode:document.querySelector('#release-watchlist'),
|
|
confirmAction:()=>true,
|
|
fetchJson:async(path, options={})=>{
|
|
calls.push({path, method:options.method, body:options.body});
|
|
return {deleted:true, source_branch:'timmy/feature', source_head_sha:'abc1234'};
|
|
},
|
|
});
|
|
receipt.capture(
|
|
{repository:'stackchain/api', number:7, key:'stackchain/api#7'},
|
|
{merge_commit_sha:'merge456', source_branch:'timmy/feature', source_head_sha:'abc1234', source_repository:'stackchain/api'},
|
|
);
|
|
document.querySelector('#release-receipt-sheet').showModal();
|
|
const button=document.querySelector('.release-watchlist-actions button');
|
|
const box=button.getBoundingClientRect();
|
|
const label=button.getAttribute('aria-label');
|
|
button.click();
|
|
await new Promise(resolve=>setTimeout(resolve, 0));
|
|
return {
|
|
calls, label, height:box.height,
|
|
branch:document.querySelector('.release-branch-cleanup-status').textContent,
|
|
overflow:document.documentElement.scrollWidth > document.documentElement.clientWidth,
|
|
};
|
|
}""")
|
|
expect(page.locator("#release-receipt-sheet")).to_be_visible()
|
|
assert result["height"] >= 44
|
|
assert result["label"] == "Delete merged source branch timmy/feature at abc1234"
|
|
assert result["calls"][0]["method"] == "DELETE"
|
|
assert result["branch"] == "Branch timmy/feature · deleted"
|
|
assert result["overflow"] is False
|
|
browser.close()
|