Skip to content

Commit

Permalink
JNG-5855 test groups and tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Jul 22, 2024
1 parent 3bf5840 commit f0d9659
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ rule ViewDeclarationVisualElement
t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/ViewDeclarationVisualElement");
t.name = s.name;
t.~pos = 0;
t.col = 12d;
t.direction = UI!Axis#VERTICAL;
t.label = null; // we don't need labels for root visual elements
log.debug("ViewDeclarationVisualElement: " + t.name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rule AbstractViewGroupDeclaration
t.stretch = UI!ui::Stretch#BOTH;
}

t.col = s.getWidth().isDefined() ? s.getWidth().value.asReal() : 12.asReal();
t.col = s.getWidth().isDefined() ? s.getWidth().value.asReal() : 12d;


if (t.~pos.isUndefined()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rule TabBarVisualElement
t.setId(actorDeclaration.name + "/(jsl/" + s.getId() + ")/TabBarVisualElement");
t.name = s.name;
t.~pos = s.~pos;
t.col = s.getWidth().isDefined() ? s.getWidth().value.asReal() : 12.asReal();
t.col = s.getWidth().isDefined() ? s.getWidth().value.asReal() : 12d;

if (s.getLabelModifier().isDefined()) {
t.label = s.getLabelModifier().value.value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hu.blackbelt.judo.tatami.jsl.jsl2ui.application;

import hu.blackbelt.judo.meta.jsl.runtime.JslParser;
import hu.blackbelt.judo.meta.ui.Application;
import hu.blackbelt.judo.meta.ui.*;
import hu.blackbelt.judo.tatami.jsl.jsl2ui.AbstractTest;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -13,7 +13,7 @@
import java.nio.file.Paths;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

@Slf4j
public class JslModel2UiWidgetsTest extends AbstractTest {
Expand Down Expand Up @@ -80,7 +80,7 @@ view UserView(User u) {
field String stringDerived <= u.string;
}
group level3 width:6 frame:true icon:"dog" label:"Level 3" orientation:horizontal {
group level22 width:6 frame:true icon:"dog" label:"Level 2 - 2" orientation:horizontal {
field Boolean booleanDerived <= u.boolean;
field Date dateDerived <= u.date;
field Numeric numericDerived <= u.numeric;
Expand All @@ -91,7 +91,7 @@ view UserView(User u) {
field Time timeDerived <= u.time;
}
group tab2 label:"Tab2" icon:"numbers" h-align:center {
group tab2 label:"Tab2" icon:"numbers" h-align:right {
field Timestamp timestampDerived <= u.timestamp;
field MyEnum mappedEnum <= u.`enum` bind default:MyEnum#Crazy;
}
Expand All @@ -111,5 +111,96 @@ view UserView(User u) {
assertEquals(1, apps.size());

Application app = apps.get(0);

List<PageContainer> pageContainers = app.getPageContainers();

assertEquals(2, pageContainers.size());

PageContainer dashboard = pageContainers.stream().filter(c -> c.getName().equals("BasicWidgetsTestModel::WidgetsActor::Dashboard")).findFirst().orElseThrow();
PageContainer user = pageContainers.stream().filter(c -> c.getName().equals("BasicWidgetsTestModel::WidgetsActor::user::PageContainer")).findFirst().orElseThrow();

// Dashboard
assertEquals(0, dashboard.getChildren().size());

// User

assertEquals(1, user.getChildren().size());

// Root Flex
Flex rootFlex = (Flex) user.getChildren().get(0);

assertEquals("UserView", rootFlex.getName());
assertNull(rootFlex.getLabel());
assertEquals(12, rootFlex.getCol());
assertEquals(Axis.VERTICAL, rootFlex.getDirection());
assertEquals(1, rootFlex.getChildren().size());

// level1

Flex level1 = (Flex) rootFlex.getChildren().get(0);

assertEquals("level1", level1.getName());
assertEquals("Yo", level1.getLabel());
assertEquals("text", level1.getIcon().getIconName());
assertEquals(12, level1.getCol());
assertEquals(Axis.VERTICAL, level1.getDirection());
assertEquals(3, level1.getChildren().size());

// level2

Flex level2 = (Flex) level1.getChildren().stream().filter(c -> c.getName().equals("level2")).findFirst().orElseThrow();

assertEquals("level2", level2.getName());
assertEquals("Level 2", level2.getLabel());
assertEquals("unicorn", level2.getIcon().getIconName());
assertEquals(12, level2.getCol());
assertEquals(Axis.VERTICAL, level2.getDirection());
assertNotNull(level2.getFrame());
assertNotNull(level2.getStretch());
assertEquals(0, level2.getChildren().size());

// level2 - 2

Flex level22 = (Flex) level1.getChildren().stream().filter(c -> c.getName().equals("level22")).findFirst().orElseThrow();

assertEquals("level22", level22.getName());
assertEquals("Level 2 - 2", level22.getLabel());
assertEquals("dog", level22.getIcon().getIconName());
assertEquals(6, level22.getCol());
assertEquals(Axis.HORIZONTAL, level22.getDirection());
assertEquals(0, level22.getChildren().size());

// tabs 0

TabController tabs0 = (TabController) level1.getChildren().stream().filter(c -> c.getName().equals("tabs0")).findFirst().orElseThrow();

assertEquals("tabs0", tabs0.getName());
assertEquals(6, tabs0.getCol());
assertEquals(TabOrientation.HORIZONTAL, tabs0.getOrientation());
assertEquals(2, tabs0.getTabs().size());

// tab1

Tab tab1 = tabs0.getTabs().stream().filter(t -> t.getName().equals("tab1")).findFirst().orElseThrow();
Flex tab1Element = (Flex) tab1.getElement();

assertEquals("tab1", tab1Element.getName());
assertEquals(12, tab1Element.getCol());
assertEquals("Tab1", tab1Element.getLabel());
assertEquals("numbers", tab1Element.getIcon().getIconName());
assertEquals(Axis.VERTICAL, tab1Element.getDirection());
assertEquals(CrossAxisAlignment.START, tab1Element.getCrossAxisAlignment());

// tab2

Tab tab2 = tabs0.getTabs().stream().filter(t -> t.getName().equals("tab2")).findFirst().orElseThrow();
Flex tab2Element = (Flex) tab2.getElement();

assertEquals("tab2", tab2Element.getName());
assertEquals(12, tab2Element.getCol());
assertEquals("Tab2", tab2Element.getLabel());
assertEquals("numbers", tab2Element.getIcon().getIconName());
assertEquals(Axis.VERTICAL, tab2Element.getDirection());
assertEquals(CrossAxisAlignment.END, tab2Element.getCrossAxisAlignment());
}
}

0 comments on commit f0d9659

Please sign in to comment.