Integrate the compact DuneMenus layout
All checks were successful
DuneRealms Plugin CI / plugins (push) Successful in 2m12s
All checks were successful
DuneRealms Plugin CI / plugins (push) Successful in 2m12s
This commit is contained in:
parent
c7c390972d
commit
8544fb4f2e
2 changed files with 43 additions and 2 deletions
File diff suppressed because one or more lines are too long
|
|
@ -58,4 +58,29 @@ class SuppliedDocumentTest {
|
|||
var sell=new Card(49,"Sell item",List.of("List the item in your main hand"),"hopper");var mine=new Card(7,"My listings",List.of("Manage existing listings"),"chest");var item=new Card(13,"Real item",List.of("100 DM"),"iron_sword");
|
||||
String html=SuppliedDocument.html("exchange","Buy","",List.of(sell,mine,item),List.of());assertTrue(html.contains("class='market-tool' data-slot='49'"));assertTrue(html.contains("class='market-tool' data-slot='7'"));assertTrue(html.contains("class='card n0' data-slot='13'"));assertEquals(1,html.split("data-slot='49'",-1).length-1);
|
||||
}
|
||||
|
||||
@Test void everyFamilyHasOnlyLocalAssetsAndRealActions(){
|
||||
var allowedSrc=java.util.regex.Pattern.compile("(art/(logo|rihla)\\.png|pack/assets/[a-z0-9_/.-]+\\.png)");
|
||||
for(String id:List.of("hub","travel","exchange","clan","company","missions","spice","war","politics","house","equipment","bank","atm","withdraw","deposit","redeem","receipt","transfer")){
|
||||
var cards=new java.util.ArrayList<Card>();var images=new java.util.HashMap<Integer,String>();
|
||||
for(int n=0;n<6;n++){cards.add(new Card(n,"Entry "+n,List.of("Line "+n),"compass",n!=2));images.put(n,"pack/assets/dunerealms/textures/item/x"+n+".png");}
|
||||
cards.add(new Card(45,"Back",List.of(),"arrow"));
|
||||
String html=SuppliedDocument.html(id,id,"sub",cards,List.of("info"),images);
|
||||
assertFalse(html.matches("(?is).*(href\\s*=|https?:|javascript:|<script|\\son[a-z]+\\s*=|<iframe|<form).*"),id+" has a link or script");
|
||||
var src=java.util.regex.Pattern.compile("src='([^']*)'").matcher(html);
|
||||
while(src.find())assertTrue(allowedSrc.matcher(src.group(1)).matches()&&!src.group(1).contains(".."),id+" bad image "+src.group(1));
|
||||
var slots=new java.util.ArrayList<String>();var m=java.util.regex.Pattern.compile("data-slot='(\\d+)'").matcher(html.replaceAll("(?s)<style>.*?</style>",""));
|
||||
while(m.find())slots.add(m.group(1));
|
||||
assertEquals(slots.size(),new java.util.HashSet<>(slots).size(),id+" duplicate action slot");
|
||||
assertFalse(slots.contains("2"),id+" locked card has an action");
|
||||
for(String slot:slots){int value=Integer.parseInt(slot);int real=value>=1000?value-1000:value;assertTrue(cards.stream().anyMatch(c->c.slot()==real&&c.enabled()),id+" unknown or locked slot "+slot);}
|
||||
}
|
||||
}
|
||||
@Test void bundledArtFilesExist(){
|
||||
for(String f:List.of("menu-art/art/logo.png","menu-art/art/rihla.png"))assertNotNull(getClass().getClassLoader().getResource(f),f);
|
||||
}
|
||||
@Test void menuIsCentredAtThreeQuartersOfTheCanvas(){
|
||||
String html=SuppliedDocument.html("hub","Hub","",List.of(),List.of());
|
||||
assertTrue(html.contains(".frame{width:75%;margin:0 auto"));assertTrue(html.contains("THE SPICE MUST FLOW"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff