整体UI修改
This commit is contained in:
@@ -15,13 +15,10 @@ const protocolUrl=await moduleUrl('../src/lib/api/protocol.ts');
|
||||
const renderUrl=await moduleUrl('../src/lib/client/render.ts',code=>code.replace('"../api/protocol"',JSON.stringify(protocolUrl)));
|
||||
const {pagination}=await import(renderUrl);
|
||||
const {bindPaginationJumps}=await import(await moduleUrl('../src/lib/client/navigation.ts'));
|
||||
const authUrl=await moduleUrl('../src/lib/client/auth.ts');
|
||||
const accountUrl=await moduleUrl('../src/lib/client/account.ts',code=>code.replace('"../api/protocol"',JSON.stringify(protocolUrl)).replace('"./render"',JSON.stringify(renderUrl)).replace("'./auth'",JSON.stringify(authUrl)));
|
||||
const {renderMember,renderWallet}=await import(accountUrl);
|
||||
|
||||
test('every paginated page type resolves directly from the page suffix',()=>{
|
||||
const keyword='都市 / page/7/?#%2F';
|
||||
const bases=['/shorts/','/topics/','/topics/7/','/theme/8/','/tag/9/','/config/31/','/rank/','/rank/hot/','/rank/new/','/rank/follow/','/search/'+encodeURIComponent(keyword)+'/', '/member/favorites/','/member/history/','/member/likes/','/member/purchased/','/info/deposit/','/info/deposit/vip/','/detail/23456/','/play/23456/90001/'];
|
||||
const bases=['/shorts/','/topics/','/topics/7/','/theme/8/','/tag/9/','/config/31/','/rank/','/rank/hot/','/rank/new/','/rank/follow/','/search/'+encodeURIComponent(keyword)+'/'];
|
||||
for(const base of bases){
|
||||
for(const page of [1,2,37]){
|
||||
const path=base+'page/'+page+'/';
|
||||
@@ -36,7 +33,8 @@ test('every paginated page type resolves directly from the page suffix',()=>{
|
||||
|
||||
test('invalid page numbers, nested page suffixes, and non-paginated sections are rejected',()=>{
|
||||
for(const value of ['0','-1','1.5','02','NaN','9007199254740992'])assert.equal(parseSitePath(`/shorts/page/${value}/`),null,value);
|
||||
for(const base of ['/','/apps/','/home-road/','/navigation/','/member/center/','/member/settings/','/info/about-us/'])assert.equal(parseSitePath(base+'page/2/'),null,base);
|
||||
for(const base of ['/','/apps/','/home-road/','/navigation/','/info/about-us/'])assert.equal(parseSitePath(base+'page/2/'),null,base);
|
||||
for(const base of ['/member/favorites/','/member/history/','/info/deposit/','/info/deposit/vip/','/info/settings/','/info/user-center/'])assert.equal(parseSitePath(base),null,base);
|
||||
assert.equal(parseSitePath('/shorts/page/2/page/3/'),null);
|
||||
assert.throws(()=>paginationPath('/shorts/',0));assert.throws(()=>paginationPath('/apps/',2));
|
||||
});
|
||||
@@ -49,7 +47,7 @@ test('page links retain filters and encoded search terms and sorting resets to t
|
||||
assert.equal(paginationPath(base,2),searchPath('都市 / 爱情?#%',2));
|
||||
const url=new URL(paginationPath(base,2),'https://drama.example');
|
||||
assert.equal(parseSitePath(url.pathname,url.search).key,'都市 / 爱情?#%');
|
||||
assert.equal(paginationPath('/play/7/90001/page/3/?commentSort=1',1,{commentSort:null}),'/play/7/90001/');
|
||||
for(const path of ['/detail/23456/page/2/','/play/23456/90001/page/2/'])assert.equal(parseSitePath(path),null,'detail and play pages have no comment pagination');
|
||||
});
|
||||
|
||||
test('pagination renders real page links with correct boundaries, current page, and bounded page numbers',()=>{
|
||||
@@ -93,27 +91,3 @@ test('jump forms navigate to independent routes, retain canonical slugs and filt
|
||||
if(previousInput===undefined)delete globalThis.HTMLInputElement;else globalThis.HTMLInputElement=previousInput;
|
||||
}
|
||||
});
|
||||
|
||||
test('personal library and wallet requests and page links use the route page',async()=>{
|
||||
const previousDocument=globalThis.document,calls=[];
|
||||
const root={innerHTML:'',querySelector:()=>null,addEventListener(){}};
|
||||
const user={userId:7,nickName:'测试用户'};
|
||||
const api={user,ensureSession:async()=>user,async get(path,query){
|
||||
calls.push({path,...query});
|
||||
if(path==='user/center/data')return {};
|
||||
if(path==='recharge/package/list')return {coinList:[],vipList:[]};
|
||||
return {list:[],totalCount:120};
|
||||
}};
|
||||
const app={api,signal:new AbortController().signal};
|
||||
globalThis.document={getElementById:()=>root};
|
||||
try{
|
||||
for(const [tab,endpoint] of [['favorites','playlet/collect/list'],['history','playlet/history/list'],['likes','playlet/like/list'],['purchased','playlet/bought/list']]){
|
||||
await renderMember(app,tab,3,page=>paginationPath(`/member/${tab}/page/3/`,page));
|
||||
const call=calls.at(-1);assert.equal(call.path,endpoint);assert.equal(call.pageNum,3);
|
||||
assert.ok(root.innerHTML.includes(`href="/member/${tab}/page/2/"`));
|
||||
}
|
||||
await renderWallet(app,true,3,page=>paginationPath('/info/deposit/vip/page/3/',page));
|
||||
assert.equal(calls.at(-1).path,'coin/trans/list');assert.equal(calls.at(-1).page,3);
|
||||
assert.ok(root.innerHTML.includes('href="/info/deposit/vip/page/4/"'));
|
||||
}finally{if(previousDocument===undefined)delete globalThis.document;else globalThis.document=previousDocument;}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user