Skip to content

Commit 0a79bf2

Browse files
committed
fix: load first page when resource list opens
1 parent 27cb7a7 commit 0a79bf2

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎src/main/java/com/DesktopApplicationClientJava/controllers/ResourceListController.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ private void initialize() {
6060
searchField.setOnAction(e -> reloadFromStart());
6161
sortCombo.setOnAction(e -> reloadFromStart());
6262
resourceTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);
63+
64+
// Initial load on open. Guarded for FXML tooling previews where no services are wired.
65+
if (services != null && services.getResourceService() != null) {
66+
reloadFromStart();
67+
}
6368
}
6469

6570
// ===== UI setup =====

‎src/test/java/ui/ResourceListControllerTest.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,23 @@ void plainUserDoesNotSeeCreateButton(FxRobot robot) {
133133
assertFalse(create.isManaged());
134134
}
135135

136+
@Test
137+
void initialOpenLoadsFirstPageWithoutInteraction(FxRobot robot) {
138+
// Regression test for the missing auto-load: opening the page must fetch the first page
139+
// with no user interaction. Red until initialize() triggers the initial load.
140+
when(resourceService.search(any(), anyLong(), anyLong(), anyString(), anyString()))
141+
.thenReturn(List.of(resource("Документ 1")));
142+
143+
robot.interact(this::loadPage);
144+
145+
waitForLoadComplete(robot);
146+
assertEquals(1, rows(robot).size(), "page opened empty: no initial load happened");
147+
assertEquals("Показано 1–1", textOf(robot, "#pageInfoLabel"));
148+
}
149+
136150
@Test
137151
void sortDefaultsToNewestFirst(FxRobot robot) {
152+
138153
ComboBox<String> sort = robot.lookup("#sortCombo").queryAs(ComboBox.class);
139154
assertEquals(
140155
List.of("Сначала новые", "Сначала старые", "По названию (А-Я)", "По названию (Я-А)"),

0 commit comments

Comments
 (0)