实现权限驱动的首页 Tab 并对齐 Android

This commit is contained in:
2026-07-06 17:27:54 +08:00
parent e04ad8f8f0
commit d79d3003e3
27 changed files with 2573 additions and 10 deletions

View File

@ -0,0 +1,52 @@
//
// RolePermissionMatcherTests.swift
// suixinkanTests
//
import XCTest
@testable import suixinkan
///
final class RolePermissionMatcherTests: XCTestCase {
private func makeItem(code: String, id: Int, name: String) -> RolePermissionResponse {
RolePermissionResponse(
role: RoleInfo(id: id, name: name, roleCode: code, notes: nil, permission: []),
scenic: []
)
}
func testMatchByRoleCodeHasHighestPriority() {
let list = [
makeItem(code: "photographer", id: 41, name: "摄影师"),
makeItem(code: "store_admin", id: 46, name: "店铺管理员"),
]
let matched = RolePermissionMatcher.match(
in: list,
roleCode: AppRoleCode.storeAdmin.rawValue,
roleName: "摄影师"
)
XCTAssertEqual(matched?.role.roleCode, AppRoleCode.storeAdmin.rawValue)
}
func testMatchByLegacyRoleIdWhenCodeMissing() {
let list = [makeItem(code: "", id: 53, name: "景区管理员")]
let matched = RolePermissionMatcher.match(
in: list,
roleCode: "",
roleName: "",
legacyRoleId: 53
)
XCTAssertEqual(matched?.role.id, 53)
}
func testMatchByRoleNameWhenCodeAndLegacyMissing() {
let list = [makeItem(code: "", id: 99, name: "剪辑师")]
let matched = RolePermissionMatcher.match(
in: list,
roleCode: "",
roleName: "剪辑师"
)
XCTAssertEqual(matched?.role.name, "剪辑师")
}
}