You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.1 KiB
53 lines
2.1 KiB
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
from playwright.sync_api import Page, expect
|
|
|
|
from tests.e2e.helpers import expect_flash, login
|
|
|
|
|
|
def test_share_link_mobile_flow_supports_search_edit_and_return(
|
|
page: Page,
|
|
base_url: str,
|
|
admin_credentials: dict[str, str],
|
|
) -> None:
|
|
login(page, base_url, username=admin_credentials["username"], password=admin_credentials["password"])
|
|
|
|
page.goto(f"{base_url}/admin/share-links")
|
|
expect(page.get_by_role("heading", name="分享链接")).to_be_visible()
|
|
|
|
page.get_by_label("备注名(可选)").fill("移动端分享验证")
|
|
page.get_by_label("有效期(天)").fill("7")
|
|
page.get_by_role("button", name="创建分享链接").click()
|
|
expect_flash(page, "已创建分享链接。")
|
|
|
|
share_href = page.locator('a[href^="/s/"]').first.get_attribute("href")
|
|
assert share_href is not None
|
|
|
|
page.set_viewport_size({"width": 393, "height": 852})
|
|
page.goto(f"{base_url}{share_href}")
|
|
page_text = page.locator("body").text_content() or ""
|
|
|
|
assert "分享搜索" in page_text, page_text
|
|
|
|
page.locator("#share-search").fill("李阿姨")
|
|
page.locator("#share-search").press("Enter")
|
|
|
|
expect(page.get_by_role("link", name="点击编辑")).to_be_visible()
|
|
page.get_by_role("link", name="点击编辑").first.click()
|
|
|
|
expect(page).to_have_url(re.compile(r".*/s/.+/households/\d+/edit\?q=.*"))
|
|
expect(page.get_by_text("编辑信息")).to_be_visible()
|
|
expect(page.locator("#phone")).to_be_visible()
|
|
current_head_name = page.locator("#head_name").input_value().strip()
|
|
|
|
page.locator("#phone").fill("13922223333")
|
|
page.locator("#attendance_status").select_option("partial")
|
|
page.locator("#actual_attendee_count").fill("1")
|
|
page.locator("#note").fill("移动端分享页自动化更新")
|
|
page.get_by_role("button", name="保存并返回搜索").click()
|
|
|
|
expect(page).to_have_url(re.compile(r".*/s/.+\?q=.*"))
|
|
expect_flash(page, f"已保存 {current_head_name} 的信息。")
|
|
expect(page.locator("#share-search")).to_have_value("李阿姨")
|
|
|