fix profile page
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""Set a profile picture and check it on the profile (configuration) page."""
|
||||
import asyncio, os
|
||||
from playwright.async_api import async_playwright
|
||||
from browser import login, BASE, OUT
|
||||
|
||||
S = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
async def header(page):
|
||||
return await page.evaluate("""() => {
|
||||
const h = document.querySelector('#avatar header');
|
||||
const s = document.querySelector('#avatar header span.primary');
|
||||
return h ? [getComputedStyle(h).backgroundImage, s && getComputedStyle(s).backgroundImage,
|
||||
h.getBoundingClientRect().height] : null;
|
||||
}""")
|
||||
|
||||
|
||||
async def main():
|
||||
async with async_playwright() as p:
|
||||
browser = await p.chromium.launch()
|
||||
ctx, page, errors = await login(browser, "alice@localhost", "alicepass", "avatar")
|
||||
bad = []
|
||||
page.on("response", lambda r: r.status >= 400 and bad.append(f"{r.status} {r.url}"))
|
||||
await page.goto(BASE + "/configuration")
|
||||
await page.wait_for_timeout(4000)
|
||||
print("before:", await header(page))
|
||||
await page.screenshot(path=f"{OUT}/avatar_1_before.png")
|
||||
|
||||
await page.evaluate("Avatar_ajaxGetForm()")
|
||||
await page.wait_for_selector("#dialog input[type=file]", state="attached", timeout=10000)
|
||||
await page.set_input_files("#dialog input[type=file]", f"{S}/test.png")
|
||||
await page.wait_for_timeout(2000)
|
||||
print("photobin length:", await page.evaluate("document.querySelector('[name=photobin]').value.length"))
|
||||
await page.screenshot(path=f"{OUT}/avatar_2_form.png")
|
||||
await page.click("#dialog footer button:last-child")
|
||||
await page.wait_for_timeout(4000)
|
||||
print("after submit:", await header(page))
|
||||
await page.screenshot(path=f"{OUT}/avatar_3_after.png")
|
||||
|
||||
await page.goto(BASE + "/configuration")
|
||||
await page.wait_for_timeout(4000)
|
||||
print("after reload:", await header(page))
|
||||
print("nav avatar:", await page.evaluate("[...document.querySelectorAll('nav img, nav span.primary')].map(e => e.src || getComputedStyle(e).backgroundImage).slice(0, 3)"))
|
||||
await page.screenshot(path=f"{OUT}/avatar_4_reload.png")
|
||||
for e in errors + bad:
|
||||
print(e)
|
||||
await browser.close()
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user