UI修改
This commit is contained in:
@@ -8,7 +8,7 @@ async function moduleUrl(file,replace=code=>code){
|
||||
return 'data:text/javascript;base64,'+Buffer.from(replace(code)).toString('base64');
|
||||
}
|
||||
const routing=await moduleUrl('../src/lib/routing.ts'),protocol=await moduleUrl('../src/lib/api/protocol.ts');
|
||||
const {navigationEntries,navigationIsActive,mobileNavigationEntries}=await import(await moduleUrl('../src/lib/site-navigation.ts',code=>code.replace("'./api/protocol'",JSON.stringify(protocol)).replace("'./routing'",JSON.stringify(routing))));
|
||||
const {navigationEntries,navigationIsActive,mobileNavigationEntries,withoutRemovedNavigation}=await import(await moduleUrl('../src/lib/site-navigation.ts',code=>code.replace("'./api/protocol'",JSON.stringify(protocol)).replace("'./routing'",JSON.stringify(routing))));
|
||||
const item=(id,name,urlValue,extra={})=>({id,name,urlValue,categoryType:1,...extra});
|
||||
|
||||
test('API order, labels, icons and nested destinations are preserved while footer and removed video entries stay absent',()=>{
|
||||
@@ -20,7 +20,14 @@ test('API order, labels, icons and nested destinations are preserved while foote
|
||||
|
||||
test('known API aliases and empty system entries generate native destinations directly without redirects',()=>{
|
||||
const entries=navigationEntries({categoryList:[item(1,'首页',''),item(2,'排行','/hot'),item(3,'回家的路',''),item(4,'福利应用',''),item(5,'名字由后台决定','/shorts?sort=2'),item(6,'未知空地址','')]});
|
||||
assert.deepEqual(entries.map(entry=>entry.href),['/','/rank/hot/','/home-road/','/apps/','/shorts/?sort=2']);
|
||||
assert.deepEqual(entries.map(entry=>entry.href),['/','/rank/hot/','/home-road/','/shorts/?sort=2']);
|
||||
});
|
||||
|
||||
test('backend navigation entries for the removed welfare app directory are filtered out',()=>{
|
||||
const entries=navigationEntries({categoryList:[item(1,'短剧','/shorts/'),item(2,'应用','/apps/'),item(3,'应用二','/application'),item(4,'福利应用','https://drama.test/apps/'),item(5,'福利应用','/topics/'),item(6,'目录','',{categoryType:2,translationList:[{id:7,name:'应用',urlValue:'/apps/'},{id:8,name:'专题',urlValue:'/topics/'}]})]},'https://drama.test');
|
||||
assert.deepEqual(entries.map(entry=>entry.name),['短剧','目录']);
|
||||
assert.deepEqual(entries[1].children.map(entry=>entry.href),['/topics/']);
|
||||
assert.ok(!JSON.stringify(entries).includes('/apps'));
|
||||
});
|
||||
|
||||
test('links reject executable addresses, credentials and removed routes, and keep external URLs external',()=>{
|
||||
@@ -38,3 +45,10 @@ test('active navigation follows configured destinations, independent pages, pagi
|
||||
assert.equal(navigationIsActive('/shorts/?sort=2','/shorts/page/2/?sort=2&campaign=test'),true);assert.equal(navigationIsActive('/shorts/?sort=2','/shorts/?sort=1'),false);
|
||||
assert.equal(navigationIsActive('https://example.net/shorts/','/shorts/'),false);assert.equal(navigationIsActive('/series/','/series/'),false);
|
||||
});
|
||||
|
||||
test('the serialized backend navigation payload no longer carries welfare-app entries',()=>{
|
||||
const data=withoutRemovedNavigation({categoryList:[{id:1,name:'短剧',urlValue:'/shorts/',categoryType:1},{id:2,name:'福利应用',urlValue:'',categoryType:1},{id:3,name:'应用',urlValue:'https://drama.test/apps/',categoryType:1},{id:4,name:'目录',urlValue:'',categoryType:2,translationList:[{id:5,name:'应用',urlValue:'/application'},{id:6,name:'专题',urlValue:'/topics/'}]}]});
|
||||
assert.deepEqual(data.categoryList.map(item=>item.id),[1,4]);
|
||||
assert.deepEqual(data.categoryList[1].translationList.map(item=>item.id),[6]);
|
||||
assert.deepEqual(withoutRemovedNavigation(null).categoryList,[]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user