refactor: 拆分品牌业务类型与页面方案
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
This commit is contained in:
1 parent
f02e2cafbb
commit
0d9f4a7d6f
86 files changed
+4111
-1543
No files matched your search
@@ -4,12 +4,20 @@ import { createElement } from "react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { MemoryRouter, Route, Routes, resolvePath } from "react-router-dom";
|
||||
import { AdminOverviewRedirect, AdminRouter } from "../src/app/AdminRouter.ts";
|
||||
import {
|
||||
canCreateBrand,
|
||||
createBrandFallbackPath,
|
||||
createBrandRouteElement,
|
||||
} from "../src/app/route-access.ts";
|
||||
|
||||
test("后台父路由正确匹配所有菜单及深层链接", () => {
|
||||
const pages = [
|
||||
"overview",
|
||||
"publication",
|
||||
"brand",
|
||||
"brands",
|
||||
"brands/new",
|
||||
"page-scheme",
|
||||
"trust",
|
||||
"services",
|
||||
"inquiries",
|
||||
@@ -51,3 +59,17 @@ test("默认与无效地址的概览重定向为绝对地址且替换历史记
|
||||
assert.equal(resolvePath(redirect.props.to, pathname).pathname, "/admin/overview");
|
||||
}
|
||||
});
|
||||
|
||||
test("只有品牌负责人可以进入创建品牌路由", () => {
|
||||
assert.equal(canCreateBrand("owner"), true);
|
||||
for (const role of ["admin", "editor", "platform-admin"]) {
|
||||
assert.equal(canCreateBrand(role), false);
|
||||
}
|
||||
|
||||
const content = createElement("h1", null, "create-brand");
|
||||
assert.equal(createBrandRouteElement("owner", content), content);
|
||||
|
||||
const denied = createBrandRouteElement("admin", content);
|
||||
assert.equal(denied.props.to, createBrandFallbackPath);
|
||||
assert.equal(denied.props.replace, true);
|
||||
});
|
||||
Reference in new issue
Block a user