feat: make mobile dock progressive (Closes #1427)
This commit is contained in:
1 parent
edd653eaaf
commit
62de2e6011
22 files changed
+439
-31
No files matched your search
@@ -0,0 +1,60 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
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_mobile_work_and_queues_are_usable_before_optional_hydration(viewport):
|
||||
with sync_playwright() as playwright:
|
||||
browser = playwright.chromium.launch()
|
||||
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 / "my-work.js")
|
||||
page.add_script_tag(path=FRONTEND / "context-poller.js")
|
||||
page.evaluate(
|
||||
"""() => {
|
||||
window.fetch = async () => ({
|
||||
ok:true, headers:{get:()=>null}, json:async()=>({
|
||||
context:{
|
||||
user:{login:'timmy'},
|
||||
issues:[{
|
||||
number:1427,title:'Progressive mobile dock',repository:'stackchain/stackchain-dashboard',
|
||||
assignees:['timmy'],work_reasons:['created_by_me'],url:'https://forge.example/issues/1427',
|
||||
}],
|
||||
pull_requests:[],
|
||||
},
|
||||
events:[],notifications:[],
|
||||
}),
|
||||
});
|
||||
}"""
|
||||
)
|
||||
page.add_script_tag(path=FRONTEND / "progressive-my-work.js")
|
||||
expect(page.locator("#my-work-status")).to_contain_text("1 assigned work item")
|
||||
page.add_script_tag(path=FRONTEND / "progressive-mobile-dock.js")
|
||||
|
||||
page.locator('[data-mobile-task="queues"]').click()
|
||||
expect(page.locator("#mobile-queue-sheet")).to_be_visible()
|
||||
expect(page.locator('[data-mobile-queue="filed"] [data-mobile-queue-count]')).to_have_text("1")
|
||||
page.locator(".mobile-queue-all summary").click()
|
||||
expect(page.locator('[data-mobile-queue="delivery"]')).to_contain_text("Still loading")
|
||||
next_action = page.locator("#mobile-queue-next-action")
|
||||
bounds = next_action.bounding_box()
|
||||
assert bounds and bounds["height"] >= 44
|
||||
assert page.evaluate("document.documentElement.scrollWidth <= window.innerWidth")
|
||||
|
||||
page.locator('[data-mobile-queue="filed"]').click()
|
||||
expect(page.locator("#progressive-work-detail")).to_be_visible()
|
||||
expect(page.locator("#progressive-work-detail-title")).to_have_text("Progressive mobile dock")
|
||||
page.locator("#close-progressive-work-detail").click()
|
||||
|
||||
page.locator('[data-mobile-task="work"]').click()
|
||||
expect(page.locator("#progressive-work-detail")).to_be_visible()
|
||||
expect(page.locator("#progressive-work-detail-title")).to_have_text("Progressive mobile dock")
|
||||
assert page.evaluate("document.documentElement.scrollWidth <= window.innerWidth")
|
||||
browser.close()
|
||||
Reference in new issue
Block a user