以 ckcloudManage a44810c 为基础,只保留资产页面(台账、单据、基础数据、同步任务)、 登录/错误/个人资料等公共页面,以及资产单据“查看流程”用到的流程详情页; 统一登录应用编码默认 CK_ASSET,标题“资产管理”,本地端口 9090。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
"""Regression: the preselected/default application loads grants and master status."""
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
ORIGIN = "http://127.0.0.1:9000"
|
||||
|
||||
|
||||
def mock(route, code, data=None):
|
||||
route.fulfill(json={"code": code, "data": data, "msg": "test response"},
|
||||
headers={"access-control-allow-origin": "*"})
|
||||
|
||||
|
||||
def main():
|
||||
with sync_playwright() as playwright:
|
||||
browser = playwright.chromium.launch(headless=True)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
page.route("**/admin-api/**", lambda route: mock(route, 0, []))
|
||||
page.route("**/system/sso-client/login-url**", lambda route: mock(route, 500))
|
||||
page.route("**/system/dict-data/simple-list**", lambda route: mock(route, 200, []))
|
||||
page.goto(ORIGIN + "/zcy/login?expired=1", wait_until="networkidle")
|
||||
page.evaluate("""async () => {
|
||||
const auth = await import('/src/utils/auth.ts')
|
||||
auth.setToken({accessToken: 'isolated-access', refreshToken: 'isolated-refresh'})
|
||||
auth.setTenantId(1)
|
||||
}""")
|
||||
calls = []
|
||||
menus = [{
|
||||
"id": 5015, "parentId": 0, "name": "应用中心", "path": "/system/application",
|
||||
"component": "Layout", "visible": True, "keepAlive": True,
|
||||
"children": [{
|
||||
"id": 5088, "parentId": 5015, "name": "应用授权", "path": "grant",
|
||||
"component": "system/application/grant/index", "componentName": "SystemApplicationGrant",
|
||||
"visible": True, "keepAlive": True
|
||||
}]
|
||||
}]
|
||||
page.route("**/system/auth/get-permission-info**", lambda route: mock(route, 0, {
|
||||
"user": {"id": 1, "nickname": "测试用户", "deptId": 1},
|
||||
"permissions": ["system:application:api-grant"], "roles": ["super_admin"], "menus": menus
|
||||
}))
|
||||
page.route("**/system/application/simple-list**", lambda route: mock(route, 0, [
|
||||
{"id": 1, "name": "财开云", "status": 0}
|
||||
]))
|
||||
|
||||
def grant_page(route):
|
||||
calls.append(route.request.url)
|
||||
mock(route, 0, {"enabled": True, "total": 1, "list": [{
|
||||
"id": 11, "apiCode": "document.read", "name": "文件读取", "method": "GET",
|
||||
"pathTemplate": "/open-api/v1/file", "requiredScope": "file.read", "granted": True
|
||||
}]})
|
||||
|
||||
page.route("**/system/application/api-grant-page**", grant_page)
|
||||
page.goto(ORIGIN + "/system/application/grant?applicationId=1", wait_until="networkidle")
|
||||
try:
|
||||
page.get_by_text("文件读取").wait_for(timeout=10000)
|
||||
except Exception:
|
||||
print("url", page.url, "grant calls", calls, "page", page.locator("body").inner_text()[:1500])
|
||||
raise
|
||||
assert len(calls) == 1 and "applicationId=1" in calls[0], calls
|
||||
assert page.locator(".application-grant__master .el-switch.is-checked").count() == 1
|
||||
print("preselected application -> grant list and enabled master: PASS")
|
||||
calls.clear()
|
||||
page.goto(ORIGIN + "/system/application/grant", wait_until="networkidle")
|
||||
page.get_by_text("文件读取").wait_for(timeout=10000)
|
||||
assert len(calls) == 1 and "applicationId=1" in calls[0], calls
|
||||
assert page.locator(".application-grant__master .el-switch.is-checked").count() == 1
|
||||
print("default application -> grant list and enabled master: PASS")
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user