fix: merge GridStackView into DashboardView (#19)
CI / build-and-test (pull_request) Successful in 2m22s
CI / build-and-test (pull_request) Successful in 2m22s
DashboardView and GridStackView rendered the same three charts from the
same hardcoded data, so every chart factory method existed twice. The
dashboard is now the GridStackLayout variant at @Route(""):
- GridStackView deleted, its grid/toolbar/chart factories moved into
DashboardView, which keeps the point-click notifications the old
dashboard had.
- Charts size to their widget (100%/100%) instead of a fixed 400px.
- MainLayout has one dashboard entry; nav.gridstack/page.gridstack keys
dropped from all three bundles.
- Storage key is "dashboard" (was "gridstack-demo"), so a saved layout
from the old route is not reused.
- GridStackViewTest renamed to DashboardViewTest, plus a test asserting
the three charts render.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0124BiJikbhbiEsNfJxdWM69
This commit is contained in:
+19
-7
@@ -1,8 +1,11 @@
|
||||
package com.example.views;
|
||||
|
||||
import com.example.Application;
|
||||
import com.example.components.BarChart;
|
||||
import com.example.components.GridStackItem;
|
||||
import com.example.components.GridStackLayout;
|
||||
import com.example.components.LineChart;
|
||||
import com.example.components.PieChart;
|
||||
import com.vaadin.browserless.SpringBrowserlessTest;
|
||||
import com.vaadin.browserless.ViewPackages;
|
||||
import com.vaadin.browserless.internal.ElementUtilsKt;
|
||||
@@ -21,12 +24,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@ViewPackages(classes = GridStackView.class)
|
||||
class GridStackViewTest extends SpringBrowserlessTest {
|
||||
@ViewPackages(classes = DashboardView.class)
|
||||
class DashboardViewTest extends SpringBrowserlessTest {
|
||||
|
||||
@Test
|
||||
void view_rendersGridWithDefaultWidgets() {
|
||||
navigate(GridStackView.class);
|
||||
navigate(DashboardView.class);
|
||||
|
||||
GridStackLayout grid = $view(GridStackLayout.class).first();
|
||||
assertNotNull(grid);
|
||||
@@ -36,9 +39,18 @@ class GridStackViewTest extends SpringBrowserlessTest {
|
||||
assertTrue(layout.stream().allMatch(p -> p.w() > 0 && p.h() > 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void view_rendersTheThreeCharts() {
|
||||
navigate(DashboardView.class);
|
||||
|
||||
assertNotNull($view(LineChart.class).first());
|
||||
assertNotNull($view(BarChart.class).first());
|
||||
assertNotNull($view(PieChart.class).first());
|
||||
}
|
||||
|
||||
@Test
|
||||
void addAndCloseWidget_changesItemCount() {
|
||||
navigate(GridStackView.class);
|
||||
navigate(DashboardView.class);
|
||||
|
||||
GridStackLayout grid = $view(GridStackLayout.class).first();
|
||||
int initial = grid.getLayout().size();
|
||||
@@ -52,7 +64,7 @@ class GridStackViewTest extends SpringBrowserlessTest {
|
||||
|
||||
@Test
|
||||
void closeButton_removesTheClickedWidgetOnly() {
|
||||
navigate(GridStackView.class);
|
||||
navigate(DashboardView.class);
|
||||
|
||||
GridStackLayout grid = $view(GridStackLayout.class).first();
|
||||
GridStackItem first = $view(GridStackItem.class).first();
|
||||
@@ -68,7 +80,7 @@ class GridStackViewTest extends SpringBrowserlessTest {
|
||||
|
||||
@Test
|
||||
void closeListener_firesOnceItemIsDetached() {
|
||||
navigate(GridStackView.class);
|
||||
navigate(DashboardView.class);
|
||||
|
||||
GridStackLayout grid = $view(GridStackLayout.class).first();
|
||||
GridStackItem item = $view(GridStackItem.class).first();
|
||||
@@ -83,7 +95,7 @@ class GridStackViewTest extends SpringBrowserlessTest {
|
||||
|
||||
@Test
|
||||
void nonClosableItem_hasNoCloseButton() {
|
||||
navigate(GridStackView.class);
|
||||
navigate(DashboardView.class);
|
||||
|
||||
GridStackItem item = $view(GridStackItem.class).first();
|
||||
assertTrue(item.isClosable(), "items are closable by default");
|
||||
Reference in New Issue
Block a user