mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-10-07 16:18:54 +00:00
Compare commits
2 commits
5ba3f00157
...
bf4fd3b816
| Author | SHA1 | Date | |
|---|---|---|---|
| bf4fd3b816 | |||
| 38a743db37 |
2 changed files with 7 additions and 51 deletions
|
|
@ -332,15 +332,13 @@ function downloadSummaryPdf() {
|
|||
}
|
||||
|
||||
function adminStartEdit(email) {
|
||||
const requestedWeek = currentAdminWeek;
|
||||
setAdminActionDisabled('start-edit', true);
|
||||
adminFetch(ADMIN_URL + '?week=' + encodeURIComponent(requestedWeek), { headers: adminHeaders() })
|
||||
adminFetch(ADMIN_URL + '?week=' + encodeURIComponent(currentAdminWeek), { headers: adminHeaders() })
|
||||
.then(r => {
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
return r.json();
|
||||
})
|
||||
.then(data => {
|
||||
if (currentAdminWeek !== requestedWeek) return;
|
||||
lastAdminData = data;
|
||||
const order = data.orders.find(o => o.employee_email === email);
|
||||
if (!order) return;
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ def _render(*, google: bool = False, api_key: str = "test-key") -> str:
|
|||
def _google_credential() -> str:
|
||||
payload = json.dumps(
|
||||
{
|
||||
"name": "Test Admin",
|
||||
"email": "test-admin@example.com",
|
||||
"name": "Adam Moussa",
|
||||
"email": "adam.moussa@seahavenind.com",
|
||||
"picture": (
|
||||
"data:image/svg+xml,"
|
||||
"<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'/>"
|
||||
|
|
@ -101,14 +101,6 @@ def _mock_form_routes(page):
|
|||
),
|
||||
),
|
||||
)
|
||||
page.route(
|
||||
"**/api/admin/orders",
|
||||
lambda route: route.fulfill(
|
||||
status=403,
|
||||
content_type="application/json",
|
||||
body='{"error":"Forbidden"}',
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TestGenerateFormStructural:
|
||||
|
|
@ -365,15 +357,10 @@ class TestGenerateFormPlaywright:
|
|||
bottom: box.bottom,
|
||||
};
|
||||
};
|
||||
const footer = document.querySelector('#sticky-footer');
|
||||
return {
|
||||
clientWidth: document.documentElement.clientWidth,
|
||||
scrollWidth: document.documentElement.scrollWidth,
|
||||
viewportHeight: window.innerHeight,
|
||||
footer: {
|
||||
...rect('#sticky-footer'),
|
||||
position: getComputedStyle(footer).position,
|
||||
},
|
||||
footer: rect('#sticky-footer'),
|
||||
total: rect('#total-display'),
|
||||
count: rect('#count-display'),
|
||||
submit: rect('#submit-btn'),
|
||||
|
|
@ -386,9 +373,6 @@ class TestGenerateFormPlaywright:
|
|||
for selector in ("footer", "total", "count", "submit"):
|
||||
assert layout[selector]["left"] >= 0
|
||||
assert layout[selector]["right"] <= layout["clientWidth"]
|
||||
assert layout["footer"]["position"] == "fixed"
|
||||
assert layout["footer"]["top"] >= 0
|
||||
assert layout["footer"]["bottom"] <= layout["viewportHeight"]
|
||||
assert layout["lastCard"]["bottom"] <= layout["footer"]["top"]
|
||||
finally:
|
||||
browser.close()
|
||||
|
|
@ -447,7 +431,7 @@ class TestGenerateFormPlaywright:
|
|||
)
|
||||
assert page.locator("#total-display").inner_text() == "$10.80"
|
||||
|
||||
@pytest.mark.parametrize("width", [320, 375, 479])
|
||||
@pytest.mark.parametrize("width", [320, 375])
|
||||
def test_local_roster_has_no_horizontal_overflow(self, browser_page, width):
|
||||
page = browser_page
|
||||
page.set_viewport_size({"width": width, "height": 800})
|
||||
|
|
@ -462,8 +446,7 @@ class TestGenerateFormPlaywright:
|
|||
|
||||
class TestGenerateFormGooglePlaywright:
|
||||
@pytest.fixture(scope="class")
|
||||
@classmethod
|
||||
def signed_in_admin_page(cls, tmp_path_factory):
|
||||
def signed_in_admin_page(self, tmp_path_factory):
|
||||
try:
|
||||
from playwright.sync_api import sync_playwright
|
||||
except ImportError as exc: # pragma: no cover
|
||||
|
|
@ -545,32 +528,7 @@ class TestGenerateFormGooglePlaywright:
|
|||
"#admin-btn",
|
||||
"#sign-out-btn",
|
||||
):
|
||||
locator = page.locator(selector)
|
||||
assert locator.is_visible()
|
||||
bounds = locator.evaluate(
|
||||
"""element => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
return {
|
||||
left: rect.left,
|
||||
top: rect.top,
|
||||
right: rect.right,
|
||||
bottom: rect.bottom,
|
||||
viewportWidth: window.innerWidth,
|
||||
viewportHeight: window.innerHeight,
|
||||
};
|
||||
}"""
|
||||
)
|
||||
assert bounds["left"] >= 0
|
||||
assert bounds["top"] >= 0
|
||||
assert bounds["right"] <= bounds["viewportWidth"]
|
||||
assert bounds["bottom"] <= bounds["viewportHeight"]
|
||||
|
||||
for selector in ("#user-name", "#user-email"):
|
||||
assert page.locator(selector).evaluate(
|
||||
"""element =>
|
||||
element.scrollWidth <= element.clientWidth &&
|
||||
element.scrollHeight <= element.clientHeight"""
|
||||
)
|
||||
assert page.locator(selector).is_visible()
|
||||
assert page.locator("#admin-btn").is_enabled()
|
||||
assert page.locator("#sign-out-btn").is_enabled()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue