Discover Table compatibility and declared Row alignment
This commit is contained in:
@@ -691,6 +691,118 @@ public final class ProjectionHostChecks {
|
||||
});
|
||||
}
|
||||
|
||||
private static void tableDiscovery(DesignerPane pane, DocumentSession document, String full)
|
||||
throws Exception {
|
||||
bindingTab(pane, "Table / Columns");
|
||||
tableSelect(pane, "bindings", 0);
|
||||
click(pane, "Discover / Validate Table");
|
||||
await(() -> fx(() -> !((ComboBox<?>) pane.lookup("#table-attributes")).getItems().isEmpty()));
|
||||
check(
|
||||
fx(
|
||||
() ->
|
||||
((Label) pane.lookup("#table-status"))
|
||||
.getText()
|
||||
.contains("matches direct bindings")),
|
||||
"Declared Row alignment missing");
|
||||
fx(
|
||||
() -> {
|
||||
var rows =
|
||||
(ComboBox<de.neitzel.fxdesigner.protocol.BindingMetadata.RepeatOption>)
|
||||
pane.lookup("#table-rows");
|
||||
check(
|
||||
rows.getItems().stream()
|
||||
.anyMatch(
|
||||
c ->
|
||||
c.name().equals("fixture.components.VisitRow")
|
||||
&& c.status().equals("COMPATIBLE")),
|
||||
"Compatible Row absent");
|
||||
check(
|
||||
rows.getItems().stream()
|
||||
.anyMatch(
|
||||
c ->
|
||||
c.name().equals("fixture.components.WrongRepeatCard")
|
||||
&& c.status().equals("INCOMPATIBLE")),
|
||||
"Wrong Model Row accepted");
|
||||
check(
|
||||
((TextField) pane.lookup("#table-row"))
|
||||
.getText()
|
||||
.equals("fixture.components.VisitRow"),
|
||||
"Discovery replaced explicit Row");
|
||||
var attrs =
|
||||
(ComboBox<de.neitzel.fxdesigner.protocol.BindingMetadata.RepeatOption>)
|
||||
pane.lookup("#table-attributes");
|
||||
attrs
|
||||
.getSelectionModel()
|
||||
.select(
|
||||
attrs.getItems().stream()
|
||||
.filter(c -> c.name().equals("street"))
|
||||
.findFirst()
|
||||
.orElseThrow());
|
||||
return null;
|
||||
});
|
||||
check(documentText(document).equals(full), "Table discovery changed source");
|
||||
// The Row draft must participate in discovery even though the parent source is unchanged.
|
||||
var rowFile =
|
||||
java.nio.file.Path.of(document.snapshot().toCompletableFuture().get().document())
|
||||
.resolveSibling("VisitRow.fxml");
|
||||
String disk = java.nio.file.Files.readString(rowFile);
|
||||
try (var row =
|
||||
pane.kit().host().documents().open(rowFile.toUri()).toCompletableFuture().get()) {
|
||||
String original = documentText(row);
|
||||
set(row, original.replace("path=\"street\"", "path=\"different\""));
|
||||
await(() -> fx(() -> ((ComboBox<?>) pane.lookup("#table-rows")).getItems().isEmpty()));
|
||||
click(pane, "Discover / Validate Table");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
((Label) pane.lookup("#table-status"))
|
||||
.getText()
|
||||
.contains("mismatch at Column")));
|
||||
check(
|
||||
java.nio.file.Files.readString(rowFile).equals(disk),
|
||||
"Row discovery saved or rewrote Row source");
|
||||
set(row, original);
|
||||
click(pane, "Discover / Validate Table");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
((Label) pane.lookup("#table-status"))
|
||||
.getText()
|
||||
.contains("matches direct bindings")));
|
||||
}
|
||||
tableSelect(pane, "columns", 0);
|
||||
tableField(pane, "attribute", "missing");
|
||||
click(pane, "Apply Column");
|
||||
await(() -> !documentText(document).equals(full));
|
||||
String invalid = documentText(document);
|
||||
await(() -> fx(() -> source(pane).getText().equals(invalid)));
|
||||
document
|
||||
.save(document.snapshot().toCompletableFuture().get().revision())
|
||||
.toCompletableFuture()
|
||||
.get();
|
||||
click(pane, "Render drafts");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
pane.lookupAll(".label").stream()
|
||||
.anyMatch(
|
||||
n ->
|
||||
n instanceof Label l
|
||||
&& l.getText() != null
|
||||
&& l.getText().startsWith("Preview blocked:")
|
||||
&& l.getText().contains("simple read/write Attribute"))));
|
||||
repeatHistory(pane, document, full, invalid);
|
||||
click(pane, "Undo");
|
||||
await(() -> documentText(document).equals(full));
|
||||
await(() -> fx(() -> source(pane).getText().equals(full)));
|
||||
System.out.println(
|
||||
"PASS Table discovery: choices, explicit selection, Row draft overlays/alignment, type"
|
||||
+ " errors, preview gating and undo/redo");
|
||||
}
|
||||
|
||||
private static void tableEdits(DesignerPane pane, DocumentSession document, String full)
|
||||
throws Exception {
|
||||
set(document, full);
|
||||
@@ -1413,6 +1525,7 @@ public final class ProjectionHostChecks {
|
||||
directBindingEdits(pane, document, full);
|
||||
computedBindingEdits(pane, document, full);
|
||||
repeatBindingEdits(pane, document, full);
|
||||
tableDiscovery(pane, document, full);
|
||||
tableEdits(pane, document, full);
|
||||
document
|
||||
.save(document.snapshot().toCompletableFuture().get().revision())
|
||||
|
||||
Reference in New Issue
Block a user